code: def _prep_field_computation(
      rr, *, sensors, bem, n_jobs, verbose=None
  ):
      """Precompute and store some things that are used for both MEG and EEG.
  
      Calculation includes multiplication factors, coordinate transforms,
      compensations, and forward solutions. All are stored in modified fwd_data.
  
      Parameters
      ----------
      rr : ndarray, shape (n_dipoles, 3)
          3D dipole source positions in head coordinates
      bem : instance of ConductorModel
          Boundary Element Model information
      fwd_data : dict
          Dict containing sensor information in the head coordinate frame.
          Gets updated here with BEM and sensor information for later forward
          calculations.
      %(n_jobs)s
      %(verbose)s
      """
      bem_rr = mults = mri_Q = head_mri_t = None
      if not bem["is_sphere"]:
          if bem["bem_method"] != FIFF.FIFFV_BEM_APPROX_LINEAR:
              raise RuntimeError("only linear collocation supported")
          # Store (and apply soon) μ_0/(4π) factor before source computations
          mults = np.repeat(
              bem["source_mult"] / (4.0 * np.pi),
              [len(s["rr"]) for s in bem["surfs"]],
          )[np.newaxis, :]
          # Get positions of BEM points for every surface
          bem_rr = np.concatenate([s["rr"] for s in bem["surfs"]])
  
          # The dipole location and orientation must be transformed
          head_mri_t = bem["head_mri_t"]
          mri_Q = bem["head_mri_t"]["trans"][:3, :3].T
  
      solutions = dict()
      for coil_type in sensors:
          coils = sensors[coil_type]["defs"]
          if not bem["is_sphere"]:
              if coil_type == "meg":
                  # MEG field computation matrices for BEM
                  start = "Composing the field computation matrix"
                  logger.info("\n" + start + "...")
                  cf = FIFF.FIFFV_COORD_HEAD
                  # multiply solution by "mults" here for simplicity
                  solution = _bem_specify_coils(
                      bem, coils, cf, mults, n_jobs
                  )
              else:
                  # Compute solution for EEG sensor
                  logger.info("Setting up for EEG...")
                  solution = _bem_specify_els(bem, coils, mults)
          else:
              solution = bem
              if coil_type == "eeg":
                  logger.info(
                      "Using the equivalent source approach in the "
                      "homogeneous sphere for EEG"
                  )
          sensors[coil_type]["defs"] = _triage_coils(coils)
          solutions[coil_type] = solution
  
      # Get appropriate forward physics function depending on sphere or BEM model
      fun = (
          _sphere_pot_or_field
          if bem["is_sphere"]
          else _bem_pot_or_field
      )
  
      # Update fwd_data with
      #    bem_rr (3D BEM vertex positions)
      #    mri_Q (3x3 Head->MRI coord transformation applied to identity matrix)
      #    head_mri_t (head->MRI coord transform dict)
      #    fun (_bem_pot_or_field if not 'sphere'; otherwise _sph_pot_or_field)
      #    solutions (len 2 list; [ndarray, shape (n_MEG_sens, n BEM vertices),
      #                            ndarray, shape (n_EEG_sens, n BEM vertices)]
      fwd_data = dict(
          bem_rr=bem_rr,
          mri_Q=mri_Q,
          head_mri_t=head_mri_t,
          fun=fun,
          solutions=solutions,
      )
      return fwd_data
  
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 21 for calling a global function with example usage: _prep_field_computation(rr) and returns: fwd_data