class_docstr: Test inverse methods.
  
  If tests are failing, the following function might be useful for displaying
  `x`, `fx`, `f⁻¹fx` and `x - f⁻¹fx`.
  
  .. code-block:: python
  
      def plot_im(orig, fwd_bck, fwd):
          import matplotlib.pyplot as plt
          diff_orig_fwd_bck = orig - fwd_bck
          ims_to_show = [orig, fwd, fwd_bck, diff_orig_fwd_bck]
          titles = ["x", "fx", "f⁻¹fx", "x - f⁻¹fx"]
          fig, axes = plt.subplots(1, 4, gridspec_kw={"width_ratios": [i.shape[1] for i in ims_to_show]})
          vmin = min(np.array(i).min() for i in [orig, fwd_bck, fwd])
          vmax = max(np.array(i).max() for i in [orig, fwd_bck, fwd])
          for im, title, ax in zip(ims_to_show, titles, axes):
              _vmin, _vmax = (vmin, vmax) if id(im) != id(diff_orig_fwd_bck) else (None, None)
              im = np.squeeze(np.array(im))
              while im.ndim > 2:
                  im = im[..., im.shape[-1] // 2]
              im_show = ax.imshow(np.squeeze(im), vmin=_vmin, vmax=_vmax)
              ax.set_title(title, fontsize=25)
              ax.axis("off")
              fig.colorbar(im_show, ax=ax)
          plt.show()
  
  This can then be added to the exception:
  
  .. code-block:: python
  
      except AssertionError:
          print(
              f"Failed: {name}. Mean diff = {mean_diff} (expected <= {acceptable_diff}), unmodified diff: {unmodded_diff}"
          )
          if orig[0].ndim > 1:
              plot_im(orig, fwd_bck, unmodified)
code: def check_inverse(
      self, name, keys, orig_d, fwd_bck_d, unmodified_d, acceptable_diff
  ):
      for key in keys:
          orig = orig_d[key]
          fwd_bck = fwd_bck_d[key]
          if isinstance(fwd_bck, torch.Tensor):
              fwd_bck = fwd_bck.cpu().numpy()
          unmodified = unmodified_d[key]
          if isinstance(orig, np.ndarray):
              mean_diff = np.mean(np.abs(orig - fwd_bck))
              resized = ResizeWithPadOrCrop(orig.shape[1:])(unmodified)
              if isinstance(resized, torch.Tensor):
                  resized = resized.detach().cpu().numpy()
              unmodded_diff = np.mean(np.abs(orig - resized))
              try:
                  self.assertLessEqual(mean_diff, acceptable_diff)
              except AssertionError:
                  print(
                      f"Failed: {name}. Mean diff = {mean_diff} (expected <= {acceptable_diff}), unmodified diff: {unmodded_diff}"
                  )
                  if orig[0].ndim == 1:
                      print("orig", orig[0])
                      print("fwd_bck", fwd_bck[0])
                      print("unmod", unmodified[0])
                  raise
  
imports: from __future__ import annotations
  import random
  import sys
  import unittest
  from copy import deepcopy
  from functools import partial
  from typing import TYPE_CHECKING
  from unittest.case import skipUnless
  import numpy
  import torch
  from parameterized import parameterized
  from monai.data import CacheDataset, DataLoader, MetaTensor, create_test_image_2d, create_test_image_3d, decollate_batch
  from monai.networks.nets import UNet
  from monai.transforms import Affined, BorderPadd, CenterScaleCropd, CenterSpatialCropd, Compose, CropForegroundd, DivisiblePadd, EnsureChannelFirstd, Flipd, FromMetaTensord, InvertibleTransform, Lambdad, LoadImaged, Orientationd, RandAffined, RandAxisFlipd, RandCropByLabelClassesd, RandCropByPosNegLabeld, RandFlipd, RandLambdad, Randomizable, RandRotate90d, RandRotated, RandSpatialCropd, RandSpatialCropSamplesd, RandWeightedCropd, RandZoomd, Resized, ResizeWithPadOrCrop, ResizeWithPadOrCropd, Rotate90d, Rotated, Spacingd, SpatialCropd, SpatialPadd, ToMetaTensord, Transposed, Zoomd, allow_missing_keys_mode, convert_applied_interp_mode, reset_ops_id
  from monai.utils import first, get_seed, optional_import, set_determinism
  from tests.utils import make_nifti_image, make_rand_affine
label_desc: Use image node_id 3 for calling the TestInverse obj's underlying member method code with example usage: obj.check_inverse(name, keys, orig_d, fwd_bck_d, unmodified_d, acceptable_diff) without return types