code: def batchify(array: list, bs: int = 1, generator: bool = True):
      """Convert any iterable into a list/generator with batch size `bs`"""
  
      def list_to_batch(array, bs):
          n = len(array)
          for i in range(0, n, bs):
              batch = array[i : i + bs]
              yield batch
  
      if generator:
          return list_to_batch(array, bs)
      else:
          return list(list_to_batch(array, bs))
  
file_path: chitra/chitra/data_processing/processor.py
imports: from typing import Callable, Optional
label_desc: Use image node_id 1 for calling a global function with example usage: batchify(array, bs, generator) and returns: list_to_batch, list