code: def _unmask_4d(X, mask, order="C"):
      """Take masked data and bring them back to 4D.
  
      Parameters
      ----------
      X : :class:`numpy.ndarray`
          Masked data. shape: (samples, features)
  
      mask : :class:`numpy.ndarray`
          Mask. mask.ndim must be equal to 4, and dtype *must* be bool.
  
      Returns
      -------
      data : :class:`numpy.ndarray`
          Unmasked data.
          Shape: (mask.shape[0], mask.shape[1], mask.shape[2], X.shape[0])
      """
      if mask.dtype != bool:
          raise TypeError("mask must be a boolean array")
      if X.ndim != 2:
          raise TypeError("X must be a 2-dimensional array")
      n_features = mask.sum()
      if X.shape[1] != n_features:
          raise TypeError(
              f"X must be of shape (samples, {n_features})."
          )
  
      data = np.zeros(
          mask.shape + (X.shape[0],), dtype=X.dtype, order=order
      )
      data[mask, :] = X.T
      return data
  
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 14 for calling a global function with example usage: _unmask_4d(X, mask, order) and returns: data