code: def _split_gof(M, X, gain):
      # parse out the variance explained using an orthogonal basis
      # assuming x is estimated using elements of gain, with residual res
      # along the first axis
      assert M.ndim == X.ndim == gain.ndim == 2, (
          M.ndim,
          X.ndim,
          gain.ndim,
      )
      assert gain.shape == (M.shape[0], X.shape[0])
      assert M.shape[1] == X.shape[1]
      norm = (M * M.conj()).real.sum(0, keepdims=True)
      norm[norm == 0] = np.inf
      M_est = gain @ X
      assert M.shape == M_est.shape
      res = M - M_est
      assert gain.shape[0] == M.shape[0], (gain.shape, M.shape)
      # find an orthonormal basis for our matrices that spans the actual data
      U, s, _ = np.linalg.svd(gain, full_matrices=False)
      if U.shape[1] > 0:
          U = U[:, s >= s[0] * 1e-6]
      # the part that gets explained
      fit_orth = U.T @ M
      # the part that got over-explained (landed in residual)
      res_orth = U.T @ res
      # determine the weights by projecting each one onto this basis
      w = (U.T @ gain)[:, :, np.newaxis] * X
      w_norm = np.linalg.norm(w, axis=1, keepdims=True)
      w_norm[w_norm == 0] = 1.0
      w /= w_norm
      # our weights are now unit-norm positive (will presrve power)
      fit_back = (
          np.linalg.norm(fit_orth[:, np.newaxis] * w, axis=0) ** 2
      )
      res_back = (
          np.linalg.norm(res_orth[:, np.newaxis] * w, axis=0) ** 2
      )
      # and the resulting goodness of fits
      gof_back = 100 * (fit_back - res_back) / norm
      assert gof_back.shape == X.shape, (gof_back.shape, X.shape)
      return gof_back
  
imports: import numpy
  from .._fiff.proj import deactivate_proj
  from ..dipole import Dipole
  from ..fixes import _safe_svd
  from ..forward import is_fixed_orient
  from ..minimum_norm.inverse import _check_reference, _log_exp_var, _prepare_forward, combine_xyz
  from ..source_estimate import SourceEstimate, _BaseSourceEstimate, _make_stc
  from ..utils import _check_depth, _check_option, _validate_type, check_random_state, logger, sum_squared, verbose, warn
  from .mxne_optim import _Phi, groups_norm2, iterative_mixed_norm_solver, iterative_tf_mixed_norm_solver, mixed_norm_solver, norm_epsilon_inf, norm_l2inf, tf_mixed_norm_solver
label_desc: Use image node_id 7 for calling a global function with example usage: _split_gof(M, X, gain) and returns: gof_back