code: def apply_inverse_raw(
      raw,
      inverse_operator,
      lambda2,
      method="dSPM",
      label=None,
      start=None,
      stop=None,
      nave=1,
      time_func=None,
      pick_ori=None,
      buffer_size=None,
      prepared=False,
      method_params=None,
      use_cps=True,
      verbose=None,
  ):
      """Apply inverse operator to Raw data.
  
      Parameters
      ----------
      raw : Raw object
          Raw data.
      inverse_operator : dict
          Inverse operator.
      lambda2 : float
          The regularization parameter.
      method : "MNE" | "dSPM" | "sLORETA" | "eLORETA"
          Use minimum norm, dSPM (default), sLORETA, or eLORETA.
      label : Label | None
          Restricts the source estimates to a given label. If None,
          source estimates will be computed for the entire source space.
      start : int
          Index of first time sample (index not time is seconds).
      stop : int
          Index of first time sample not to include (index not time is seconds).
      nave : int
          Number of averages used to regularize the solution.
          Set to 1 on raw data.
      time_func : callable
          Linear function applied to sensor space time series.
      %(pick_ori)s
      buffer_size : int (or None)
          If not None, the computation of the inverse and the combination of the
          current components is performed in segments of length buffer_size
          samples. While slightly slower, this is useful for long datasets as it
          reduces the memory requirements by approx. a factor of 3 (assuming
          buffer_size << data length).
          Note that this setting has no effect for fixed-orientation inverse
          operators.
      prepared : bool
          If True, do not call :func:`prepare_inverse_operator`.
      method_params : dict | None
          Additional options for eLORETA. See Notes of :func:`apply_inverse`.
  
          .. versionadded:: 0.16
      %(use_cps_restricted)s
  
          .. versionadded:: 0.20
      %(verbose)s
  
      Returns
      -------
      stc : SourceEstimate | VectorSourceEstimate | VolSourceEstimate
          The source estimates.
  
      See Also
      --------
      apply_inverse : Apply inverse operator to evoked object.
      apply_inverse_epochs : Apply inverse operator to epochs object.
      apply_inverse_tfr_epochs : Apply inverse operator to epochs tfr object.
      apply_inverse_cov : Apply inverse operator to covariance object.
      """
      _validate_type(raw, BaseRaw, "raw")
      _check_reference(raw, inverse_operator["info"]["ch_names"])
      _check_option("method", method, INVERSE_METHODS)
      _check_ori(
          pick_ori,
          inverse_operator["source_ori"],
          inverse_operator["src"],
      )
      _check_ch_names(inverse_operator, raw.info)
  
      #
      #   Set up the inverse according to the parameters
      #
      inv = _check_or_prepare(
          inverse_operator,
          nave,
          lambda2,
          method,
          method_params,
          prepared,
      )
  
      #
      #   Pick the correct channels from the data
      #
      sel = _pick_channels_inverse_operator(raw.ch_names, inv)
      logger.info("Applying inverse to raw...")
      logger.info("    Picked %d channels from the data" % len(sel))
      logger.info("    Computing inverse...")
  
      data, times = raw[sel, start:stop]
  
      if time_func is not None:
          data = time_func(data)
  
      K, noise_norm, vertno, source_nn = _assemble_kernel(
          inv, label, method, pick_ori, use_cps
      )
  
      is_free_ori = (
          inverse_operator["source_ori"] == FIFF.FIFFV_MNE_FREE_ORI
          and pick_ori != "normal"
      )
  
      if buffer_size is not None and is_free_ori:
          # Process the data in segments to conserve memory
          n_seg = int(np.ceil(data.shape[1] / float(buffer_size)))
          logger.info(
              "    computing inverse and combining the current "
              "components (using %d segments)..." % (n_seg)
          )
  
          # Allocate space for inverse solution
          n_times = data.shape[1]
  
          n_dipoles = (
              K.shape[0] if pick_ori == "vector" else K.shape[0] // 3
          )
          sol = np.empty(
              (n_dipoles, n_times), dtype=np.result_type(K, data)
          )
  
          for pos in range(0, n_times, buffer_size):
              sol_chunk = np.dot(K, data[:, pos : pos + buffer_size])
              if pick_ori != "vector":
                  sol_chunk = combine_xyz(sol_chunk)
              sol[:, pos : pos + buffer_size] = sol_chunk
  
              logger.info(
                  "        segment %d / %d done.."
                  % (pos / buffer_size + 1, n_seg)
              )
      else:
          sol = np.dot(K, data)
          if is_free_ori and pick_ori != "vector":
              logger.info("    combining the current components...")
              sol = combine_xyz(sol)
      if noise_norm is not None:
          if pick_ori == "vector" and is_free_ori:
              noise_norm = noise_norm.repeat(3, axis=0)
          sol *= noise_norm
  
      tmin = float(times[0])
      tstep = 1.0 / raw.info["sfreq"]
      subject = _subject_from_inverse(inverse_operator)
      src_type = _get_src_type(inverse_operator["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,
      )
      logger.info("[done]")
  
      return 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 16 for calling a global function with example usage: apply_inverse_raw(raw, inverse_operator, lambda2, method, label, start, stop, nave, time_func, pick_ori, buffer_size, prepared, method_params, use_cps, verbose) and returns: stc