code: def test_shape(
      self, img_transform, label_transform, indices, expected_shape
  ):
      test_image = nib.Nifti1Image(
          np.random.randint(0, 2, size=(128, 128, 128)).astype(float),
          np.eye(4),
      )
      with tempfile.TemporaryDirectory() as tempdir:
          test_image1 = os.path.join(tempdir, "test_image1.nii.gz")
          test_seg1 = os.path.join(tempdir, "test_seg1.nii.gz")
          test_image2 = os.path.join(tempdir, "test_image2.nii.gz")
          test_seg2 = os.path.join(tempdir, "test_seg2.nii.gz")
          nib.save(test_image, test_image1)
          nib.save(test_image, test_seg1)
          nib.save(test_image, test_image2)
          nib.save(test_image, test_seg2)
          test_images = [test_image1, test_image2]
          test_segs = [test_seg1, test_seg2]
          test_labels = [1, 1]
          dataset = ArrayDataset(
              test_images,
              img_transform,
              test_segs,
              label_transform,
              test_labels,
              None,
          )
          self.assertEqual(len(dataset), 2)
          dataset.set_random_state(1234)
          data1 = dataset[0]
          data2 = dataset[1]
  
          self.assertTupleEqual(data1[indices[0]].shape, expected_shape)
          self.assertTupleEqual(data1[indices[1]].shape, expected_shape)
          np.testing.assert_allclose(
              data1[indices[0]], data1[indices[1]]
          )
          self.assertTupleEqual(data2[indices[0]].shape, expected_shape)
          self.assertTupleEqual(data2[indices[1]].shape, expected_shape)
          np.testing.assert_allclose(
              data2[indices[0]], data2[indices[0]]
          )
  
          dataset = ArrayDataset(
              test_images,
              img_transform,
              test_segs,
              label_transform,
              test_labels,
              None,
          )
          dataset.set_random_state(1234)
          _ = dataset[0]
          data2_new = dataset[1]
          np.testing.assert_allclose(
              data2[indices[0]], data2_new[indices[0]], atol=1e-3
          )
  
file_path: MONAI/tests/test_arraydataset.py
imports: from __future__ import annotations
  import os
  import sys
  import tempfile
  import unittest
  import nibabel
  import numpy
  from parameterized import parameterized
  from torch.utils.data import DataLoader
  from monai.data import ArrayDataset
  from monai.transforms import Compose, EnsureChannelFirst, LoadImage, RandAdjustContrast, RandGaussianNoise, Spacing
label_desc: Use image node_id 1 for calling the TestArrayDataset obj's underlying member method code with example usage: obj.test_shape(img_transform, label_transform, indices, expected_shape) without return types