code: def test_spacing_intensity(self):
      set_determinism(seed=0)
      with tempfile.TemporaryDirectory() as tempdir:
          for i in range(5):
              im, seg = create_test_image_3d(
                  32,
                  32,
                  32,
                  num_seg_classes=1,
                  num_objs=3,
                  rad_max=6,
                  channel_dim=0,
              )
              n = nib.Nifti1Image(im, np.eye(4))
              nib.save(n, os.path.join(tempdir, f"img{i:d}.nii.gz"))
              n = nib.Nifti1Image(seg, np.eye(4))
              nib.save(n, os.path.join(tempdir, f"seg{i:d}.nii.gz"))
  
          train_images = sorted(
              glob.glob(os.path.join(tempdir, "img*.nii.gz"))
          )
          train_labels = sorted(
              glob.glob(os.path.join(tempdir, "seg*.nii.gz"))
          )
          data_dicts = [
              {"image": image_name, "label": label_name}
              for image_name, label_name in zip(
                  train_images, train_labels
              )
          ]
  
          t = Compose(
              [
                  LoadImaged(keys=["image", "label"], image_only=False),
                  ToNumpyd(
                      keys=[
                          "image",
                          "label",
                          "image_meta_dict",
                          "label_meta_dict",
                      ]
                  ),
              ]
          )
          dataset = Dataset(data=data_dicts, transform=t)
  
          # test **kwargs of `DatasetSummary` for `DataLoader`
          calculator = DatasetSummary(
              dataset,
              num_workers=4,
              meta_key="image_meta_dict",
              collate_fn=test_collate,
          )
  
          target_spacing = calculator.get_target_spacing(
              spacing_key="pixdim"
          )
          self.assertEqual(target_spacing, (1.0, 1.0, 1.0))
          calculator.calculate_statistics()
          np.testing.assert_allclose(
              calculator.data_mean, 0.892599, rtol=1e-5, atol=1e-5
          )
          np.testing.assert_allclose(
              calculator.data_std, 0.131731, rtol=1e-5, atol=1e-5
          )
          calculator.calculate_percentiles(
              sampling_flag=True, interval=2
          )
          self.assertEqual(calculator.data_max_percentile, 1.0)
          np.testing.assert_allclose(
              calculator.data_min_percentile,
              0.556411,
              rtol=1e-5,
              atol=1e-5,
          )
  
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 the TestDatasetSummary obj's underlying member method code with example usage: obj.test_spacing_intensity() without return types