code: def __iter__(self):
      # deterministically shuffle based on epoch
      if self.shuffle:
          g = torch.Generator()
          # When :attr:`shuffle=True`, this ensures all replicas
          # use a different random ordering for each epoch.
          # Otherwise, the next iteration of this sampler will
          # yield the same ordering.
          g.manual_seed(self.epoch + self.seed)
          indices = torch.randperm(
              len(self.dataset), generator=g
          ).tolist()
      else:
          indices = torch.arange(len(self.dataset)).tolist()
  
      # add extra samples to make it evenly divisible
      # in case that indices is shorter than half of total_size
      indices = (indices * math.ceil(self.total_size / len(indices)))[
          : self.total_size
      ]
      assert len(indices) == self.total_size
  
      # subsample
      indices = indices[self.rank : self.total_size : self.num_replicas]
      assert len(indices) == self.num_samples
  
      return iter(indices)
  
file_path: insightface/recognition/arcface_torch/utils/utils_distributed_sampler.py
imports: import math
  import os
  import random
  import numpy
  import torch
  import torch.distributed
  from torch.utils.data import DistributedSampler
label_desc: Use image node_id 2 for calling the DistributedSampler obj's underlying member method code with example usage: obj.__iter__() and returns: iter