original_docstring: 
      Create a right-padded matrix from an uneven list of lists.
  
      Returns (padded, lengths), where padded is the padded matrix, and lengths
      is a list containing the lengths of each row.
  
      Matrix is right-padded (filled to the right) by default, but can be
      left padded if the flag is set to True.
  
      Matrix can also be placed on cuda automatically.
  
      :param list[iter[int]] items: List of items
      :param bool sort: If True, orders by the length
      :param int pad_idx: the value to use for padding
      :param bool use_cuda: if true, places `padded` on GPU
      :param bool left_padded:
      :param int max_len: if None, the max length is the maximum item length
      :param bool fp16friendly: if True, pads the time dimension to be a multiple of 8.
  
      :returns: (padded, lengths) tuple
      :rtype: (Tensor[int64], list[int])
      
docstring: Create a right-padded matrix from an uneven list of lists.
  Returns (padded, lengths), where padded is the padded matrix, and lengths
  is a list containing the lengths of each row.
  
  Matrix is right-padded (filled to the right) by default, but can be
  left padded if the flag is set to True.
  
  Matrix can also be placed on cuda automatically.
docstring_tokens: Create a right - padded matrix from an uneven list of lists . Returns ( padded lengths ) where padded is the padded matrix and lengths is a list containing the lengths of each row . Matrix is right - padded ( filled to the right ) by default but can be left padded if the flag is set to True . Matrix can also be placed on cuda automatically .
code: def padded_tensor(
      items: List[Union[List[int], torch.LongTensor]],
      pad_idx: int = 0,
      use_cuda: bool = False,
      left_padded: bool = False,
      max_len: Optional[int] = None,
      fp16friendly: bool = False,
  ) -> Tuple[torch.LongTensor, List[int]]:
      """
      Create a right-padded matrix from an uneven list of lists.
  
      Returns (padded, lengths), where padded is the padded matrix, and lengths
      is a list containing the lengths of each row.
  
      Matrix is right-padded (filled to the right) by default, but can be
      left padded if the flag is set to True.
  
      Matrix can also be placed on cuda automatically.
  
      :param list[iter[int]] items: List of items
      :param bool sort: If True, orders by the length
      :param int pad_idx: the value to use for padding
      :param bool use_cuda: if true, places `padded` on GPU
      :param bool left_padded:
      :param int max_len: if None, the max length is the maximum item length
      :param bool fp16friendly: if True, pads the time dimension to be a multiple of 8.
  
      :returns: (padded, lengths) tuple
      :rtype: (Tensor[int64], list[int])
      """
  
      # number of items
      n = len(items)
      # length of each item
      lens: List[int] = [len(item) for item in items]  # type: ignore
      # max in time dimension
      t = max(lens) if max_len is None else max_len
  
      # if input tensors are empty, we should expand to nulls
      t = max(t, 1)
  
      if fp16friendly and (t % 8 != 0):
          # pad to be a multiple of 8 to ensure we use the tensor cores
          t += 8 - (t % 8)
  
      if isinstance(items[0], torch.Tensor):
          # keep type of input tensors, they may already be cuda ones
          output = items[0].new(n, t)  # type: ignore
      else:
          output = torch.LongTensor(n, t)  # type: ignore
      output.fill_(pad_idx)
  
      for i, (item, length) in enumerate(zip(items, lens)):
          if length == 0:
              # skip empty items
              continue
          if not isinstance(item, torch.Tensor):
              # put non-tensors into a tensor
              item = torch.LongTensor(item)  # type: ignore
          if left_padded:
              # place at end
              output[i, t - length :] = item
          else:
              # place at beginning
              output[i, :length] = item
  
      if use_cuda:
          output = output.cuda()
      return output, lens
code_tokens: def padded_tensor ( items : List [ Union [ List [ int ] , torch . LongTensor ] ] , pad_idx : int = 0 , use_cuda : bool = False , left_padded : bool = False , max_len : Optional [ int ] = None , fp16friendly : bool = False , ) -> Tuple [ torch . LongTensor , List [ int ] ] : n = len ( items ) lens : List [ int ] = [ len ( item ) for item in items ] t = max ( lens ) if max_len is None else max_len t = max ( t , 1 ) if fp16friendly and ( t % 8 != 0 ) : t += 8 - ( t % 8 ) if isinstance ( items [ 0 ] , torch . Tensor ) : output = items [ 0 ] . new ( n , t ) else : output = torch . LongTensor ( n , t ) output . fill_ ( pad_idx ) for i , ( item , length ) in enumerate ( zip ( items , lens ) ) : if length == 0 : continue if not isinstance ( item , torch . Tensor ) : item = torch . LongTensor ( item ) if left_padded : output [ i , t - length : ] = item else : output [ i , : length ] = item if use_cuda : output = output . cuda ( ) return output , lens
short_docstring: Create a right-padded matrix from an uneven list of lists.
short_docstring_tokens: Create a right - padded matrix from an uneven list of lists .
comment: """
      Create a right-padded matrix from an uneven list of lists.
  
      Returns (padded, lengths), where padded is the padded matrix, and lengths
      is a list containing the lengths of each row.
  
      Matrix is right-padded (filled to the right) by default, but can be
      left padded if the flag is set to True.
  
      Matrix can also be placed on cuda automatically.
  
      :param list[iter[int]] items: List of items
      :param bool sort: If True, orders by the length
      :param int pad_idx: the value to use for padding
      :param bool use_cuda: if true, places `padded` on GPU
      :param bool left_padded:
      :param int max_len: if None, the max length is the maximum item length
      :param bool fp16friendly: if True, pads the time dimension to be a multiple of 8.
  
      :returns: (padded, lengths) tuple
      :rtype: (Tensor[int64], list[int])
      """$SEP$# number of items$SEP$# length of each item$SEP$# type: ignore$SEP$# max in time dimension$SEP$# if input tensors are empty, we should expand to nulls$SEP$# pad to be a multiple of 8 to ensure we use the tensor cores$SEP$# keep type of input tensors, they may already be cuda ones$SEP$# type: ignore$SEP$# type: ignore$SEP$# skip empty items$SEP$# put non-tensors into a tensor$SEP$# type: ignore$SEP$# place at end$SEP$# place at beginning