code: def apply_mask_fmri(
      imgs, mask_img, dtype="f", smoothing_fwhm=None, ensure_finite=True
  ):
      """Perform similar action to :func:`nilearn.masking.apply_mask`.
  
      The only difference with :func:`nilearn.masking.apply_mask` is that
      some costly checks on ``mask_img`` are not performed: ``mask_img`` is
      assumed to contain only two different values (this is checked for in
      :func:`nilearn.masking.apply_mask`, not in this function).
      """
      mask_img = _utils.check_niimg_3d(mask_img)
      mask_affine = mask_img.affine
      mask_data = _utils.as_ndarray(get_data(mask_img), dtype=bool)
  
      if smoothing_fwhm is not None:
          ensure_finite = True
  
      imgs_img = _utils.check_niimg(imgs)
      affine = imgs_img.affine[:3, :3]
  
      if not np.allclose(mask_affine, imgs_img.affine):
          raise ValueError(
              f"Mask affine: \n{mask_affine}\n is different from img affine:"
              "\n{imgs_img.affine}"
          )
  
      if mask_data.shape != imgs_img.shape[:3]:
          raise ValueError(
              f"Mask shape: {str(mask_data.shape)} is different "
              f"from img shape:{str(imgs_img.shape[:3])}"
          )
  
      # All the following has been optimized for C order.
      # Time that may be lost in conversion here is regained multiple times
      # afterward, especially if smoothing is applied.
      series = safe_get_data(imgs_img)
  
      if dtype == "f":
          dtype = (
              series.dtype if series.dtype.kind == "f" else np.float32
          )
  
      series = _utils.as_ndarray(
          series, dtype=dtype, order="C", copy=True
      )
      del imgs_img  # frees a lot of memory
  
      # Delayed import to avoid circular imports
      from .image.image import smooth_array
  
      smooth_array(
          series,
          affine,
          fwhm=smoothing_fwhm,
          ensure_finite=ensure_finite,
          copy=False,
      )
      return series[mask_data].T
  
imports: import numbers
  import warnings
  import numpy
  from joblib import Parallel, delayed
  from scipy.ndimage import binary_dilation, binary_erosion
  from .None import _utils
  from ._utils import fill_doc
  from ._utils.cache_mixin import cache
  from ._utils.ndimage import get_border_data, largest_connected_component
  from ._utils.niimg import safe_get_data
  from .datasets import load_mni152_gm_template, load_mni152_template, load_mni152_wm_template
  from .image import get_data, new_img_like, resampling
label_desc: Use image node_id 12 for calling a global function with example usage: apply_mask_fmri(imgs, mask_img, dtype, smoothing_fwhm, ensure_finite) and returns: series