code: def test_masking(images):
      # generate synthetic mask randomly
      mask = np.random.randint(
          0, 2, size=(images[0].shape[-2], images[0].shape[-1])
      )
      idx_zeros = np.where(mask == 0)
      idx_ones = np.where(mask == 1)
      img_masked = mask_img_stack(images, mask)
      n_samples = len(images)
      for i in range(n_samples):
          n_phases = images[i].shape[0]
          for j in range(n_phases):
              img = img_masked[i][j, ...]
              testing.assert_equal(np.sum(img[idx_zeros]), 0)
              img_orig = images[i][j, ...]
              testing.assert_equal(img[idx_ones], img_orig[idx_ones])
  
file_path: pykale/tests/prepdata/test_image_transform.py
imports: import os
  import matplotlib.figure
  import numpy
  import pytest
  from numpy import testing
  from kale.interpret.visualize import plot_multi_images
  from kale.loaddata.image_access import check_dicom_series_uid, dicom2arraylist, read_dicom_dir
  from kale.prepdata.image_transform import mask_img_stack, normalize_img_stack, reg_img_stack, rescale_img_stack
label_desc: Use image node_id 5 for calling a global function with example usage: test_masking(images) without return types