class_docstr: A `DatasetReader` that wraps multiple other dataset readers,
  and interleaves their instances, adding a `MetadataField` to
  indicate the provenance of each instance.
  
  Unlike most of our other dataset readers, here the `file_path` passed into
  `read()` should be a JSON-serialized dictionary with one file_path
  per wrapped dataset reader (and with corresponding keys).
  
  Registered as a `DatasetReader` with name "interleaving".
  
  # Parameters
  
  readers : `Dict[str, DatasetReader]`
      The dataset readers to wrap. The keys of this dictionary will be used
      as the values in the MetadataField indicating provenance.
  dataset_field_name : `str`, optional (default = `"dataset"`)
      The name of the MetadataField indicating which dataset an instance came from.
  scheme : `str`, optional (default = `"round_robin"`)
      Indicates how to interleave instances. Currently the two options are "round_robin",
      which repeatedly cycles through the datasets grabbing one instance from each;
      and "all_at_once", which yields all the instances from the first dataset,
      then all the instances from the second dataset, and so on. You could imagine also
      implementing some sort of over- or under-sampling, although hasn't been done.
class_docstr_tok: ["A","`","DatasetReader","`","that","wraps","multiple","other","dataset","readers",",","and","interleaves","their","instances",",","adding","a","`","MetadataField","`","to","indicate","the","provenance","of","each","instance",".","Unlike","most","of","our","other","dataset","readers",",","here","the","`","file_path","`","passed","into","`","read","(",")","`","should","be","a","JSON-serialized","dictionary","with","one","file_path","per","wrapped","dataset","reader","(","and","with","corresponding","keys",")",".","Registered","as","a","`","DatasetReader","`","with","name","``","interleaving","''",".","#","Parameters","readers",":","`","Dict","[","str",",","DatasetReader","]","`","The","dataset","readers","to","wrap",".","The","keys","of","this","dictionary","will","be","used","as","the","values","in","the","MetadataField","indicating","provenance",".","dataset_field_name",":","`","str","`",",","optional","(","default","=","`","``","dataset","''","`",")","The","name","of","the","MetadataField","indicating","which","dataset","an","instance","came","from",".","scheme",":","`","str","`",",","optional","(","default","=","`","``","round_robin","''","`",")","Indicates","how","to","interleave","instances",".","Currently","the","two","options","are","``","round_robin","''",",","which","repeatedly","cycles","through","the","datasets","grabbing","one","instance","from","each",";","and","``","all_at_once","''",",","which","yields","all","the","instances","from","the","first","dataset",",","then","all","the","instances","from","the","second","dataset",",","and","so","on",".","You","could","imagine","also","implementing","some","sort","of","over-","or","under-sampling",",","although","has","n't","been","done","."]
code: def _read_round_robin(
      self, datasets: Mapping[str, Iterable[Instance]]
  ) -> Iterable[Instance]:
      remaining = set(datasets)
      dataset_iterators = {
          key: iter(dataset) for key, dataset in datasets.items()
      }
  
      while remaining:
          for key, dataset in dataset_iterators.items():
              if key in remaining:
                  try:
                      instance = next(dataset)
                      instance.fields[
                          self._dataset_field_name
                      ] = MetadataField(key)
                      yield instance
                  except StopIteration:
                      remaining.remove(key)
  
file_path: allennlp/allennlp/data/dataset_readers/interleaving_dataset_reader.py
imports: from typing import Dict, Mapping, Iterable, Union, Optional
  import json
  from allennlp.common.checks import ConfigurationError
  from allennlp.data.dataset_readers.dataset_reader import DatasetReader, PathOrStr, WorkerInfo, DistributedInfo
  from allennlp.data.fields import MetadataField
  from allennlp.data.instance import Instance
label_desc: Use image node_id 4 for calling the InterleavingDatasetReader obj's underlying member method code with example usage: obj._read_round_robin(datasets) without return types