class_docstr: A very basic iterator that takes a dataset, possibly shuffles it, and creates fixed sized batches.
  
  It takes the same parameters as :class:`allennlp.data.iterators.DataIterator`
code: def _create_batches(self, instances, shuffle):
      # First break the dataset into memory-sized lists:
      for instance_list in self._memory_sized_lists(instances):
          if shuffle:
              random.shuffle(instance_list)
          iterator = iter(instance_list)
          # Then break each memory-sized list into batches.
          for batch_instances in lazy_groups_of(
              iterator, self._batch_size
          ):
              for (
                  possibly_smaller_batches
              ) in self._ensure_batch_is_sufficiently_small(
                  batch_instances
              ):
                  batch = Batch(possibly_smaller_batches)
                  yield batch
  
file_path: magnitude/pymagnitude/third_party/allennlp/data/iterators/basic_iterator.py
imports: from __future__ import absolute_import
  import logging
  import random
  from allennlp.common.util import lazy_groups_of
  from allennlp.data.instance import Instance
  from allennlp.data.iterators.data_iterator import DataIterator
  from allennlp.data.dataset import Batch
label_desc: Use image node_id 1 for calling the BasicIterator obj's underlying member method code with example usage: obj._create_batches(instances, shuffle) without return types