class_docstr: This sampler takes in a dictionary of iterators and returns batches according
  to the specified probabilities by `unnormalized_iterator_probs`. We cycle through
  the iterators (restarting any that "run out") indefinitely. Set batches_per_epoch
  in Trainer.Config.
  
  Example:
  
      Iterator A: [A, B, C, D],  Iterator B: [a, b]
  
      batches_per_epoch = 3, unnormalized_iterator_probs = {"A": 0, "B": 1}
      Epoch 1 = [a, b, a]
      Epoch 2 = [b, a, b]
  
  Args:
      unnormalized_iterator_probs (Dict[str, float]): Iterator sampling probabilities.
          The keys should be the same as the keys of the underlying iterators, and the
          values will be normalized to sum to 1.
class_docstr_tok: ["This","sampler","takes","in","a","dictionary","of","iterators","and","returns","batches","according","to","the","specified","probabilities","by","`","unnormalized_iterator_probs","`",".","We","cycle","through","the","iterators","(","restarting","any","that","``","run","out","''",")","indefinitely",".","Set","batches_per_epoch","in","Trainer.Config",".","Example",":","Iterator","A",":","[","A",",","B",",","C",",","D","]",",","Iterator","B",":","[","a",",","b","]","batches_per_epoch","=","3",",","unnormalized_iterator_probs","=","{","``","A","''",":","0",",","``","B","''",":","1","}","Epoch","1","=","[","a",",","b",",","a","]","Epoch","2","=","[","b",",","a",",","b","]","Args",":","unnormalized_iterator_probs","(","Dict","[","str",",","float","]",")",":","Iterator","sampling","probabilities",".","The","keys","should","be","the","same","as","the","keys","of","the","underlying","iterators",",","and","the","values","will","be","normalized","to","sum","to","1","."]
code: def batchify(self, iterators: Dict[str, Iterator]):
      assert set(iterators) == set(self.iterator_names)
      if self.iter_dict is None:
          self.iter_dict = {
              name: iter(iterator)
              for name, iterator in iterators.items()
          }
      num_batches = 0
  
      while True:
          selected_key, batch = select_key_and_batch(
              self.iterator_names,
              self.iterator_probs,
              self.iter_dict,
              iterators,
          )
          num_batches += 1
          yield selected_key, batch
  
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 3 for calling the RandomizedBatchSampler obj's underlying member method code with example usage: obj.batchify(iterators) without return types