code: def test_check_embedded_masker():
      owner = OwningClass()
      masker = check_embedded_masker(owner)
      assert type(masker) is MultiNiftiMasker
  
      for mask, masker_type in (
          (MultiNiftiMasker(), "multi_nii"),
          (NiftiMasker(), "nii"),
          (SurfaceMasker(), "surface"),
      ):
          owner = OwningClass(mask=mask)
          masker = check_embedded_masker(owner, masker_type=masker_type)
          assert isinstance(masker, type(mask))
          for param_key in masker.get_params():
              if param_key not in [
                  "memory",
                  "memory_level",
                  "n_jobs",
                  "verbose",
              ]:
                  assert getattr(masker, param_key) == getattr(
                      mask, param_key
                  )
              else:
                  assert getattr(masker, param_key) == getattr(
                      owner, param_key
                  )
  
      # Check use of mask as mask_img
      shape = (6, 8, 10, 5)
      affine = np.eye(4)
      mask = nibabel.Nifti1Image(
          np.ones(shape[:3], dtype=np.int8), affine
      )
      owner = OwningClass(mask=mask)
      masker = check_embedded_masker(owner)
      assert masker.mask_img is mask
  
      # Check attribute forwarding
      data = np.zeros((9, 9, 9))
      data[2:-2, 2:-2, 2:-2] = 10
      imgs = nibabel.Nifti1Image(data, np.eye(4))
      mask = MultiNiftiMasker()
      mask.fit([[imgs]])
      owner = OwningClass(mask=mask)
      masker = check_embedded_masker(owner)
      assert masker.mask_img is mask.mask_img_
  
      # Check conflict warning
      mask = NiftiMasker(mask_strategy="epi")
      owner = OwningClass(mask=mask)
      with pytest.warns(UserWarning):
          check_embedded_masker(owner)
  
file_path: nilearn/nilearn/_utils/tests/test_masker_validation.py
imports: import nibabel
  import numpy
  import pytest
  from joblib import Memory
  from sklearn.base import BaseEstimator
  from nilearn._utils.masker_validation import check_embedded_masker
  from nilearn.experimental.surface import SurfaceMasker
  from nilearn.maskers import MultiNiftiMasker, NiftiMasker
label_desc: Use image node_id 2 for calling a global function with example usage: test_check_embedded_masker() without return types