code: def test_random_array(self, ndim):
      # Create image/array with random size and pixel intensities
      s = torch.randint(low=2, high=20, size=(ndim,))
      img = 100 * torch.rand((1, 1, *s.tolist()), dtype=torch.float32)
  
      # Pad at the edges because ITK and MONAI have different behavior there
      # during resampling
      img = torch.nn.functional.pad(img, pad=ndim * (1, 1))
      ddf = (
          5
          * torch.rand(
              (1, ndim, *img.shape[-ndim:]), dtype=torch.float32
          )
          - 2.5
      )
  
      # Warp with MONAI
      img_resampled = self.monai_warp(img, ddf)
  
      # Create ITK image
      itk_img = itk.GetImageFromArray(img.squeeze().numpy())
  
      # Set random spacing
      spacing = 3 * np.random.rand(ndim)
      itk_img.SetSpacing(spacing)
  
      # Set random direction
      direction = 5 * np.random.rand(ndim, ndim) - 5
      direction = itk.matrix_from_array(direction)
      itk_img.SetDirection(direction)
  
      # Set random origin
      origin = 100 * np.random.rand(ndim) - 100
      itk_img.SetOrigin(origin)
  
      # Warp with ITK
      itk_img_resampled = self.itk_warp(itk_img, ddf.squeeze().numpy())
  
      # Compare
      np.testing.assert_allclose(
          img_resampled, itk_img_resampled, rtol=1e-2, atol=1e-2
      )
  
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 13 for calling the TestITKTorchAffineMatrixBridge obj's underlying member method code with example usage: obj.test_random_array(ndim) without return types