code: def test_spacing(
      self,
      init_param: dict,
      img: torch.Tensor,
      affine: torch.Tensor,
      data_param: dict,
      expected_output: torch.Tensor,
      device: torch.device,
  ):
      img = MetaTensor(img, affine=affine).to(device)
      tr = Spacing(**init_param)
      call_param = data_param.copy()
      call_param["data_array"] = img
      res: MetaTensor = tr(**call_param)  # type: ignore
      self.assertEqual(img.device, res.device)
  
      test_resampler_lazy(
          tr, res, init_param=init_param, call_param=call_param
      )
  
      assert_allclose(res, expected_output, atol=1e-1, rtol=1e-1)
      sr = min(len(res.shape) - 1, 3)
      if isinstance(init_param["pixdim"], float):
          init_param["pixdim"] = [init_param["pixdim"]] * sr
      init_pixdim = init_param["pixdim"][:sr]
      norm = affine_to_spacing(res.affine, sr).cpu().numpy()
      assert_allclose(
          fall_back_tuple(init_pixdim, norm), norm, type_test=False
      )
  
file_path: MONAI/tests/test_spacing.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  from monai.config import USE_COMPILED
  from monai.data.meta_obj import set_track_meta
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import affine_to_spacing
  from monai.transforms import Spacing
  from monai.utils import fall_back_tuple
  from tests.lazy_transforms_utils import test_resampler_lazy
  from tests.utils import TEST_DEVICES, TEST_NDARRAYS_ALL, assert_allclose, skip_if_quick
label_desc: Use image node_id 1 for calling the TestSpacingCase obj's underlying member method code with example usage: obj.test_spacing(init_param, img, affine, data_param, expected_output, device) without return types