code: def _map_meg_or_eeg_channels(
      info_from, info_to, mode, origin, miss=None
  ):
      """Find mapping from one set of channels to another.
  
      Parameters
      ----------
      info_from : instance of Info
          The measurement data to interpolate from.
      info_to : instance of Info
          The measurement info to interpolate to.
      mode : str
          Either `'accurate'` or `'fast'`, determines the quality of the
          Legendre polynomial expansion used. `'fast'` should be sufficient
          for most applications.
      origin : array-like, shape (3,) | str
          Origin of the sphere in the head coordinate frame and in meters.
          Can be ``'auto'``, which means a head-digitization-based origin
          fit. Default is ``(0., 0., 0.04)``.
  
      Returns
      -------
      mapping : array, shape (n_to, n_from)
          A mapping matrix.
      """
      # no need to apply trans because both from and to coils are in device
      # coordinates
      info_kinds = set(ch["kind"] for ch in info_to["chs"])
      info_kinds |= set(ch["kind"] for ch in info_from["chs"])
      if FIFF.FIFFV_REF_MEG_CH in info_kinds:  # refs same as MEG
          info_kinds |= set([FIFF.FIFFV_MEG_CH])
          info_kinds -= set([FIFF.FIFFV_REF_MEG_CH])
      info_kinds = sorted(info_kinds)
      # This should be guaranteed by the callers
      assert len(info_kinds) == 1 and info_kinds[0] in (
          FIFF.FIFFV_MEG_CH,
          FIFF.FIFFV_EEG_CH,
      )
      kind = "eeg" if info_kinds[0] == FIFF.FIFFV_EEG_CH else "meg"
  
      #
      # Step 1. Prepare the coil definitions
      #
      if kind == "meg":
          templates = _read_coil_defs(verbose=False)
          coils_from = _create_meg_coils(
              info_from["chs"],
              "normal",
              info_from["dev_head_t"],
              templates,
          )
          coils_to = _create_meg_coils(
              info_to["chs"], "normal", info_to["dev_head_t"], templates
          )
          pinv_method = "tsvd"
          miss = 1e-4
      else:
          coils_from = _create_eeg_els(info_from["chs"])
          coils_to = _create_eeg_els(info_to["chs"])
          pinv_method = "tikhonov"
          miss = 1e-1
          if _has_eeg_average_ref_proj(
              info_from
          ) and not _has_eeg_average_ref_proj(info_to):
              raise RuntimeError(
                  "info_to must have an average EEG reference projector if "
                  "info_from has one"
              )
      origin = _check_origin(origin, info_from)
      #
      # Step 2. Calculate the dot products
      #
      int_rad, noise, lut_fun, n_fact = _setup_dots(
          mode, info_from, coils_from, kind
      )
      logger.info(
          f"    Computing dot products for {len(coils_from)} "
          f"{kind.upper()} channel{_pl(coils_from)}..."
      )
      self_dots = _do_self_dots(
          int_rad,
          False,
          coils_from,
          origin,
          kind,
          lut_fun,
          n_fact,
          n_jobs=None,
      )
      logger.info(
          f"    Computing cross products for {len(coils_from)} → "
          f"{len(coils_to)} {kind.upper()} channel{_pl(coils_to)}..."
      )
      cross_dots = _do_cross_dots(
          int_rad,
          False,
          coils_from,
          coils_to,
          origin,
          kind,
          lut_fun,
          n_fact,
      ).T
  
      ch_names = [c["ch_name"] for c in info_from["chs"]]
      fmd = dict(
          kind=kind,
          ch_names=ch_names,
          origin=origin,
          noise=noise,
          self_dots=self_dots,
          surface_dots=cross_dots,
          int_rad=int_rad,
          miss=miss,
          pinv_method=pinv_method,
      )
  
      #
      # Step 3. Compute the mapping matrix
      #
      mapping = _compute_mapping_matrix(fmd, info_from)
      return mapping
  
imports: import inspect
  from copy import deepcopy
  import numpy
  from scipy.interpolate import interp1d
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import _simplify_info
  from .._fiff.pick import pick_info, pick_types
  from .._fiff.proj import _has_eeg_average_ref_proj, make_projector
  from ..bem import _check_origin
  from ..cov import make_ad_hoc_cov
  from ..epochs import BaseEpochs, EpochsArray
  from ..evoked import Evoked, EvokedArray
  from ..fixes import _safe_svd
  from ..surface import get_head_surf, get_meg_helmet_surf
  from ..transforms import _find_trans, _get_trans, transform_surface_to
  from ..utils import _check_fname, _check_option, _pl, _reg_pinv, logger, verbose
  from ._lead_dots import _do_cross_dots, _do_self_dots, _do_surface_dots, _get_legen_table
  from ._make_forward import _create_eeg_els, _create_meg_coils, _read_coil_defs
label_desc: Use image node_id 5 for calling a global function with example usage: _map_meg_or_eeg_channels(info_from, info_to, mode, origin, miss) and returns: mapping