code: def test_intersect_masks(affine_eye):
      """Test the intersect_masks function."""
      # Create dummy masks
      mask_a = np.zeros((4, 4, 1), dtype=bool)
      mask_a[2:4, 2:4] = 1
      mask_a_img = Nifti1Image(mask_a.astype("int32"), affine_eye)
  
      # +---+---+---+---+
      # |   |   |   |   |
      # +---+---+---+---+
      # |   |   |   |   |
      # +---+---+---+---+
      # |   |   | X | X |
      # +---+---+---+---+
      # |   |   | X | X |
      # +---+---+---+---+
  
      mask_b = np.zeros((4, 4, 1), dtype=bool)
      mask_b[1:3, 1:3] = 1
      mask_b_img = Nifti1Image(mask_b.astype("int32"), affine_eye)
  
      # +---+---+---+---+
      # |   |   |   |   |
      # +---+---+---+---+
      # |   | X | X |   |
      # +---+---+---+---+
      # |   | X | X |   |
      # +---+---+---+---+
      # |   |   |   |   |
      # +---+---+---+---+
  
      mask_c = np.zeros((4, 4, 1), dtype=bool)
      mask_c[:, 2] = 1
      mask_c[0, 0] = 1
      mask_c_img = Nifti1Image(mask_c.astype("int32"), affine_eye)
  
      # +---+---+---+---+
      # | X |   | X |   |
      # +---+---+---+---+
      # |   |   | X |   |
      # +---+---+---+---+
      # |   |   | X |   |
      # +---+---+---+---+
      # |   |   | X |   |
      # +---+---+---+---+
  
      mask_ab = np.zeros((4, 4, 1), dtype=bool)
      mask_ab[2, 2] = 1
      mask_ab_ = intersect_masks(
          [mask_a_img, mask_b_img], threshold=1.0
      )
      assert_array_equal(mask_ab, get_data(mask_ab_))
      # Test intersect mask images with '>f8'. This function uses
      # largest_connected_component to check if intersect_masks passes with
      # connected=True (which is by default)
      mask_a_img_change_dtype = Nifti1Image(
          get_data(mask_a_img).astype(">f8"), affine=mask_a_img.affine
      )
      mask_b_img_change_dtype = Nifti1Image(
          get_data(mask_b_img).astype(">f8"), affine=mask_b_img.affine
      )
      mask_ab_change_type = intersect_masks(
          [mask_a_img_change_dtype, mask_b_img_change_dtype],
          threshold=1.0,
      )
      assert_array_equal(mask_ab, get_data(mask_ab_change_type))
  
      mask_abc = mask_a + mask_b + mask_c
      mask_abc_ = intersect_masks(
          [mask_a_img, mask_b_img, mask_c_img],
          threshold=0.0,
          connected=False,
      )
      assert_array_equal(mask_abc, get_data(mask_abc_))
  
      mask_abc[0, 0] = 0
      mask_abc_ = intersect_masks(
          [mask_a_img, mask_b_img, mask_c_img], threshold=0.0
      )
      assert_array_equal(mask_abc, get_data(mask_abc_))
  
      mask_abc = mask_ab
      mask_abc_ = intersect_masks(
          [mask_a_img, mask_b_img, mask_c_img], threshold=1.0
      )
      assert_array_equal(mask_abc, get_data(mask_abc_))
  
      mask_abc[1, 2] = 1
      mask_abc[3, 2] = 1
      mask_abc_ = intersect_masks([mask_a_img, mask_b_img, mask_c_img])
      assert_array_equal(mask_abc, get_data(mask_abc_))
  
imports: import warnings
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_array_equal
  from sklearn.preprocessing import StandardScaler
  from nilearn import masking
  from nilearn._utils import data_gen
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.testing import write_imgs_to_path
  from nilearn.conftest import _rng
  from nilearn.image import get_data, high_variance_confounds
  from nilearn.maskers import NiftiMasker
  from nilearn.masking import _MaskWarning, _unmask_3d, _unmask_4d, compute_background_mask, compute_brain_mask, compute_epi_mask, compute_multi_brain_mask, compute_multi_epi_mask, extrapolate_out_mask, intersect_masks, unmask, unmask_from_to_3d_array
label_desc: Use image node_id 12 for calling a global function with example usage: test_intersect_masks(affine_eye) without return types