code: def test_collate(batch):
      elem = batch[0]
      elem_type = type(elem)
      if isinstance(elem, np.ndarray):
          return np.stack(batch, 0)
      elif isinstance(elem, dict):
          return elem_type(
              {
                  key: test_collate([d[key] for d in batch])
                  for key in elem
              }
          )
  
file_path: MONAI/tests/test_dataset_summary.py
imports: from __future__ import annotations
  import glob
  import os
  import tempfile
  import unittest
  import nibabel
  import numpy
  from monai.data import Dataset, DatasetSummary, create_test_image_3d
  from monai.transforms import LoadImaged
  from monai.transforms.compose import Compose
  from monai.transforms.utility.dictionary import ToNumpyd
  from monai.utils import set_determinism
label_desc: Use image node_id 1 for calling a global function with example usage: test_collate(batch) and returns: np, elem_type