class_docstr: Sampler that partitions dataset across ranks and repartitions after reset events.
  
  Works similar to `DistributedSampler`, but with an optional capability to record
  which dataset indices have been processed each batch. When tracked by a `TorchState`
  object, the sampler will automatically repartition the unprocessed indices among the
  new set of workers.
  
  In order to use this object successfully it is recommended that the user:
  
  1. Include this object in the `TorchState`.
  2. Call `record_batch` after processing a set of samples.
  3. Call `set_epoch` at the end of each epoch to clear the processed indices.
  
  Args:
      dataset: Dataset used for sampling (assumed to be of constant size).
      shuffle: If `True` (default), shuffle the indices.
      seed: Random seed used to shuffle the sampler when `shuffle=True`.
            This number should be identical across all ranks (default: 0).
class_docstr_tok: ["Sampler","that","partitions","dataset","across","ranks","and","repartitions","after","reset","events",".","Works","similar","to","`","DistributedSampler","`",",","but","with","an","optional","capability","to","record","which","dataset","indices","have","been","processed","each","batch",".","When","tracked","by","a","`","TorchState","`","object",",","the","sampler","will","automatically","repartition","the","unprocessed","indices","among","the","new","set","of","workers",".","In","order","to","use","this","object","successfully","it","is","recommended","that","the","user",":","1",".","Include","this","object","in","the","`","TorchState","`",".","2",".","Call","`","record_batch","`","after","processing","a","set","of","samples",".","3",".","Call","`","set_epoch","`","at","the","end","of","each","epoch","to","clear","the","processed","indices",".","Args",":","dataset",":","Dataset","used","for","sampling","(","assumed","to","be","of","constant","size",")",".","shuffle",":","If","`","True","`","(","default",")",",","shuffle","the","indices",".","seed",":","Random","seed","used","to","shuffle","the","sampler","when","`","shuffle=True","`",".","This","number","should","be","identical","across","all","ranks","(","default",":","0",")","."]
code: def load_state_dict(self, state_dict):
      self.epoch = state_dict["epoch"]
      self.processed_num = state_dict["processed_num"]
      self.reset()
  
file_path: horovod/horovod/torch/elastic/sampler.py
imports: import math
  import random
  import torch.utils.data.distributed
  from horovod.torch.mpi_ops import rank, size
label_desc: Use image node_id 4 for calling the ElasticSampler obj's underlying member method code with example usage: obj.load_state_dict(state_dict) without return types