code: def test_ill_affine(self, device):
      img = MetaTensor(torch.arange(12).reshape(1, 2, 2, 3)).to(device)
      ill_affine = torch.tensor(
          [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, -1, 1.5], [0, 0, 0, 1]]
      )
      with self.assertRaises(ValueError):
          img.affine = torch.eye(4)
          dst_affine = ill_affine
          SpatialResample()(img=img, dst_affine=dst_affine)
      with self.assertRaises(ValueError):
          img.affine = ill_affine
          dst_affine = torch.eye(4)
          SpatialResample()(img=img, dst_affine=dst_affine)
      if not (
          optional_import("scipy")[1] and optional_import("cupy")[1]
      ):
          return
      with self.assertRaises(ValueError):  # requires scipy
          SpatialResample(mode=1, align_corners=True)(
              img=img, dst_affine=dst_affine
          )
      with self.assertRaises(ValueError):
          SpatialResample(mode=1, align_corners=False)(
              img=img, dst_affine=dst_affine
          )
  
imports: from __future__ import annotations
  import unittest
  from copy import deepcopy
  import numpy
  import torch
  from parameterized import parameterized
  from monai.data.meta_obj import set_track_meta
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import to_affine_nd
  from monai.transforms import SpatialResample
  from monai.utils import optional_import
  from tests.lazy_transforms_utils import test_resampler_lazy
  from tests.utils import TEST_DEVICES, TEST_NDARRAYS_ALL, assert_allclose
label_desc: Use image node_id 3 for calling the TestSpatialResample obj's underlying member method code with example usage: obj.test_ill_affine(device) without return types