code: def test_affine_transform_2d(self):
      t = np.pi / 3
      affine = [
          [np.cos(t), -np.sin(t), 0],
          [np.sin(t), np.cos(t), 0],
          [0, 0, 1],
      ]
      affine = torch.as_tensor(
          affine, device=torch.device("cpu:0"), dtype=torch.float32
      )
      image = (
          torch.arange(24.0)
          .view(1, 1, 4, 6)
          .to(device=torch.device("cpu:0"))
      )
      xform = AffineTransform(
          (3, 4),
          padding_mode="border",
          align_corners=False,
          mode="bilinear",
      )
      out = xform(image, affine)
      out = out.detach().cpu().numpy()
      expected = [
          [
              [
                  [
                      7.1525574e-07,
                      4.9999994e-01,
                      1.0000000e00,
                      1.4999999e00,
                  ],
                  [
                      3.8660259e00,
                      1.3660253e00,
                      1.8660252e00,
                      2.3660252e00,
                  ],
                  [
                      7.7320518e00,
                      3.0358994e00,
                      2.7320509e00,
                      3.2320507e00,
                  ],
              ]
          ]
      ]
      np.testing.assert_allclose(out, expected, atol=1e-3, rtol=_rtol)
  
      if torch.cuda.is_available():
          affine = torch.as_tensor(
              affine, device=torch.device("cuda:0"), dtype=torch.float32
          )
          image = (
              torch.arange(24.0)
              .view(1, 1, 4, 6)
              .to(device=torch.device("cuda:0"))
          )
          xform = AffineTransform(
              padding_mode="border",
              align_corners=False,
              mode="bilinear",
          )
          out = xform(image, affine, (3, 4))
          out = out.detach().cpu().numpy()
          expected = [
              [
                  [
                      [
                          7.1525574e-07,
                          4.9999994e-01,
                          1.0000000e00,
                          1.4999999e00,
                      ],
                      [
                          3.8660259e00,
                          1.3660253e00,
                          1.8660252e00,
                          2.3660252e00,
                      ],
                      [
                          7.7320518e00,
                          3.0358994e00,
                          2.7320509e00,
                          3.2320507e00,
                      ],
                  ]
              ]
          ]
          np.testing.assert_allclose(out, expected, atol=5e-3)
  
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  from monai.networks import normalize_transform, to_norm_affine
  from monai.networks.layers import AffineTransform
  from tests.utils import is_tf32_env
label_desc: Use image node_id 9 for calling the TestAffineTransform obj's underlying member method code with example usage: obj.test_affine_transform_2d() without return types