code: def get_batches_stats(
      self, batches: Iterable[Batch]
  ) -> Dict[str, Union[int, List[int]]]:
      grouped_instances = [batch.instances for batch in batches]
      group_lengths = [len(group) for group in grouped_instances]
  
      sample_sizes = []
      for batch in batches:
          batch_sequence_length = max(
              instance.get_padding_lengths()["text"]["tokens___tokens"]
              for instance in batch.instances
          )
          sample_sizes.append(
              batch_sequence_length * len(batch.instances)
          )
  
      return {
          "batch_lengths": group_lengths,
          "total_instances": sum(group_lengths),
          "sample_sizes": sample_sizes,
      }
  
file_path: allennlp/tests/data/samplers/sampler_test.py
imports: from typing import List, Iterable, Dict, Union
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.data import Vocabulary, Instance, Token, Batch, DatasetReader
  from allennlp.data.fields import TextField
  from allennlp.data.token_indexers import SingleIdTokenIndexer
label_desc: Use image node_id 5 for calling the SamplerTest obj's underlying member method code with example usage: obj.get_batches_stats(batches) and returns: dict