class_docstr: Sampler that repeats the same data elements for num_repeats times. The
  batch size should be divisible by num_repeats.
  
  It ensures that different each
  augmented version of a sample will be visible to a different process (GPU).
  Heavily based on torch.utils.data.DistributedSampler.
  
  This sampler was modified from
  https://github.com/facebookresearch/deit/blob/0c4b8f60/samplers.py
  Used in
  Copyright (c) 2015-present, Facebook, Inc.
  
  Args:
      dataset (Sized): The dataset.
      shuffle (bool): Whether shuffle the dataset or not. Defaults to True.
      num_repeats (int): The repeat times of every sample. Defaults to 3.
      seed (int, optional): Random seed used to shuffle the sampler if
          :attr:`shuffle=True`. This number should be identical across all
          processes in the distributed group. Defaults to None.
class_docstr_tok: ["Sampler","that","repeats","the","same","data","elements","for","num_repeats","times",".","The","batch","size","should","be","divisible","by","num_repeats",".","It","ensures","that","different","each","augmented","version","of","a","sample","will","be","visible","to","a","different","process","(","GPU",")",".","Heavily","based","on","torch.utils.data.DistributedSampler",".","This","sampler","was","modified","from","https",":","\/\/github.com\/facebookresearch\/deit\/blob\/0c4b8f60\/samplers.py","Used","in","Copyright","(","c",")","2015-present",",","Facebook",",","Inc.","Args",":","dataset","(","Sized",")",":","The","dataset",".","shuffle","(","bool",")",":","Whether","shuffle","the","dataset","or","not",".","Defaults","to","True",".","num_repeats","(","int",")",":","The","repeat","times","of","every","sample",".","Defaults","to","3.","seed","(","int",",","optional",")",":","Random","seed","used","to","shuffle","the","sampler","if",":","attr",":","`","shuffle=True","`",".","This","number","should","be","identical","across","all","processes","in","the","distributed","group",".","Defaults","to","None","."]
docstr: Iterate the indices.
docstr_tok: ["Iterate","the","indices","."]
code: def __iter__(self) -> Iterator[int]:
      """Iterate the indices."""
      # deterministically shuffle based on epoch and seed
      if self.shuffle:
          g = torch.Generator()
          g.manual_seed(self.seed + self.epoch)
          indices = torch.randperm(
              len(self.dataset), generator=g
          ).tolist()
      else:
          indices = list(range(len(self.dataset)))
  
      # produce repeats e.g. [0, 0, 0, 1, 1, 1, 2, 2, 2....]
      indices = [x for x in indices for _ in range(self.num_repeats)]
      # add extra samples to make it evenly divisible
      indices = (indices * int(self.total_size / len(indices) + 1))[
          : self.total_size
      ]
      assert len(indices) == self.total_size
  
      # subsample per rank
      indices = indices[self.rank : self.total_size : self.world_size]
      assert len(indices) == self.num_samples
  
      # return up to num selected samples
      return iter(indices)
  
file_path: mmocr/mmocr/datasets/samplers/batch_aug.py
imports: import math
  from typing import Iterator, Optional, Sized
  import torch
  from mmengine.dist import get_dist_info, sync_random_seed
  from torch.utils.data import Sampler
  from mmocr.registry import DATA_SAMPLERS
label_desc: Use image node_id 2 for calling the BatchAugSampler obj's underlying member method code with example usage: obj.__iter__() and returns: iter