class_docstr: This sampler iterates over all the datasets, sampling according to
  the weighted number of samples in each dataset.
class_docstr_tok: ["This","sampler","iterates","over","all","the","datasets",",","sampling","according","to","the","weighted","number","of","samples","in","each","dataset","."]
code: def __init__(self, dataset_counts: Dict[str, int]) -> None:
      self.dataset_counts = dataset_counts
      # Note: we need to make `iter_dict` an instance attribute so that it persists
      # across calls to `batchify()`. This way subsequent epochs will continue from
      # previous states of the iterators (instead of recreating them).
      self.iter_dict = None
      self.iterator_names, self.iterator_probs = None, None
  
imports: from collections.abc import Iterator
  from typing import Dict, Optional
  import numpy
  from pytext.config.component import Component, ComponentType
label_desc: Use image node_id 2 to create a new NaturalBatchSampler object from inherited base classes: RandomizedBatchSampler with example: obj = NaturalBatchSampler(dataset_counts)