code: def batcher(iterator, batch_size=4, progress=False):
      if progress:
          iterator = tqdm.tqdm(iterator)
  
      batch = []
      for elem in iterator:
          batch.append(elem)
          if len(batch) == batch_size:
              final_batch = batch
              batch = []
              yield final_batch
      if len(batch) > 0:  # Leftovers
          yield batch
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/metrics/summac/utils_misc.py
imports: import numpy
  import tqdm
  import os
  import time
label_desc: Use image node_id 5 for calling a global function with example usage: batcher(iterator, batch_size, progress) without return types