class_docstr: StatefulDistributedSampler that does not generates random permutations but
  instead uses a fixed assignment of samples for each rank.
  
  Useful for debugging: it gives 100% reproducible sample assignments.
  
  Args:
      dataset (Dataset): Pytorch dataset from which to sample elements
      batch_size (int): batch size we want the sampler to sample
class_docstr_tok: ["StatefulDistributedSampler","that","does","not","generates","random","permutations","but","instead","uses","a","fixed","assignment","of","samples","for","each","rank",".","Useful","for","debugging",":","it","gives","100","%","reproducible","sample","assignments",".","Args",":","dataset","(","Dataset",")",":","Pytorch","dataset","from","which","to","sample","elements","batch_size","(","int",")",":","batch","size","we","want","the","sampler","to","sample"]
code: def __iter__(self):
      # Cut the dataset in deterministic parts
      indices = list(
          range(
              (self.rank * self.num_samples),
              (self.rank + 1) * self.num_samples,
          )
      )
  
      # make sure we have correct number of samples per replica
      assert len(indices) == self.num_samples
      assert self.batch_size > 0, "batch_size not set for the sampler"
  
      # resume the sampler
      start_index = self.start_iter * self.batch_size
      indices = indices[start_index:]
      return iter(indices)
  
imports: import contextlib
  import logging
  import queue
  from typing import Dict, List
  import numpy
  import torch
  from PIL import Image
  from torch.utils.data import Dataset
  from torch.utils.data.distributed import DistributedSampler
label_desc: Use image node_id 2 for calling the DeterministicDistributedSampler obj's underlying member method code with example usage: obj.__iter__() and returns: iter