code: def itk_affine_resample(
      self,
      image,
      matrix,
      translation,
      center_of_rotation=None,
      reference_image=None,
  ):
      # Translation transform
      itk_transform = itk.AffineTransform[itk.D, image.ndim].New()
  
      # Set center
      if center_of_rotation:
          itk_transform.SetCenter(center_of_rotation)
      else:
          itk_transform.SetCenter(get_itk_image_center(image))
  
      # Set matrix and translation
      itk_transform.SetMatrix(itk.matrix_from_array(matrix))
      itk_transform.Translate(translation)
  
      # Interpolator
      image = image.astype(itk.D)
      interpolator = itk.LinearInterpolateImageFunction.New(image)
  
      if not reference_image:
          reference_image = image
  
      # Resample with ITK
      output_image = itk.resample_image_filter(
          image,
          interpolator=interpolator,
          transform=itk_transform,
          output_parameters_from_image=reference_image,
      )
  
      return np.asarray(output_image, dtype=np.float32)
  
imports: from __future__ import annotations
  import itertools
  import os
  import tempfile
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  import monai
  import monai.transforms
  from monai.apps import download_url
  from monai.data import ITKReader
  from monai.data.itk_torch_bridge import get_itk_image_center, itk_image_to_metatensor, itk_to_monai_affine, metatensor_to_itk_image, monai_to_itk_affine, monai_to_itk_ddf
  from monai.networks.blocks import Warp
  from monai.transforms import Affine
  from monai.utils import optional_import, set_determinism
  from tests.utils import assert_allclose, skip_if_downloading_fails, skip_if_quick, test_is_quick, testing_data_config
label_desc: Use image node_id 4 for calling the TestITKTorchAffineMatrixBridge obj's underlying member method code with example usage: obj.itk_affine_resample(image, matrix, translation, center_of_rotation, reference_image) and returns: np