class_docstr: Extension of DistributedSampler, as discussed in
  https://github.com/pytorch/pytorch/issues/23430
  
  Example:
      dataset: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
      num_replicas: 4
      shuffle: False
  
  when group_size = 1
          RANK    |  shard_dataset
          =========================
          rank_0  |  [0, 4, 8, 12]
          rank_1  |  [1, 5, 9, 13]
          rank_2  |  [2, 6, 10, 0]
          rank_3  |  [3, 7, 11, 1]
  
  when group_size = 2
  
          RANK    |  shard_dataset
          =========================
          rank_0  |  [0, 1, 8, 9]
          rank_1  |  [2, 3, 10, 11]
          rank_2  |  [4, 5, 12, 13]
          rank_3  |  [6, 7, 0, 1]
code: def __iter__(self) -> Iterator[int]:
      # deterministically shuffle based on epoch
      g = torch.Generator()
      g.manual_seed(self.epoch)
      indices: Union[torch.Tensor, List[int]]
      if self.shuffle:
          indices = torch.randperm(
              len(self.dataset), generator=g
          ).tolist()
      else:
          indices = list(range(len(self.dataset)))
  
      # add extra samples to make it evenly divisible
      indices += indices[: (self.total_size - len(indices))]
      assert len(indices) == self.total_size
  
      total_group_size = self.total_size // self.group_size
      indices = torch.reshape(
          torch.LongTensor(indices), (total_group_size, self.group_size)
      )
  
      # subsample
      indices = indices[
          self.rank : total_group_size : self.num_replicas, :
      ]
      indices = torch.reshape(indices, (-1,)).tolist()
      assert len(indices) == self.num_samples
  
      if isinstance(self.dataset, Sampler):
          orig_indices = list(iter(self.dataset))
          indices = [orig_indices[i] for i in indices]
  
      return iter(indices)
  
imports: import math
  from typing import cast, Iterator, List, Optional, Sized, Union
  import torch
  import torch.distributed
  from torch.utils.data import Sampler
  from torchvision.datasets.video_utils import VideoClips
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