code: def test_affine_transform_3d(self):
      t = np.pi / 3
      affine = [
          [1, 0, 0, 0],
          [0.0, np.cos(t), -np.sin(t), 0],
          [0, np.sin(t), np.cos(t), 0],
          [0, 0, 0, 1],
      ]
      affine = torch.as_tensor(
          affine, device=torch.device("cpu:0"), dtype=torch.float32
      )
      image = (
          torch.arange(48.0)
          .view(2, 1, 4, 2, 3)
          .to(device=torch.device("cpu:0"))
      )
      xform = AffineTransform(
          (3, 4, 2),
          padding_mode="border",
          align_corners=False,
          mode="bilinear",
      )
      out = xform(image, affine)
      out = out.detach().cpu().numpy()
      expected = [
          [
              [
                  [
                      [0.00000006, 0.5000001],
                      [2.3660254, 1.3660254],
                      [4.732051, 2.4019241],
                      [5.0, 3.9019237],
                  ],
                  [
                      [6.0, 6.5],
                      [8.366026, 7.3660254],
                      [10.732051, 8.401924],
                      [11.0, 9.901924],
                  ],
                  [
                      [12.0, 12.5],
                      [14.366026, 13.366025],
                      [16.732052, 14.401924],
                      [17.0, 15.901923],
                  ],
              ]
          ],
          [
              [
                  [
                      [24.0, 24.5],
                      [26.366024, 25.366024],
                      [28.732052, 26.401924],
                      [29.0, 27.901924],
                  ],
                  [
                      [30.0, 30.5],
                      [32.366028, 31.366026],
                      [34.732048, 32.401924],
                      [35.0, 33.901924],
                  ],
                  [
                      [36.0, 36.5],
                      [38.366024, 37.366024],
                      [40.73205, 38.401924],
                      [41.0, 39.901924],
                  ],
              ]
          ],
      ]
      np.testing.assert_allclose(out, expected, atol=1e-4, rtol=_rtol)
  
      if torch.cuda.is_available():
          affine = torch.as_tensor(
              affine, device=torch.device("cuda:0"), dtype=torch.float32
          )
          image = (
              torch.arange(48.0)
              .view(2, 1, 4, 2, 3)
              .to(device=torch.device("cuda:0"))
          )
          xform = AffineTransform(
              padding_mode="border",
              align_corners=False,
              mode="bilinear",
          )
          out = xform(image, affine, (3, 4, 2))
          out = out.detach().cpu().numpy()
          expected = [
              [
                  [
                      [
                          [0.00000006, 0.5000001],
                          [2.3660254, 1.3660254],
                          [4.732051, 2.4019241],
                          [5.0, 3.9019237],
                      ],
                      [
                          [6.0, 6.5],
                          [8.366026, 7.3660254],
                          [10.732051, 8.401924],
                          [11.0, 9.901924],
                      ],
                      [
                          [12.0, 12.5],
                          [14.366026, 13.366025],
                          [16.732052, 14.401924],
                          [17.0, 15.901923],
                      ],
                  ]
              ],
              [
                  [
                      [
                          [24.0, 24.5],
                          [26.366024, 25.366024],
                          [28.732052, 26.401924],
                          [29.0, 27.901924],
                      ],
                      [
                          [30.0, 30.5],
                          [32.366028, 31.366026],
                          [34.732048, 32.401924],
                          [35.0, 33.901924],
                      ],
                      [
                          [36.0, 36.5],
                          [38.366024, 37.366024],
                          [40.73205, 38.401924],
                          [41.0, 39.901924],
                      ],
                  ]
              ],
          ]
          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 10 for calling the TestAffineTransform obj's underlying member method code with example usage: obj.test_affine_transform_3d() without return types