class_docstr: This sampler takes in a dictionary of iterators and returns batches alternating
  between keys and probabilities specified by `unnormalized_iterator_probs` and
  'second_unnormalized_iterator_probs', This is used for example in XLM
  pre-training where we alternate between MLM and TLM batches.
class_docstr_tok: ["This","sampler","takes","in","a","dictionary","of","iterators","and","returns","batches","alternating","between","keys","and","probabilities","specified","by","`","unnormalized_iterator_probs","`","and","'second_unnormalized_iterator_probs","'",",","This","is","used","for","example","in","XLM","pre-training","where","we","alternate","between","MLM","and","TLM","batches","."]
code: def batchify(self, iterators: Dict[str, Iterator]):
      assert set(iterators) == set(self.iterator_names).union(
          set(self.second_iterator_names)
      )
  
      if self.iter_dict is None:
          self.iter_dict = {
              name: iter(iterator)
              for name, iterator in iterators.items()
          }
  
      while True:
          curr_iter = (
              self.second_iterator_names
              if self.is_secondary_turn
              else self.iterator_names
          )
          curr_probs = (
              self.second_iterator_probs
              if self.is_secondary_turn
              else self.iterator_probs
          )
  
          selected_key, batch = select_key_and_batch(
              curr_iter, curr_probs, self.iter_dict, iterators
          )
  
          self.is_secondary_turn = not self.is_secondary_turn
  
          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 AlternatingRandomizedBatchSampler obj's underlying member method code with example usage: obj.batchify(iterators) without return types