code: def _rap_music(
      evoked, forward, noise_cov, n_dipoles, return_residual, use_trap
  ):
      """RAP-/TRAP-MUSIC implementation."""
      info = evoked.info
      data = evoked.data
      times = evoked.times
  
      picks = _check_info_inv(
          info, forward, data_cov=None, noise_cov=noise_cov
      )
  
      data = data[picks]
  
      dipoles, explained_data = _apply_rap_music(
          data,
          info,
          times,
          forward,
          noise_cov,
          n_dipoles,
          picks,
          use_trap,
      )
  
      if return_residual:
          residual = evoked.copy().pick(
              [info["ch_names"][p] for p in picks]
          )
          residual.data -= explained_data
          active_projs = [
              p for p in residual.info["projs"] if p["active"]
          ]
          for p in active_projs:
              p["active"] = False
          residual.add_proj(active_projs, remove_existing=True)
          residual.apply_proj()
          return dipoles, residual
      else:
          return dipoles
  
file_path: mne-python/mne/beamformer/_rap_music.py
imports: import numpy
  from scipy import linalg
  from .._fiff.pick import pick_channels_forward, pick_info
  from ..fixes import _safe_svd
  from ..forward import convert_forward_solution, is_fixed_orient
  from ..inverse_sparse.mxne_inverse import _make_dipoles_sparse
  from ..minimum_norm.inverse import _log_exp_var
  from ..utils import _check_info_inv, fill_doc, logger, verbose
  from ._compute_beamformer import _prepare_beamformer_input
label_desc: Use image node_id 4 for calling a global function with example usage: _rap_music(evoked, forward, noise_cov, n_dipoles, return_residual, use_trap) and returns: dipoles,  residual, dipoles