code: def _bem_inf_fields(rr, rmag, cosmag):
      """Compute infinite-medium magnetic field at one MEG sensor.
  
      This operates on all dipoles in all 3 basis directions.
  
      Parameters
      ----------
      rr : ndarray, shape (n_source_points, 3)
          3D dipole source positions
      rmag : ndarray, shape (n_sensor points, 3)
          3D positions of 1 MEG coil's integration points (from coil['rmag'])
      cosmag : ndarray, shape (n_sensor_points, 3)
          Direction of 1 MEG coil's integration points (from coil['cosmag'])
  
      Returns
      -------
      ndarray, shape (n_dipoles, 3, n_integration_pts)
          Magnetic field from all dipoles at each MEG sensor integration point
      """
      # rr, rmag refactored according to Equation (19) in Mosher, 1999
      # Knowing that we're doing all directions, refactor above function:
  
      # rr, 3, rmag
      diff = rmag.T.reshape(1, 3, rmag.shape[0]) - rr.reshape(
          rr.shape[0], 3, 1
      )
      diff_norm = np.sum(diff * diff, axis=1)  # rr, rmag
      diff_norm *= np.sqrt(diff_norm)  # Get magnitude of distance cubed
      diff_norm_ = diff_norm.reshape(-1)
      diff_norm_[diff_norm_ == 0] = 1  # avoid nans
  
      # This is the result of cross-prod calcs with basis vectors,
      # as if we had taken (Q=np.eye(3)), then multiplied by cosmags
      # factor, and then summed across directions
      x = np.empty((rr.shape[0], 3, rmag.shape[0]))
      x[:, 0] = diff[:, 1] * cosmag[:, 2] - diff[:, 2] * cosmag[:, 1]
      x[:, 1] = diff[:, 2] * cosmag[:, 0] - diff[:, 0] * cosmag[:, 2]
      x[:, 2] = diff[:, 0] * cosmag[:, 1] - diff[:, 1] * cosmag[:, 0]
      diff_norm = diff_norm_.reshape((rr.shape[0], 1, rmag.shape[0]))
      x /= diff_norm
      # x.shape == (rr.shape[0], 3, rmag.shape[0])
      return x
  
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 9 for calling a global function with example usage: _bem_inf_fields(rr, rmag, cosmag) and returns: x