docstr: test resampling of an identity grid with padding 2, im_type, interp, padding, input_shape
docstr_tok: ["test","resampling","of","an","identity","grid","with","padding","2",",","im_type",",","interp",",","padding",",","input_shape"]
code: def test_resample_identity(
      self, input_param, im_type, interp, padding, input_shape
  ):
      """test resampling of an identity grid with padding 2, im_type, interp, padding, input_shape"""
      xform = Resample(dtype=im_type, **input_param)
      n_elem = np.prod(input_shape)
      img = convert_to_numpy(
          np.arange(n_elem).reshape(input_shape), dtype=im_type
      )
      grid = create_grid(
          input_shape[1:], homogeneous=True, backend="numpy"
      )
      grid_p = np.stack(
          [np.pad(g, 2, "constant") for g in grid]
      )  # testing pad
      output = xform(
          img=img, grid=grid_p, mode=interp, padding_mode=padding
      )
      self.assertTrue(
          not torch.any(torch.isinf(output) | torch.isnan(output))
      )
      self.assertIsInstance(output, MetaTensor)
      slices = [slice(None)]
      slices.extend([slice(2, -2) for _ in img.shape[1:]])
      output_c = output[slices]
      assert_allclose(
          output_c, img, rtol=_rtol, atol=1e-3, type_test="tensor"
      )
  
file_path: MONAI/tests/test_resample_backends.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  from monai.config import USE_COMPILED
  from monai.data import MetaTensor
  from monai.transforms import Resample
  from monai.transforms.utils import create_grid
  from monai.utils import GridSampleMode, GridSamplePadMode, NdimageMode, SplineMode, convert_to_numpy
  from tests.utils import SkipIfBeforePyTorchVersion, assert_allclose, is_tf32_env
label_desc: Use image node_id 1 for calling the TestResampleBackends obj's underlying member method code with example usage: obj.test_resample_identity(input_param, im_type, interp, padding, input_shape) without return types