code: def test_inverse_array(
      self, use_compose: bool, dtype: torch.dtype, device: torch.device
  ):
      img: MetaTensor
      tr = Compose(
          [
              EnsureChannelFirst(channel_dim="no_channel"),
              Orientation("RAS"),
              Flip(1),
              Spacing([1.0, 1.2, 0.9], align_corners=False),
          ]
      )
      num_invertible = len(
          [
              i
              for i in tr.transforms
              if isinstance(i, InvertibleTransform)
          ]
      )
  
      # forward
      img = tr(self.get_image(dtype, device))
      self.assertEqual(len(img.applied_operations), num_invertible)
  
      # inverse with Compose
      if use_compose:
          img = tr.inverse(img)
          self.assertEqual(len(img.applied_operations), 0)
  
      # inverse individually
      else:
          _tr: InvertibleTransform
          num_to_inverse = num_invertible
          for _tr in tr.transforms[::-1]:
              if isinstance(_tr, InvertibleTransform):
                  img = _tr.inverse(img)
                  num_to_inverse -= 1
                  self.assertEqual(
                      len(img.applied_operations), num_to_inverse
                  )
  
file_path: MONAI/tests/test_inverse_array.py
imports: from __future__ import annotations
  import unittest
  import torch
  from parameterized import parameterized
  from monai.data import MetaTensor
  from monai.transforms import Compose, EnsureChannelFirst, Flip, Orientation, Spacing
  from monai.transforms.inverse import InvertibleTransform
  from monai.utils import optional_import
  from tests.utils import TEST_DEVICES
label_desc: Use image node_id 2 for calling the TestInverseArray obj's underlying member method code with example usage: obj.test_inverse_array(use_compose, dtype, device) without return types