class_docstr: More fine-grained state DataSampler that uses training iteration and epoch
  both for shuffling data. PyTorch DistributedSampler only uses epoch
  for the shuffling and starts sampling data from the start. In case of training
  on very large data, we train for one epoch only and when we resume training,
  we want to resume the data sampler from the training iteration.
class_docstr_tok: ["More","fine-grained","state","DataSampler","that","uses","training","iteration","and","epoch","both","for","shuffling","data",".","PyTorch","DistributedSampler","only","uses","epoch","for","the","shuffling","and","starts","sampling","data","from","the","start",".","In","case","of","training","on","very","large","data",",","we","train","for","one","epoch","only","and","when","we","resume","training",",","we","want","to","resume","the","data","sampler","from","the","training","iteration","."]
docstr: Initializes the instance of StatefulDistributedSampler. Random seed is set
  for the epoch set and data is shuffled. For starting the sampling, use
  the start_iter (set to 0 or set by checkpointing resuming) to
  sample data from the remaining images.
  
  Args:
      dataset (Dataset): Pytorch dataset that sampler will shuffle
      batch_size (int): batch size we want the sampler to sample
      seed (int): Seed for the torch generator.
docstr_tok: ["Initializes","the","instance","of","StatefulDistributedSampler",".","Random","seed","is","set","for","the","epoch","set","and","data","is","shuffled",".","For","starting","the","sampling",",","use","the","start_iter","(","set","to","0","or","set","by","checkpointing","resuming",")","to","sample","data","from","the","remaining","images",".","Args",":","dataset","(","Dataset",")",":","Pytorch","dataset","that","sampler","will","shuffle","batch_size","(","int",")",":","batch","size","we","want","the","sampler","to","sample","seed","(","int",")",":","Seed","for","the","torch","generator","."]
code: def __init__(self, dataset, batch_size=None, seed: int = 0):
      """
      Initializes the instance of StatefulDistributedSampler. Random seed is set
      for the epoch set and data is shuffled. For starting the sampling, use
      the start_iter (set to 0 or set by checkpointing resuming) to
      sample data from the remaining images.
  
      Args:
          dataset (Dataset): Pytorch dataset that sampler will shuffle
          batch_size (int): batch size we want the sampler to sample
          seed (int): Seed for the torch generator.
      """
      super().__init__(dataset, shuffle=False, seed=seed)
  
      self.start_iter = 0
      self.batch_size = batch_size
      self.total_size = len(dataset) - (
          len(dataset) % self.num_replicas
      )
      self.num_samples = self.total_size // self.num_replicas
      logging.info(f"rank: {self.rank}: Sampler created...")
  
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 1 to create a new StatefulDistributedSampler object from inherited base classes: DistributedSampler with example: obj = StatefulDistributedSampler(dataset, batch_size, seed)