code: def _prepare_source_params(
      inst,
      inverse_operator,
      label=None,
      lambda2=1.0 / 9.0,
      method="dSPM",
      nave=1,
      pca=True,
      pick_ori="normal",
      prepared=False,
      method_params=None,
      use_cps=True,
  ):
      """Prepare inverse operator and params for spectral / TFR analysis."""
      inv = _check_or_prepare(
          inverse_operator,
          nave,
          lambda2,
          method,
          method_params,
          prepared,
      )
  
      #
      #   Pick the correct channels from the data
      #
      sel = _pick_channels_inverse_operator(inst.ch_names, inv)
      logger.info("Picked %d channels from the data" % len(sel))
      logger.info("Computing inverse...")
      #
      #   Simple matrix multiplication followed by combination of the
      #   three current components
      #
      #   This does all the data transformations to compute the weights for the
      #   eigenleads
      #
      # K shape: (3 x n_sources, n_channels) or (n_sources, n_channels)
      # noise_norm shape: (n_sources, 1)
      # vertno: [lh_verts, rh_verts]
  
      k_idxs = None
      if not isinstance(label, (Label, BiHemiLabel)):
          whole_K, whole_noise_norm, whole_vertno, _ = _assemble_kernel(
              inv, None, method, pick_ori, use_cps=use_cps
          )
          if isinstance(label, list):
              K, noise_norm, vertno, k_idxs = _restrict_K_to_lbls(
                  label,
                  whole_K,
                  whole_noise_norm,
                  whole_vertno,
                  pick_ori,
              )
          else:
              assert not label
              K, noise_norm, vertno = (
                  whole_K,
                  whole_noise_norm,
                  whole_vertno,
              )
      elif isinstance(label, (Label, BiHemiLabel)):
          K, noise_norm, vertno, _ = _assemble_kernel(
              inv, label, method, pick_ori, use_cps=use_cps
          )
  
      if pca:
          U, s, Vh = _safe_svd(K, full_matrices=False)
          rank = np.sum(s > 1e-8 * s[0])
          K = s[:rank] * U[:, :rank]
          Vh = Vh[:rank]
          logger.info("Reducing data rank %d -> %d" % (len(s), rank))
      else:
          Vh = None
      is_free_ori = (
          inverse_operator["source_ori"] == FIFF.FIFFV_MNE_FREE_ORI
      )
  
      return K, sel, Vh, vertno, is_free_ori, noise_norm, k_idxs
  
imports: import numpy
  from .._fiff.constants import FIFF
  from .._fiff.pick import pick_info
  from ..baseline import _log_rescale, rescale
  from ..epochs import Epochs
  from ..event import make_fixed_length_events
  from ..evoked import EvokedArray
  from ..fixes import _safe_svd
  from ..label import BiHemiLabel, Label
  from ..parallel import parallel_func
  from ..source_estimate import _make_stc
  from ..time_frequency.multitaper import _compute_mt_params, _mt_spectra, _psd_from_mt, _psd_from_mt_adaptive
  from ..time_frequency.tfr import cwt, morlet
  from ..utils import ProgressBar, _check_option, _pl, _validate_type, logger, verbose
  from .inverse import INVERSE_METHODS, _assemble_kernel, _check_or_prepare, _check_ori, _pick_channels_inverse_operator, _subject_from_inverse, combine_xyz
label_desc: Use image node_id 2 for calling a global function with example usage: _prepare_source_params(inst, inverse_operator, label, lambda2, method, nave, pca, pick_ori, prepared, method_params, use_cps) and returns: K,  sel,  Vh,  vertno,  is_free_ori,  noise_norm,  k_idxs