class_docstr: Base class for standard and DataParallel 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 mode or not. Default: False
class_docstr_tok: ["Base","class","for","standard","and","DataParallel","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","mode","or","not",".","Default",":","False"]
code: def add_arguments(
      cls, parser: argparse.ArgumentParser
  ) -> argparse.ArgumentParser:
      if cls != BaseSampler:
          # Don't re-register arguments in subclasses that don't override `add_arguments()`.
          return parser
  
      # add sampler-specific arguments
      group = parser.add_argument_group(cls.__name__)
      group.add_argument(
          "--sampler.name",
          type=str,
          default="batch_sampler",
          help="Name of the sampler. Defaults to batch sampler.",
      )
      group.add_argument(
          "--sampler.num-repeats",
          type=int,
          default=1,
          help="Repeat the training dataset samples by this factor in each epoch (aka repeated augmentation). "
          "This effectively increases samples per epoch. As an example, if dataset has 10000 samples "
          "and sampler.num_repeats is set to 2, then total samples in each epoch would be 20000. "
          "Defaults to 1.",
      )
  
      group.add_argument(
          "--sampler.truncated-repeat-aug-sampler",
          action="store_true",
          default=False,
          help="When enabled, it restricts the sampler to load a subset of the training dataset such that"
          "number of samples obtained after repetition are the same as the original dataset."
          "As an example, if dataset has 10000 samples, sampler.num_repeats is set to 2, and "
          "sampler.truncated_repeat_aug_sampler is enabled, then the sampler would sample "
          "10000 samples in each epoch. 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 2 for calling the BaseSampler obj's underlying member method code with example usage: obj.add_arguments(cls, parser) and returns: parser, parser