code: def test_unmask(rng, affine_eye, tmp_path):
      # A delta in 3D
      shape = (10, 20, 30, 40)
      data4D = rng.uniform(size=shape)
      data3D = data4D[..., 0]
      mask = rng.integers(2, size=shape[:3], dtype="int32")
      mask_img = Nifti1Image(mask, affine_eye)
      mask = mask.astype(bool)
  
      masked4D = data4D[mask, :].T
      unmasked4D = data4D.copy()
      unmasked4D[np.logical_not(mask), :] = 0
      masked3D = data3D[mask]
      unmasked3D = data3D.copy()
      unmasked3D[np.logical_not(mask)] = 0
  
      # 4D Test, test value ordering at the same time.
      t = get_data(unmask(masked4D, mask_img, order="C"))
      assert t.ndim == 4
      assert t.flags["C_CONTIGUOUS"]
      assert not t.flags["F_CONTIGUOUS"]
      assert_array_equal(t, unmasked4D)
      t = unmask([masked4D], mask_img, order="F")
      t = [get_data(t_) for t_ in t]
      assert isinstance(t, list)
      assert t[0].ndim == 4
      assert not t[0].flags["C_CONTIGUOUS"]
      assert t[0].flags["F_CONTIGUOUS"]
      assert_array_equal(t[0], unmasked4D)
  
      # 3D Test - check both with Nifti1Image and file
      for create_files in (False, True):
          filename = write_imgs_to_path(
              mask_img,
              file_path=tmp_path,
              create_files=create_files,
          )
          t = get_data(unmask(masked3D, filename, order="C"))
          assert t.ndim == 3
          assert t.flags["C_CONTIGUOUS"]
          assert not t.flags["F_CONTIGUOUS"]
          assert_array_equal(t, unmasked3D)
          t = unmask([masked3D], filename, order="F")
          t = [get_data(t_) for t_ in t]
          assert isinstance(t, list)
          assert t[0].ndim == 3
          assert not t[0].flags["C_CONTIGUOUS"]
          assert t[0].flags["F_CONTIGUOUS"]
          assert_array_equal(t[0], unmasked3D)
  
      # Error test: shape
      vec_1D = np.empty((500,), dtype=int)
      with pytest.raises(TypeError):
          unmask(vec_1D, mask_img)
      with pytest.raises(TypeError):
          unmask([vec_1D], mask_img)
  
      vec_2D = np.empty((500, 500), dtype=np.float64)
      with pytest.raises(TypeError):
          unmask(vec_2D, mask_img)
      with pytest.raises(TypeError):
          unmask([vec_2D], mask_img)
  
      # Error test: mask type
      with pytest.raises(
          TypeError, match="mask must be a boolean array"
      ):
          _unmask_3d(vec_1D, mask.astype(int))
      with pytest.raises(
          TypeError, match="mask must be a boolean array"
      ):
          _unmask_4d(vec_2D, mask.astype(np.float64))
  
      # Transposed vector
      transposed_vector = np.ones((np.sum(mask), 1), dtype=bool)
      with pytest.raises(TypeError, match="X must be of shape"):
          unmask(transposed_vector, mask_img)
  
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 10 for calling a global function with example usage: test_unmask(rng, affine_eye, tmp_path) without return types