code: def test_random_shape(self, input_param, input_shape, expected_shape):
      for im_type in TEST_NDARRAYS_ALL:
          with self.subTest(im_type=im_type):
              cropper = self.Cropper(**input_param)
              cropper.set_random_state(seed=123)
              input_data = {
                  "img": im_type(np.random.randint(0, 2, input_shape))
              }
              expected = cropper(input_data)["img"]
              self.assertTupleEqual(expected.shape, expected_shape)
  
              # lazy
              # reset random seed to ensure the same results
              cropper.set_random_state(seed=123)
              cropper.lazy = True
              pending_result = cropper(input_data)["img"]
              self.assertIsInstance(pending_result, MetaTensor)
              assert_allclose(
                  pending_result.peek_pending_affine(), expected.affine
              )
              assert_allclose(
                  pending_result.peek_pending_shape(),
                  expected.shape[1:],
              )
              # only support nearest
              result = apply_pending(
                  pending_result,
                  overrides={"mode": "nearest", "align_corners": False},
              )[0]
              # compare
              assert_allclose(result, expected, rtol=1e-5)
  
file_path: MONAI/tests/test_rand_spatial_cropd.py
imports: from __future__ import annotations
  import unittest
  import numpy
  from parameterized import parameterized
  from monai.data.meta_tensor import MetaTensor
  from monai.transforms import RandScaleCropd, RandSpatialCropd
  from monai.transforms.lazy.functional import apply_pending
  from tests.croppers import CropTest
  from tests.utils import TEST_NDARRAYS_ALL, assert_allclose
label_desc: Use image node_id 3 for calling the TestRandSpatialCropd obj's underlying member method code with example usage: obj.test_random_shape(input_param, input_shape, expected_shape) without return types