class_docstr: A batch of Instances. In addition to containing the instances themselves,
  it contains helper functions for converting the data into tensors.
  
  A Batch just takes an iterable of instances in its constructor and hangs onto them
  in a list.
class_docstr_tok: ["A","batch","of","Instances",".","In","addition","to","containing","the","instances","themselves",",","it","contains","helper","functions","for","converting","the","data","into","tensors",".","A","Batch","just","takes","an","iterable","of","instances","in","its","constructor","and","hangs","onto","them","in","a","list","."]
docstr: Check that all the instances have the same types.
docstr_tok: ["Check","that","all","the","instances","have","the","same","types","."]
code: def _check_types(self) -> None:
      """
      Check that all the instances have the same types.
      """
      field_name_to_type_counters: Dict[str, Counter] = defaultdict(
          lambda: Counter()
      )
      field_counts: Counter = Counter()
      for instance in self.instances:
          for field_name, value in instance.fields.items():
              field_name_to_type_counters[field_name][
                  value.__class__.__name__
              ] += 1
              field_counts[field_name] += 1
      for (
          field_name,
          type_counters,
      ) in field_name_to_type_counters.items():
          if len(type_counters) > 1:
              raise ConfigurationError(
                  "You cannot construct a Batch with non-homogeneous Instances. "
                  f"Field '{field_name}' has {len(type_counters)} different types: "
                  f"{', '.join(type_counters.keys())}"
              )
          if field_counts[field_name] != len(self.instances):
              raise ConfigurationError(
                  "You cannot construct a Batch with non-homogeneous Instances. "
                  f"Field '{field_name}' present in some Instances but not others."
              )
  
file_path: allennlp/allennlp/data/batch.py
imports: import logging
  from collections import defaultdict, Counter
  from typing import Dict, Iterable, Iterator, List, Union
  import numpy
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import ensure_list
  from allennlp.data.instance import Instance
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 2 for calling the Batch obj's underlying member method code with example usage: obj._check_types() without return types