code: def make_forward_solution(
      info,
      trans,
      src,
      bem,
      meg=True,
      eeg=True,
      *,
      mindist=0.0,
      ignore_ref=False,
      n_jobs=None,
      verbose=None,
  ):
      """Calculate a forward solution for a subject.
  
      Parameters
      ----------
      %(info_str)s
      %(trans)s
  
          .. versionchanged:: 0.19
              Support for ``'fsaverage'`` argument.
      src : path-like | instance of SourceSpaces
          Either a path to a source space file or a loaded or generated
          :class:`~mne.SourceSpaces`.
      bem : path-like | ConductorModel
          Filename of the BEM (e.g., ``"sample-5120-5120-5120-bem-sol.fif"``) to
          use, or a loaded :class:`~mne.bem.ConductorModel`. See
          :func:`~mne.make_bem_model` and :func:`~mne.make_bem_solution` to create a
          :class:`mne.bem.ConductorModel`.
      meg : bool
          If True (default), include MEG computations.
      eeg : bool
          If True (default), include EEG computations.
      mindist : float
          Minimum distance of sources from inner skull surface (in mm).
      ignore_ref : bool
          If True, do not include reference channels in compensation. This
          option should be True for KIT files, since forward computation
          with reference channels is not currently supported.
      %(n_jobs)s
      %(verbose)s
  
      Returns
      -------
      fwd : instance of Forward
          The forward solution.
  
      See Also
      --------
      convert_forward_solution
  
      Notes
      -----
      The ``--grad`` option from MNE-C (to compute gradients) is not implemented
      here.
  
      To create a fixed-orientation forward solution, use this function
      followed by :func:`mne.convert_forward_solution`.
  
      .. note::
          If the BEM solution was computed with `OpenMEEG <https://openmeeg.github.io>`__
          in :func:`mne.make_bem_solution`, then OpenMEEG will automatically
          be used to compute the forward solution.
  
      .. versionchanged:: 1.2
         Added support for OpenMEEG-based forward solution calculations.
      """
      # Currently not (sup)ported:
      # 1. --grad option (gradients of the field, not used much)
      # 2. --fixed option (can be computed post-hoc)
      # 3. --mricoord option (probably not necessary)
  
      # read the transformation from MRI to HEAD coordinates
      # (could also be HEAD to MRI)
      mri_head_t, trans = _get_trans(trans)
      if isinstance(bem, ConductorModel):
          bem_extra = "instance of ConductorModel"
      else:
          bem_extra = bem
      _validate_type(info, ("path-like", Info), "info")
      if not isinstance(info, Info):
          info_extra = op.split(info)[1]
          info = _check_fname(
              info, must_exist=True, overwrite="read", name="info"
          )
          info = read_info(info, verbose=False)
      else:
          info_extra = "instance of Info"
  
      # Report the setup
      logger.info("Source space          : %s" % src)
      logger.info("MRI -> head transform : %s" % trans)
      logger.info("Measurement data      : %s" % info_extra)
      if isinstance(bem, ConductorModel) and bem["is_sphere"]:
          logger.info(
              "Sphere model      : origin at %s mm" % (bem["r0"],)
          )
          logger.info("Standard field computations")
      else:
          logger.info("Conductor model   : %s" % bem_extra)
          logger.info("Accurate field computations")
      logger.info(
          "Do computations in %s coordinates",
          _coord_frame_name(FIFF.FIFFV_COORD_HEAD),
      )
      logger.info("Free source orientations")
  
      # Create MEG coils and EEG electrodes in the head coordinate frame
      sensors, rr, info, update_kwargs, bem = _prepare_for_forward(
          src,
          mri_head_t,
          info,
          bem,
          mindist,
          n_jobs,
          bem_extra,
          trans,
          info_extra,
          meg,
          eeg,
          ignore_ref,
      )
      del (
          src,
          mri_head_t,
          trans,
          info_extra,
          bem_extra,
          mindist,
          meg,
          eeg,
          ignore_ref,
      )
  
      # Time to do the heavy lifting: MEG first, then EEG
      fwds = _compute_forwards(
          rr, bem=bem, sensors=sensors, n_jobs=n_jobs
      )
  
      # merge forwards
      fwds = {
          key: _to_forward_dict(fwds[key], sensors[key]["ch_names"])
          for key in _FWD_ORDER
          if key in fwds
      }
      fwd = _merge_fwds(fwds, verbose=False)
      del fwds
      logger.info("")
  
      # Don't transform the source spaces back into MRI coordinates (which is
      # done in the C code) because mne-python assumes forward solution source
      # spaces are in head coords.
      fwd.update(**update_kwargs)
      logger.info("Finished.")
      return fwd
  
imports: import os
  import os.path
  from contextlib import contextmanager
  from copy import deepcopy
  from pathlib import Path
  import numpy
  from .._fiff.compensator import get_current_comp, make_compensator
  from .._fiff.constants import FIFF, FWD
  from .._fiff.meas_info import Info, read_info
  from .._fiff.pick import _has_kit_refs, pick_info, pick_types
  from .._fiff.tag import _loc_to_coil_trans, _loc_to_eeg_loc
  from ..bem import ConductorModel, _bem_find_surface, read_bem_solution
  from ..source_estimate import VolSourceEstimate
  from ..source_space._source_space import _complete_vol_src, _ensure_src, _filter_source_spaces, _make_discrete_source_space
  from ..surface import _CheckInside, _normalize_vectors
  from ..transforms import Transform, _coord_frame_name, _ensure_trans, _get_trans, _print_coord_trans, apply_trans, invert_transform, transform_surface_to
  from ..utils import _check_fname, _pl, _validate_type, logger, verbose, warn
  from ._compute_forward import _compute_forwards
  from .forward import _FWD_ORDER, Forward, _merge_fwds, convert_forward_solution
label_desc: Use image node_id 12 for calling a global function with example usage: make_forward_solution(info, trans, src, bem, meg, eeg) and returns: fwd