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 __init__(
      self,
      dataset: Sized,
      num_replicas: Optional[int] = None,
      rank: Optional[int] = None,
      shuffle: bool = False,
      group_size: int = 1,
  ) -> None:
      if num_replicas is None:
          if not dist.is_available():
              raise RuntimeError(
                  "Requires distributed package to be available"
              )
          num_replicas = dist.get_world_size()
      if rank is None:
          if not dist.is_available():
              raise RuntimeError(
                  "Requires distributed package to be available"
              )
          rank = dist.get_rank()
      if len(dataset) % group_size != 0:
          raise ValueError(
              f"dataset length must be a multiplier of group size dataset length: {len(dataset)}, group size: {group_size}"
          )
      self.dataset = dataset
      self.group_size = group_size
      self.num_replicas = num_replicas
      self.rank = rank
      self.epoch = 0
      dataset_group_length = len(dataset) // group_size
      self.num_group_samples = int(
          math.ceil(dataset_group_length * 1.0 / self.num_replicas)
      )
      self.num_samples = self.num_group_samples * group_size
      self.total_size = self.num_samples * self.num_replicas
      self.shuffle = shuffle
  
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 1 to create a new DistributedSampler object from inherited base classes: Sampler with example: obj = DistributedSampler(dataset, num_replicas, rank, shuffle, group_size)