code: def _compute_forwards_openmeeg(rr, *, bem, sensors):
      """Compute the MEG and EEG forward solutions for OpenMEEG."""
      if len(bem["surfs"]) != 3:
          raise RuntimeError(
              "Only 3-layer BEM is supported for OpenMEEG."
          )
      om = _import_openmeeg("compute a forward solution using OpenMEEG")
      hminv = om.SymMatrix(bem["solution"])
      geom = _make_openmeeg_geometry(
          bem, invert_transform(bem["head_mri_t"])
      )
  
      # Make dipoles for all XYZ orientations
      dipoles = np.c_[
          np.kron(rr.T, np.ones(3)[None, :]).T,
          np.kron(np.ones(len(rr))[:, None], np.eye(3)),
      ]
      dipoles = np.asfortranarray(dipoles)
      dipoles = om.Matrix(dipoles)
      dsm = om.DipSourceMat(geom, dipoles, "Brain")
      Bs = dict()
      if "eeg" in sensors:
          rmags, _, ws, bins = _concatenate_coils(
              sensors["eeg"]["defs"]
          )
          rmags = np.asfortranarray(rmags.astype(np.float64))
          eeg_sensors = om.Sensors(
              om.Matrix(np.asfortranarray(rmags)), geom
          )
          h2em = om.Head2EEGMat(geom, eeg_sensors)
          eeg_fwd_full = om.GainEEG(hminv, dsm, h2em).array()
          Bs["eeg"] = np.array(
              [
                  bincount(bins, ws * x, bins[-1] + 1)
                  for x in eeg_fwd_full.T
              ],
              float,
          )
      if "meg" in sensors:
          rmags, cosmags, ws, bins = _concatenate_coils(
              sensors["meg"]["defs"]
          )
          rmags = np.asfortranarray(rmags.astype(np.float64))
          cosmags = np.asfortranarray(cosmags.astype(np.float64))
          labels = [str(ii) for ii in range(len(rmags))]
          weights = radii = np.ones(len(labels))
          meg_sensors = om.Sensors(
              labels, rmags, cosmags, weights, radii
          )
          h2mm = om.Head2MEGMat(geom, meg_sensors)
          ds2mm = om.DipSource2MEGMat(dipoles, meg_sensors)
          meg_fwd_full = om.GainMEG(hminv, dsm, h2mm, ds2mm).array()
          B = np.array(
              [
                  bincount(bins, ws * x, bins[-1] + 1)
                  for x in meg_fwd_full.T
              ],
              float,
          )
          compensator = sensors["meg"].get("compensator", None)
          post_picks = sensors["meg"].get("post_picks", None)
          if compensator is not None:
              B = B @ compensator.T
          if post_picks is not None:
              B = B[:, post_picks]
          Bs["meg"] = B
      return Bs
  
imports: from copy import deepcopy
  import numpy
  from .._fiff.constants import FIFF
  from ..bem import _import_openmeeg, _make_openmeeg_geometry
  from ..fixes import bincount, jit
  from ..parallel import parallel_func
  from ..surface import _jit_cross, _project_onto_surface
  from ..transforms import apply_trans, invert_transform
  from ..utils import _check_option, _pl, fill_doc, logger, verbose, warn
label_desc: Use image node_id 24 for calling a global function with example usage: _compute_forwards_openmeeg(rr) and returns: Bs