code: def collate_1d(
      values,
      pad_idx=0,
      left_pad=False,
      shift_right=False,
      max_len=None,
      shift_id=1,
  ):
      """Convert a list of 1d tensors into a padded 2d tensor."""
      size = (
          max(v.size(0) for v in values) if max_len is None else max_len
      )
      res = values[0].new(len(values), size).fill_(pad_idx)
  
      def copy_tensor(src, dst):
          assert dst.numel() == src.numel()
          if shift_right:
              dst[1:] = src[:-1]
              dst[0] = shift_id
          else:
              dst.copy_(src)
  
      for i, v in enumerate(values):
          copy_tensor(
              v,
              res[i][size - len(v) :] if left_pad else res[i][: len(v)],
          )
      return res
  
file_path: PaddleHub/modules/audio/svs/diffsinger/utils/__init__.py
imports: import sys
  import time
  import types
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: collate_1d(values, pad_idx, left_pad, shift_right, max_len, shift_id) and returns: res