code: def _compute_mapping_matrix(fmd, info):
      """Do the hairy computations."""
      logger.info("    Preparing the mapping matrix...")
      # assemble a projector and apply it to the data
      ch_names = fmd["ch_names"]
      projs = info.get("projs", list())
      proj_op = make_projector(projs, ch_names)[0]
      proj_dots = np.dot(proj_op.T, np.dot(fmd["self_dots"], proj_op))
  
      noise_cov = fmd["noise"]
      # Whiten
      if not noise_cov["diag"]:
          raise NotImplementedError  # this shouldn't happen
      whitener = np.diag(1.0 / np.sqrt(noise_cov["data"].ravel()))
      whitened_dots = np.dot(whitener.T, np.dot(proj_dots, whitener))
  
      # SVD is numerically better than the eigenvalue composition even if
      # mat is supposed to be symmetric and positive definite
      if fmd.get("pinv_method", "tsvd") == "tsvd":
          inv, fmd["nest"] = _pinv_trunc(whitened_dots, fmd["miss"])
      else:
          assert fmd["pinv_method"] == "tikhonov", fmd["pinv_method"]
          inv, fmd["nest"] = _pinv_tikhonov(whitened_dots, fmd["miss"])
  
      # Sandwich with the whitener
      inv_whitened = np.dot(whitener.T, np.dot(inv, whitener))
  
      # Take into account that the lead fields used to compute
      # d->surface_dots were unprojected
      inv_whitened_proj = proj_op.T @ inv_whitened
  
      # Finally sandwich in the selection matrix
      # This one picks up the correct lead field projection
      mapping_mat = np.dot(fmd["surface_dots"], inv_whitened_proj)
  
      # Optionally apply the average electrode reference to the final field map
      if fmd["kind"] == "eeg" and _has_eeg_average_ref_proj(info):
          logger.info(
              "    The map has an average electrode reference "
              f"({mapping_mat.shape[0]} channels)"
          )
          mapping_mat -= np.mean(mapping_mat, axis=0)
      return mapping_mat
  
imports: import inspect
  from copy import deepcopy
  import numpy
  from scipy.interpolate import interp1d
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import _simplify_info
  from .._fiff.pick import pick_info, pick_types
  from .._fiff.proj import _has_eeg_average_ref_proj, make_projector
  from ..bem import _check_origin
  from ..cov import make_ad_hoc_cov
  from ..epochs import BaseEpochs, EpochsArray
  from ..evoked import Evoked, EvokedArray
  from ..fixes import _safe_svd
  from ..surface import get_head_surf, get_meg_helmet_surf
  from ..transforms import _find_trans, _get_trans, transform_surface_to
  from ..utils import _check_fname, _check_option, _pl, _reg_pinv, logger, verbose
  from ._lead_dots import _do_cross_dots, _do_self_dots, _do_surface_dots, _get_legen_table
  from ._make_forward import _create_eeg_els, _create_meg_coils, _read_coil_defs
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_mapping_matrix(fmd, info) and returns: mapping_mat