code: def _post_process_mask(
      mask, affine, opening=2, connected=True, warning_msg=""
  ):
      """Perform post processing on mask.
  
      Performs opening and keep only largest connected component is
      ``connected=True``.
      """
      if opening:
          opening = int(opening)
          mask = binary_erosion(mask, iterations=opening)
      mask_any = mask.any()
      if not mask_any:
          warnings.warn(
              f"Computed an empty mask. {warning_msg}",
              _MaskWarning,
              stacklevel=2,
          )
      if connected and mask_any:
          mask = largest_connected_component(mask)
      if opening:
          mask = binary_dilation(mask, iterations=2 * opening)
          mask = binary_erosion(mask, iterations=opening)
      return mask, affine
  
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 4 for calling a global function with example usage: _post_process_mask(mask, affine, opening, connected, warning_msg) and returns: mask,  affine