class_docstr: An abstract ``DataIterator`` class. ``DataIterators`` must override ``_create_batches()``.
  
  Parameters
  ----------
  batch_size : ``int``, optional, (default = 32)
      The size of each batch of instances yielded when calling the iterator.
  instances_per_epoch : ``int``, optional, (default = None)
      If specified, each epoch will consist of precisely this many instances.
      If not specified, each epoch will consist of a single pass through the dataset.
  max_instances_in_memory : ``int``, optional, (default = None)
      If specified, the iterator will load this many instances at a time into an
      in-memory list and then produce batches from one such list at a time. This
      could be useful if your instances are read lazily from disk.
  cache_instances : ``bool``, optional, (default = False)
      If true, the iterator will cache the tensorized instances in memory.
      If false, it will do the tensorization anew each iteration.
  track_epoch : ``bool``, optional, (default = False)
      If true, each instance will get a ``MetadataField`` containing the epoch number.
  maximum_samples_per_batch : ``Tuple[str, int]``, (default = None)
      If specified, then is a tuple (padding_key, limit) and we will
      shrink the batch size for very long sequences such that
      batch_size * sequence_length <= limit where sequence_length is given
      by the padding_key.
docstr: If self._maximum_samples_per_batch is specified, then split the batch into smaller
  sub-batches if it exceeds the maximum size.
docstr_tok: ["If","self._maximum_samples_per_batch","is","specified",",","then","split","the","batch","into","smaller","sub-batches","if","it","exceeds","the","maximum","size","."]
code: def _ensure_batch_is_sufficiently_small(self, batch_instances):
      """
      If self._maximum_samples_per_batch is specified, then split the batch into smaller
      sub-batches if it exceeds the maximum size.
      """
      if self._maximum_samples_per_batch is None:
          return [list(batch_instances)]
  
      # check if we need to break into smaller chunks
      key, limit = self._maximum_samples_per_batch
      padding_length = -1
      list_batch_instances = list(batch_instances)
      for instance in list_batch_instances:
          field_lengths = instance.get_padding_lengths()
          for _, lengths in list(field_lengths.items()):
              try:
                  padding_length = max(padding_length, lengths[key])
              except KeyError:
                  pass
  
      if padding_length * len(list_batch_instances) > limit:
          # need to shrink
          num_samples = padding_length * len(list_batch_instances)
          num_shrunk_batches = math.ceil(num_samples / float(limit))
          shrunk_batch_size = math.ceil(
              len(list_batch_instances) / num_shrunk_batches
          )
          shrunk_batches = []
          start = 0
          while start < len(list_batch_instances):
              end = start + shrunk_batch_size
              shrunk_batches.append(list_batch_instances[start:end])
              start = end
          return shrunk_batches
      else:
          return [list_batch_instances]
  
imports: from __future__ import division
  from __future__ import absolute_import
  import logging
  from collections import defaultdict
  import itertools
  import math
  import random
  import torch
  from allennlp.common.registrable import Registrable
  from allennlp.common.util import is_lazy, lazy_groups_of, ensure_list
  from allennlp.data.dataset import Batch
  from allennlp.data.fields import MetadataField
  from allennlp.data.instance import Instance
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 5 for calling the DataIterator obj's underlying member method code with example usage: obj._ensure_batch_is_sufficiently_small(batch_instances) and returns: list, shrunk_batches, list