code: def _apply_inverse(
      evoked,
      inverse_operator,
      lambda2,
      method,
      pick_ori,
      prepared,
      label,
      method_params,
      return_residual,
      use_cps,
  ):
      _validate_type(evoked, Evoked, "evoked")
      _check_reference(evoked, inverse_operator["info"]["ch_names"])
      _check_option("method", method, INVERSE_METHODS)
      _check_ori(
          pick_ori,
          inverse_operator["source_ori"],
          inverse_operator["src"],
      )
      #
      #   Set up the inverse according to the parameters
      #
      nave = evoked.nave
  
      _check_ch_names(inverse_operator, evoked.info)
  
      inv = _check_or_prepare(
          inverse_operator,
          nave,
          lambda2,
          method,
          method_params,
          prepared,
          copy="non-src",
      )
      del inverse_operator
  
      #
      #   Pick the correct channels from the data
      #
      sel = _pick_channels_inverse_operator(evoked.ch_names, inv)
      logger.info(
          'Applying inverse operator to "%s"...' % (evoked.comment,)
      )
      logger.info("    Picked %d channels from the data" % len(sel))
      logger.info("    Computing inverse...")
      K, noise_norm, vertno, source_nn = _assemble_kernel(
          inv, label, method, pick_ori, use_cps=use_cps
      )
      sol = np.dot(K, evoked.data[sel])  # apply imaging kernel
      logger.info("    Computing residual...")
      # x̂(t) = G ĵ(t) = C ** 1/2 U Π w(t)
      # where the diagonal matrix Π has elements πk = λk γk
      Pi = inv["sing"] * inv["reginv"]
      data_w = np.dot(
          inv["whitener"], np.dot(inv["proj"], evoked.data[sel])
      )  # C ** -0.5
      w_t = np.dot(inv["eigen_fields"]["data"], data_w)  # U.T @ data
      data_est = np.dot(
          inv["colorer"],  # C ** 0.5
          np.dot(
              inv["eigen_fields"]["data"].T, Pi[:, np.newaxis] * w_t
          ),  # U
      )
      data_est_w = np.dot(
          inv["whitener"], np.dot(inv["proj"], data_est)
      )
      _log_exp_var(data_w, data_est_w)
      if return_residual:
          residual = evoked.copy()
          residual.data[sel] -= data_est
      is_free_ori = (
          inv["source_ori"] == FIFF.FIFFV_MNE_FREE_ORI
          and pick_ori != "normal"
      )
  
      if is_free_ori and pick_ori != "vector":
          logger.info("    Combining the current components...")
          sol = combine_xyz(sol)
  
      if noise_norm is not None:
          logger.info("    %s..." % (method,))
          if is_free_ori and pick_ori == "vector":
              noise_norm = noise_norm.repeat(3, axis=0)
          sol *= noise_norm
  
      tstep = 1.0 / evoked.info["sfreq"]
      tmin = float(evoked.times[0])
      subject = _subject_from_inverse(inv)
      src_type = _get_src_type(inv["src"], vertno)
      stc = _make_stc(
          sol,
          vertno,
          tmin=tmin,
          tstep=tstep,
          subject=subject,
          vector=(pick_ori == "vector"),
          source_nn=source_nn,
          src_type=src_type,
      )
  
      return (stc, residual) if return_residual else stc
  
imports: from copy import deepcopy
  from math import sqrt
  import numpy
  from scipy import linalg
  from scipy.stats import chi2
  from .._fiff.constants import FIFF
  from .._fiff.matrix import _read_named_matrix, _transpose_named_matrix, write_named_matrix
  from .._fiff.open import fiff_open
  from .._fiff.pick import channel_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import _electrode_types, _needs_eeg_average_ref_proj, _read_proj, _write_proj, make_projector
  from .._fiff.tag import find_tag
  from .._fiff.tree import dir_tree_find
  from .._fiff.write import end_block, start_and_end_file, start_block, write_coord_trans, write_float, write_float_matrix, write_int, write_string
  from ..cov import Covariance, _read_cov, _write_cov, compute_whitener, prepare_noise_cov
  from ..epochs import BaseEpochs, EpochsArray
  from ..evoked import Evoked, EvokedArray
  from ..fixes import _safe_svd
  from ..forward import _read_forward_meas_info, _select_orient_forward, compute_depth_prior, compute_orient_prior, convert_forward_solution, is_fixed_orient
  from ..forward.forward import _triage_loose, write_forward_meas_info
  from ..html_templates import _get_html_template
  from ..io import BaseRaw
  from ..source_estimate import _get_src_type, _make_stc
  from ..source_space._source_space import _get_src_nn, _get_vertno, _read_source_spaces_from_tree, _write_source_spaces_to_fid, find_source_space_hemi, label_src_vertno_sel
  from ..surface import _normal_orth
  from ..time_frequency.tfr import _check_tfr_complex
  from ..transforms import _ensure_trans, transform_surface_to
  from ..utils import _check_compensation_grade, _check_depth, _check_fname, _check_option, _check_src_normal, _validate_type, _verbose_safe_false, check_fname, logger, repr_html, verbose, warn
  from ._eloreta import _compute_eloreta
label_desc: Use image node_id 15 for calling a global function with example usage: _apply_inverse(evoked, inverse_operator, lambda2, method, pick_ori, prepared, label, method_params, return_residual, use_cps) and returns: unknown