code: def _prepare_G(G, lambda2):
      G.flat[:: len(G) + 1] += lambda2
      # compute the CSD
      Gi = np.linalg.inv(G)
  
      TC = Gi.sum(0)
      sgi = np.sum(TC)  # compute sum total
  
      return Gi, TC, sgi
  
file_path: mne-python/mne/preprocessing/_csd.py
imports: import numpy
  from scipy.optimize import minimize_scalar
  from scipy.stats import gaussian_kde
  from .._fiff.constants import FIFF
  from .._fiff.pick import pick_types
  from ..bem import fit_sphere_to_headshape
  from ..channels.interpolation import _calc_g, _calc_h
  from ..epochs import BaseEpochs, make_fixed_length_epochs
  from ..evoked import Evoked
  from ..io import BaseRaw
  from ..utils import _check_preload, _ensure_int, _validate_type, logger, verbose
label_desc: Use image node_id 1 for calling a global function with example usage: _prepare_G(G, lambda2) and returns: Gi,  TC,  sgi