class_docstr: Distributed sampler proxy to adapt user's sampler for distributed data parallelism configuration.
  
  Code is based on https://github.com/pytorch/pytorch/issues/23430#issuecomment-562350407
  
  Args:
      sampler: Input torch data sampler.
      num_replicas: Number of processes participating in distributed training.
      rank: Rank of the current process within ``num_replicas``.
  
  .. note::
      Input sampler is assumed to have a constant size.
class_docstr_tok: ["Distributed","sampler","proxy","to","adapt","user","'s","sampler","for","distributed","data","parallelism","configuration",".","Code","is","based","on","https",":","\/\/github.com\/pytorch\/pytorch\/issues\/23430","#","issuecomment-562350407","Args",":","sampler",":","Input","torch","data","sampler",".","num_replicas",":","Number","of","processes","participating","in","distributed","training",".","rank",":","Rank","of","the","current","process","within","``","num_replicas","``",".","..","note",":",":","Input","sampler","is","assumed","to","have","a","constant","size","."]
code: def __iter__(self) -> Iterator:
      # deterministically shuffle based on epoch
      torch.manual_seed(self.epoch)
  
      indices: List = []
      while len(indices) < self.total_size:
          indices += list(self.sampler)
  
      if len(indices) > self.total_size:
          indices = indices[: self.total_size]
  
      # subsample
      indices = indices[self.rank : self.total_size : self.num_replicas]
      if len(indices) != self.num_samples:
          raise RuntimeError(f"{len(indices)} vs {self.num_samples}")
  
      return iter(indices)
  
file_path: ignite/ignite/distributed/auto.py
imports: import warnings
  from typing import Any, Iterator, List, Optional, Union
  import torch
  import torch.nn
  from torch.optim.optimizer import Optimizer
  from torch.utils.data import DataLoader, Dataset, IterableDataset
  from torch.utils.data.distributed import DistributedSampler
  from torch.utils.data.sampler import Sampler
  from ignite.distributed import utils
  from ignite.distributed.comp_models import horovod, native, xla
  from ignite.utils import setup_logger
label_desc: Use image node_id 2 for calling the DistributedProxySampler obj's underlying member method code with example usage: obj.__iter__() and returns: iter