class_docstr: A list of tensors of different sizes, backed by a (offset, size, data)
  tuple.
  
  Indexing by LongTensor returns a new TensorList with the selected list
  elements (similar to indexing a torch index_select_).
  
  Indexing by an int returns a torch.Tensor with that list element.
class_docstr_tok: ["A","list","of","tensors","of","different","sizes",",","backed","by","a","(","offset",",","size",",","data",")","tuple",".","Indexing","by","LongTensor","returns","a","new","TensorList","with","the","selected","list","elements","(","similar","to","indexing","a","torch","index_select_",")",".","Indexing","by","an","int","returns","a","torch.Tensor","with","that","list","element","."]
code: def __getitem__(self, index):
      if isinstance(index, (torch.LongTensor, torch.cuda.LongTensor)):
          offsets_sub = self.offsets[index]
          sizes_sub = self.offsets[index + 1] - offsets_sub
          new_offsets, new_data = _extract_intervals(
              offsets_sub, sizes_sub, self.data
          )
  
          return TensorList(new_offsets, new_data)
      elif isinstance(index, int):
          if self.offsets[index] != self.offsets[index + 1]:
              return self.data[
                  self.offsets[index] : self.offsets[index + 1]
              ]
          else:
              return self.data.new()
      elif isinstance(index, slice):
          start, stop, step = index.indices(len(self))
          if step != 1:
              raise ValueError(
                  "Expected slice with step 1, got %d" % step
              )
          new_offsets = self.offsets[start : stop + 1]
          new_data = self.data[new_offsets[0] : new_offsets[-1]]
          new_offsets = new_offsets - new_offsets[0]
          return TensorList(new_offsets, new_data)
      else:
          raise KeyError("Unknown index type: %s" % type(index))
  
imports: import torch
label_desc: Use image node_id 5 for calling the TensorList obj's underlying member method code with example usage: obj.__getitem__(index) and returns: TensorList, self, self, TensorList