code: def apply_mask(
      imgs, mask_img, dtype="f", smoothing_fwhm=None, ensure_finite=True
  ):
      """Extract signals from images using specified mask.
  
      Read the time series from the given Niimg-like object, using the mask.
  
      Parameters
      ----------
      imgs : :obj:`list` of 4D Niimg-like objects
          See :ref:`extracting_data`.
          Images to be masked. list of lists of 3D images are also accepted.
  
      mask_img : Niimg-like object
          See :ref:`extracting_data`.
          3D mask array: True where a :term:`voxel` should be used.
  
      dtype: numpy dtype or 'f'
          The dtype of the output, if 'f', any float output is acceptable
          and if the data is stored on the disk as floats the data type
          will not be changed.
      %(smoothing_fwhm)s
  
          .. note::
  
              Implies ensure_finite=True.
  
      ensure_finite : :obj:`bool`, default=True
          If ensure_finite is True, the non-finite values (NaNs and
          infs) found in the images will be replaced by zeros.
  
      Returns
      -------
      run_series : :class:`numpy.ndarray`
          2D array of series with shape (image number, :term:`voxel` number)
  
      Notes
      -----
      When using smoothing, ``ensure_finite`` is set to True, as non-finite
      values would spread across the image.
      """
      mask_img = _utils.check_niimg_3d(mask_img)
      mask, mask_affine = load_mask_img(mask_img)
      mask_img = new_img_like(mask_img, mask, mask_affine)
      return apply_mask_fmri(
          imgs,
          mask_img,
          dtype=dtype,
          smoothing_fwhm=smoothing_fwhm,
          ensure_finite=ensure_finite,
      )
  
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 11 for calling a global function with example usage: apply_mask(imgs, mask_img, dtype, smoothing_fwhm, ensure_finite) and returns: apply_mask_fmri