code: def test_anisotropic_spacing(self):
      with tempfile.TemporaryDirectory() as tempdir:
          pixdims = [
              [1.0, 1.0, 5.0],
              [1.0, 1.0, 4.0],
              [1.0, 1.0, 4.5],
              [1.0, 1.0, 2.0],
              [1.0, 1.0, 1.0],
          ]
          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))
              n.header["pixdim"][1:4] = pixdims[i]
              nib.save(n, os.path.join(tempdir, f"img{i:d}.nii.gz"))
              n = nib.Nifti1Image(seg, np.eye(4))
              n.header["pixdim"][1:4] = pixdims[i]
              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"])])
          dataset = Dataset(data=data_dicts, transform=t)
  
          calculator = DatasetSummary(dataset, num_workers=4)
  
          target_spacing = calculator.get_target_spacing(
              anisotropic_threshold=4.0, percentile=20.0
          )
          np.testing.assert_allclose(target_spacing, (1.0, 1.0, 1.8))
  
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 2 for calling the TestDatasetSummary obj's underlying member method code with example usage: obj.test_anisotropic_spacing() without return types