code: def test_maximum_samples_per_batch(self):
      for test_instances in (self.instances, self.lazy_instances):
          # pylint: disable=protected-access
          iterator = BasicIterator(
              batch_size=3, maximum_samples_per_batch=["num_tokens", 9]
          )
          batches = list(
              iterator._create_batches(test_instances, shuffle=False)
          )
  
          # ensure all instances are in a batch
          grouped_instances = [batch.instances for batch in batches]
          num_instances = sum(len(group) for group in grouped_instances)
          assert num_instances == len(self.instances)
  
          # ensure all batches are sufficiently small
          for batch in batches:
              batch_sequence_length = max(
                  [
                      instance.get_padding_lengths()["text"][
                          "num_tokens"
                      ]
                      for instance in batch.instances
                  ]
              )
              assert batch_sequence_length * len(batch.instances) <= 9
  
imports: from __future__ import absolute_import
  from collections import Counter
  from allennlp.common import Params
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Instance, Token, Vocabulary
  from allennlp.data.dataset_readers.dataset_reader import _LazyInstances
  from allennlp.data.fields import TextField
  from allennlp.data.iterators import BasicIterator
  from allennlp.data.token_indexers import SingleIdTokenIndexer
label_desc: Use image node_id 11 for calling the TestBasicIterator obj's underlying member method code with example usage: obj.test_maximum_samples_per_batch() without return types