code: def _generate_batch_data(sampler, batch_size):
      batch = []
      for idx in sampler:
          batch.append(idx)
          if len(batch) == batch_size:
              yield batch
              batch = []
      if len(batch) > 0:
          yield batch
  
file_path: mmdetection/demo/create_result_gif.py
imports: import argparse
  import os
  import os.path
  import matplotlib.patches
  import matplotlib.pyplot
  import mmcv
  import numpy
  from mmengine.utils import scandir
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_batch_data(sampler, batch_size) without return types