code: def _resample_to_affine(itk_obj, ref_obj):
      """linear resample"""
      dim = itk_obj.GetImageDimension()
      transform = itk.IdentityTransform[itk.D, dim].New()
      interpolator = itk.LinearInterpolateImageFunction[
          type(itk_obj), itk.D
      ].New()
      resampled = itk.resample_image_filter(
          Input=itk_obj,
          interpolator=interpolator,
          transform=transform,
          UseReferenceImage=True,
          ReferenceImage=ref_obj,
      )
      return resampled
  
file_path: MONAI/tests/test_meta_affine.py
imports: from __future__ import annotations
  import os
  import unittest
  from copy import deepcopy
  import numpy
  from parameterized import parameterized
  from monai.data.image_writer import ITKWriter
  from monai.transforms import Compose, EnsureChannelFirst, EnsureChannelFirstd, LoadImage, LoadImaged, MapTransform, Orientation, Orientationd, Randomizable, Spacing, Spacingd, Transform
  from monai.utils import convert_data_type, optional_import
  from tests.utils import assert_allclose, download_url_or_skip_test, testing_data_config
label_desc: Use image node_id 2 for calling a global function with example usage: _resample_to_affine(itk_obj, ref_obj) and returns: resampled