class_docstr: Base class for all Samplers.
  
  Every Sampler subclass has to provide an :meth:`__iter__` method, providing a
  way to iterate over indices or lists of indices (batches) of dataset elements, and a :meth:`__len__` method
  that returns the length of the returned iterators.
  
  Args:
      data_source (Dataset): This argument is not used and will be removed in 2.2.0.
          You may still have custom implementation that utilizes it.
  
  Example:
      >>> # xdoctest: +SKIP
      >>> class AccedingSequenceLengthSampler(Sampler[int]):
      >>>     def __init__(self, data: List[str]) -> None:
      >>>         self.data = data
      >>>
      >>>     def __len__(self) -> int:
      >>>         return len(self.data)
      >>>
      >>>     def __iter__(self) -> Iterator[int]:
      >>>         sizes = torch.tensor([len(x) for x in self.data])
      >>>         yield from torch.argsort(sizes).tolist()
      >>>
      >>> class AccedingSequenceLengthBatchSampler(Sampler[List[int]]):
      >>>     def __init__(self, data: List[str], batch_size: int) -> None:
      >>>         self.data = data
      >>>         self.batch_size = batch_size
      >>>
      >>>     def __len__(self) -> int:
      >>>         return (len(self.data) + self.batch_size - 1) // self.batch_size
      >>>
      >>>     def __iter__(self) -> Iterator[List[int]]:
      >>>         sizes = torch.tensor([len(x) for x in self.data])
      >>>         for batch in torch.chunk(torch.argsort(sizes), len(self)):
      >>>             yield batch.tolist()
  
  .. note:: The :meth:`__len__` method isn't strictly required by
            :class:`~torch.utils.data.DataLoader`, but is expected in any
            calculation involving the length of a :class:`~torch.utils.data.DataLoader`.
class_docstr_tok: ["Base","class","for","all","Samplers",".","Every","Sampler","subclass","has","to","provide","an",":","meth",":","`","__iter__","`","method",",","providing","a","way","to","iterate","over","indices","or","lists","of","indices","(","batches",")","of","dataset","elements",",","and","a",":","meth",":","`","__len__","`","method","that","returns","the","length","of","the","returned","iterators",".","Args",":","data_source","(","Dataset",")",":","This","argument","is","not","used","and","will","be","removed","in","2.2.0",".","You","may","still","have","custom","implementation","that","utilizes","it",".","Example",":",">",">",">","#","xdoctest",":","+SKIP",">",">",">","class","AccedingSequenceLengthSampler","(","Sampler","[","int","]",")",":",">",">",">","def","__init__","(","self",",","data",":","List","[","str","]",")","-",">","None",":",">",">",">","self.data","=","data",">",">",">",">",">",">","def","__len__","(","self",")","-",">","int",":",">",">",">","return","len","(","self.data",")",">",">",">",">",">",">","def","__iter__","(","self",")","-",">","Iterator","[","int","]",":",">",">",">","sizes","=","torch.tensor","(","[","len","(","x",")","for","x","in","self.data","]",")",">",">",">","yield","from","torch.argsort","(","sizes",")",".tolist","(",")",">",">",">",">",">",">","class","AccedingSequenceLengthBatchSampler","(","Sampler","[","List","[","int","]","]",")",":",">",">",">","def","__init__","(","self",",","data",":","List","[","str","]",",","batch_size",":","int",")","-",">","None",":",">",">",">","self.data","=","data",">",">",">","self.batch_size","=","batch_size",">",">",">",">",">",">","def","__len__","(","self",")","-",">","int",":",">",">",">","return","(","len","(","self.data",")","+","self.batch_size","-","1",")","\/\/","self.batch_size",">",">",">",">",">",">","def","__iter__","(","self",")","-",">","Iterator","[","List","[","int","]","]",":",">",">",">","sizes","=","torch.tensor","(","[","len","(","x",")","for","x","in","self.data","]",")",">",">",">","for","batch","in","torch.chunk","(","torch.argsort","(","sizes",")",",","len","(","self",")",")",":",">",">",">","yield","batch.tolist","(",")","..","note",":",":","The",":","meth",":","`","__len__","`","method","is","n't","strictly","required","by",":","class",":","`","~torch.utils.data.DataLoader","`",",","but","is","expected","in","any","calculation","involving","the","length","of","a",":","class",":","`","~torch.utils.data.DataLoader","`","."]
code: def __iter__(self) -> Iterator[T_co]:
      raise NotImplementedError
  
imports: import torch
  from torch import Tensor
  from typing import Iterator, Iterable, Optional, Sequence, List, TypeVar, Generic, Sized, Union
label_desc: Use image node_id 2 for calling the Sampler obj's underlying member method code with example usage: obj.__iter__() without return types