class_docstr: A class that determines how to order instances within an epoch.
  This is used by the `MultiTaskDataLoader`. The main operation performed by this class is to
  take a dictionary of instance iterators, one for each dataset, and combine them into an
  iterator of batches, based on some scheduling algorithm (such as round robin, randomly choosing
  between available datasets, etc.). To control this behavior as training progresses, there is an
  `update_from_epoch_metrics` method available, which should be called from a `Callback` during
  training.  Not all `MultiTaskSchedulers` will implement this method.
class_docstr_tok: ["A","class","that","determines","how","to","order","instances","within","an","epoch",".","This","is","used","by","the","`","MultiTaskDataLoader","`",".","The","main","operation","performed","by","this","class","is","to","take","a","dictionary","of","instance","iterators",",","one","for","each","dataset",",","and","combine","them","into","an","iterator","of","batches",",","based","on","some","scheduling","algorithm","(","such","as","round","robin",",","randomly","choosing","between","available","datasets",",","etc.",")",".","To","control","this","behavior","as","training","progresses",",","there","is","an","`","update_from_epoch_metrics","`","method","available",",","which","should","be","called","from","a","`","Callback","`","during","training",".","Not","all","`","MultiTaskSchedulers","`","will","implement","this","method","."]
docstr: Given a dictionary of `Iterable[Instance]` for each dataset, combines them into an
  `Iterable` of batches of instances.
docstr_tok: ["Given","a","dictionary","of","`","Iterable","[","Instance","]","`","for","each","dataset",",","combines","them","into","an","`","Iterable","`","of","batches","of","instances","."]
code: def batch_instances(
      self, epoch_instances: Dict[str, Iterable[Instance]]
  ) -> Iterable[List[Instance]]:
      """
      Given a dictionary of `Iterable[Instance]` for each dataset, combines them into an
      `Iterable` of batches of instances.
      """
      raise NotImplementedError
  
imports: from collections import defaultdict
  from typing import Any, Dict, Iterable, Union, List, Mapping
  import more_itertools
  from allennlp.common.registrable import Registrable
  from allennlp.data.instance import Instance
label_desc: Use image node_id 1 for calling the MultiTaskScheduler obj's underlying member method code with example usage: obj.batch_instances(epoch_instances) without return types