class_docstr: In training, we only care about the "infinite stream" of training data.
  So this sampler produces an infinite stream of indices and
  all workers cooperate to correctly shuffle the indices and sample different indices.
  
  The samplers in each worker effectively produces `indices[worker_id::num_workers]`
  where `indices` is an infinite stream of indices consisting of
  `shuffle(range(size)) + shuffle(range(size)) + ...` (if shuffle is True)
  or `range(size) + range(size) + ...` (if shuffle is False)
class_docstr_tok: ["In","training",",","we","only","care","about","the","``","infinite","stream","''","of","training","data",".","So","this","sampler","produces","an","infinite","stream","of","indices","and","all","workers","cooperate","to","correctly","shuffle","the","indices","and","sample","different","indices",".","The","samplers","in","each","worker","effectively","produces","`","indices","[","worker_id",":",":num_workers","]","`","where","`","indices","`","is","an","infinite","stream","of","indices","consisting","of","`","shuffle","(","range","(","size",")",")","+","shuffle","(","range","(","size",")",")","+","...","`","(","if","shuffle","is","True",")","or","`","range","(","size",")","+","range","(","size",")","+","...","`","(","if","shuffle","is","False",")"]
code: def _infinite_indices(self):
      g = torch.Generator()
      g.manual_seed(self._seed)
      while True:
          if self._shuffle:
              yield from torch.randperm(self._size, generator=g)
          else:
              yield from torch.arange(self._size)
  
imports: import itertools
  import math
  from collections import defaultdict
  from typing import Optional
  import torch
  from torch.utils.data.sampler import Sampler
  from ....utils import comm
label_desc: Use image node_id 3 for calling the TrainingSampler obj's underlying member method code with example usage: obj._infinite_indices() without return types