class_docstr: Base class for DistributedDataParallel Sampler.
  
  Every subclass should implement `__iter__` method, providing a way to iterate
  over indices of dataset elements.
  
  Args:
      opts: command line argument
      n_data_samples: Number of samples in the dataset
      is_training: Training or validation mode. Default: False
class_docstr_tok: ["Base","class","for","DistributedDataParallel","Sampler",".","Every","subclass","should","implement","`","__iter__","`","method",",","providing","a","way","to","iterate","over","indices","of","dataset","elements",".","Args",":","opts",":","command","line","argument","n_data_samples",":","Number","of","samples","in","the","dataset","is_training",":","Training","or","validation","mode",".","Default",":","False"]
code: def add_arguments(
      cls, parser: argparse.ArgumentParser
  ) -> argparse.ArgumentParser:
      if cls != BaseSamplerDDP:
          # Don't re-register arguments in subclasses that don't override `add_arguments()`.
          return parser
  
      group = parser.add_argument_group(cls.__name__)
      group.add_argument(
          "--sampler.use-shards",
          action="store_true",
          default=False,
          help="Use data sharding. Only applicable to DDP. Defaults to False.",
      )
      group.add_argument(
          "--sampler.disable-shuffle-sharding",
          action="store_true",
          default=False,
          help="Disable shuffling while sharding for extremely large datasets. Defaults to False.",
      )
  
      return parser
  
imports: import argparse
  import copy
  import math
  import random
  from typing import Any, Iterator, List, Tuple
  import numpy
  import torch
  import torch.distributed
  from torch.utils.data.sampler import Sampler
label_desc: Use image node_id 5 for calling the BaseSamplerDDP obj's underlying member method code with example usage: obj.add_arguments(cls, parser) and returns: parser, parser