code: def pad_test(
      self, input_param, input_shape, expected_shape, modes=None
  ):
      # loop over each mode
      for mode in modes or MODES:
          with self.subTest(mode=mode):
              base_comparison = None
              im = self.get_arr(input_shape)
              padder = self.Padder(mode=mode, **input_param)
              is_map = isinstance(padder, MapTransform)
              # check result is the same regardless of input type
              for im_type in TEST_NDARRAYS_ALL:
                  with self.subTest(im_type=im_type):
                      input_image = im_type(im)
                      input_data = (
                          {"img": im_type(im)}
                          if is_map
                          else im_type(im)
                      )
                      # our array transforms can also take `mode` as an argument to `__call__`
                      # Check this gives equivalent results
                      for call_extra_args in (
                          [{}] if is_map else [{}, {"mode": mode}]
                      ):
                          with self.subTest(
                              call_extra_args=call_extra_args
                          ):
                              r_out = padder(
                                  input_data, **call_extra_args
                              )
                              r_im = r_out["img"] if is_map else r_out
                              # check shape, type, etc.
                              np.testing.assert_allclose(
                                  r_im.shape, expected_shape
                              )
                              self.assertIsInstance(r_im, MetaTensor)
                              self.assertEqual(
                                  len(r_im.applied_operations), 1
                              )
                              # check results are same regardless of input type
                              if base_comparison is None:
                                  base_comparison = r_im
                              else:
                                  assert_allclose(r_im, base_comparison)
                              # test inverse
                              if isinstance(r_im, MetaTensor):
                                  r_out = padder.inverse(r_out)
                                  r_im = (
                                      r_out["img"] if is_map else r_out
                                  )
                                  self.assertIsInstance(
                                      r_im, MetaTensor
                                  )
                                  assert_allclose(
                                      r_im, input_image, type_test=False
                                  )
                                  self.assertEqual(
                                      r_im.applied_operations, []
                                  )
  
file_path: MONAI/tests/padders.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from monai.data.meta_tensor import MetaTensor
  from monai.transforms import Compose
  from monai.transforms.lazy.functional import apply_pending
  from monai.transforms.transform import MapTransform
  from monai.utils.enums import NumpyPadMode, PytorchPadMode
  from tests.utils import TEST_NDARRAYS_ALL, assert_allclose
label_desc: Use image node_id 2 for calling the PadTest obj's underlying member method code with example usage: obj.pad_test(input_param, input_shape, expected_shape, modes) without return types