class_docstr: This sampler takes a dictionary of Iterators and returns batches in a round
  robin fashion till a the end of one of the iterators is reached. The end
  is specified by `iter_to_set_epoch`.
  
  If `iter_to_set_epoch` is set, cycle batches from each iterator until one
  epoch of the target iterator is fulfilled. Iterators with fewer batches
  than the target iterator are repeated, so they never run out.
  
  If `iter_to_set_epoch` is None, cycle over batches from each iterator until the
  shortest iterator completes one epoch.
  
  Example:
  
      Iterator 1: [A, B, C, D],  Iterator 2: [a, b]
  
      iter_to_set_epoch = "Iterator 1"
      Output: [A, a, B, b, C, a, D, b]
  
      iter_to_set_epoch = None
      Output: [A, a, B, b]
  
  Args:
      iter_to_set_epoch (Optional[str]): Name of iterator to define epoch size.
          If this is not set, epoch size defaults to the length of
          the shortest iterator.
class_docstr_tok: ["This","sampler","takes","a","dictionary","of","Iterators","and","returns","batches","in","a","round","robin","fashion","till","a","the","end","of","one","of","the","iterators","is","reached",".","The","end","is","specified","by","`","iter_to_set_epoch","`",".","If","`","iter_to_set_epoch","`","is","set",",","cycle","batches","from","each","iterator","until","one","epoch","of","the","target","iterator","is","fulfilled",".","Iterators","with","fewer","batches","than","the","target","iterator","are","repeated",",","so","they","never","run","out",".","If","`","iter_to_set_epoch","`","is","None",",","cycle","over","batches","from","each","iterator","until","the","shortest","iterator","completes","one","epoch",".","Example",":","Iterator","1",":","[","A",",","B",",","C",",","D","]",",","Iterator","2",":","[","a",",","b","]","iter_to_set_epoch","=","``","Iterator","1","''","Output",":","[","A",",","a",",","B",",","b",",","C",",","a",",","D",",","b","]","iter_to_set_epoch","=","None","Output",":","[","A",",","a",",","B",",","b","]","Args",":","iter_to_set_epoch","(","Optional","[","str","]",")",":","Name","of","iterator","to","define","epoch","size",".","If","this","is","not","set",",","epoch","size","defaults","to","the","length","of","the","shortest","iterator","."]
docstr: Loop through each key in the input dict and generate batches from
  the iterator associated with that key until the target iterator reaches
  its end.
  
  Args:
      iterators: Dictionary of iterators
docstr_tok: ["Loop","through","each","key","in","the","input","dict","and","generate","batches","from","the","iterator","associated","with","that","key","until","the","target","iterator","reaches","its","end",".","Args",":","iterators",":","Dictionary","of","iterators"]
code: def batchify(self, iterators: Dict[str, Iterator]):
      """
      Loop through each key in the input dict and generate batches from
      the iterator associated with that key until the target iterator reaches
      its end.
  
      Args:
          iterators: Dictionary of iterators
      """
      iter_dict = {
          name: iter(iterator) for name, iterator in iterators.items()
      }
      while True:
          for name, it in iter_dict.items():
              try:
                  yield name, next(it)
              except StopIteration:
                  new_iter = iter(iterators[name])
                  iter_dict[name] = new_iter
                  if (
                      not self.iter_to_set_epoch
                  ) or name == self.iter_to_set_epoch:
                      self.iter_to_set_epoch = name
                      # end of epoch
                      return
                  else:
                      yield name, next(new_iter)
  
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 RoundRobinBatchSampler obj's underlying member method code with example usage: obj.batchify(iterators) without return types