code: def test_correct(self):
      transforms = Compose(
          [
              LoadImaged(("im1", "im2")),
              EnsureChannelFirstd(("im1", "im2")),
              CopyItemsd(("im2"), names=("im3")),
              ResampleToMatchd("im3", "im1"),
              Lambda(update_fname),
              SaveImaged(
                  "im3",
                  output_dir=self.tmpdir,
                  output_postfix="",
                  separate_folder=False,
                  resample=False,
              ),
          ]
      )
      data = transforms({"im1": self.fnames[0], "im2": self.fnames[1]})
      # check that output sizes match
      assert_allclose(data["im1"].shape, data["im3"].shape)
      # and that the meta data has been updated accordingly
      assert_allclose(data["im3"].affine, data["im1"].affine)
      # check we're different from the original
      self.assertTrue(
          any(
              i != j
              for i, j in zip(data["im3"].shape, data["im2"].shape)
          )
      )
      self.assertTrue(
          any(
              i != j
              for i, j in zip(
                  data["im3"].affine.flatten(),
                  data["im2"].affine.flatten(),
              )
          )
      )
      # test the inverse
      data = Invertd("im3", transforms)(data)
      assert_allclose(data["im2"].shape, data["im3"].shape)
  
file_path: MONAI/tests/test_resample_to_matchd.py
imports: from __future__ import annotations
  import os
  import shutil
  import tempfile
  import unittest
  from monai.transforms import Compose, CopyItemsd, EnsureChannelFirstd, Invertd, Lambda, LoadImaged, ResampleToMatchd, SaveImaged
  from tests.lazy_transforms_utils import test_resampler_lazy
  from tests.utils import assert_allclose, download_url_or_skip_test, testing_data_config
label_desc: Use image node_id 3 for calling the TestResampleToMatchd obj's underlying member method code with example usage: obj.test_correct() without return types