code: def test_inverse(self, device):
      img_t = torch.rand(
          (1, 10, 9, 8), dtype=torch.float32, device=device
      )
      affine = torch.tensor(
          [[0, 0, -1, 0], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]],
          dtype=torch.float32,
          device="cpu",
      )
      meta = {"fname": "somewhere"}
      img = MetaTensor(img_t, affine=affine, meta=meta)
      tr = Orientation("LPS")
      # check that image and affine have changed
      img = tr(img)
      self.assertNotEqual(img.shape, img_t.shape)
      self.assertGreater((affine - img.affine).max(), 0.5)
      # check that with inverse, image affine are back to how they were
      img = tr.inverse(img)
      self.assertEqual(img.shape, img_t.shape)
      self.assertLess((affine - img.affine).max(), 1e-2)
  
file_path: MONAI/tests/test_orientation.py
imports: from __future__ import annotations
  import unittest
  import nibabel
  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.transforms import Orientation, create_rotate, create_translate
  from tests.lazy_transforms_utils import test_resampler_lazy
  from tests.utils import TEST_DEVICES, assert_allclose
label_desc: Use image node_id 4 for calling the TestOrientationCase obj's underlying member method code with example usage: obj.test_inverse(device) without return types