code: def _do_lin_field_coeff(
      bem_rr, tris, tn, ta, rmags, cosmags, ws, bins
  ):
      """Compute field coefficients (parallel-friendly).
  
      See section IV of Mosher et al., 1999 (specifically equation 35).
  
      Parameters
      ----------
      bem_rr : ndarray, shape (n_BEM_vertices, 3)
          Positions on one BEM surface in 3-space. 2562 BEM vertices for BEM with
          5120 triangles (ico-4)
      tris : ndarray, shape (n_BEM_vertices, 3)
          Vertex indices for each triangle (referring to bem_rr)
      tn : ndarray, shape (n_BEM_vertices, 3)
          Triangle unit normal vectors
      ta : ndarray, shape (n_BEM_vertices,)
          Triangle areas
      rmag : ndarray, shape (n_sensor_pts, 3)
          3D positions of MEG coil integration points (from coil['rmag'])
      cosmag : ndarray, shape (n_sensor_pts, 3)
          Direction of the MEG coil integration points (from coil['cosmag'])
      ws : ndarray, shape (n_sensor_pts,)
          Weights for MEG coil integration points
      bins : ndarray, shape (n_sensor_pts,)
          The sensor assignments for each rmag/cosmag/w.
  
      Returns
      -------
      coeff : ndarray, shape (n_MEG_sensors, n_BEM_vertices)
          Linear coefficients with effect of each BEM vertex on each sensor (?)
      """
      coeff = np.zeros((bins[-1] + 1, len(bem_rr)))
      w_cosmags = ws.reshape(-1, 1) * cosmags
      diff = rmags.reshape(rmags.shape[0], 1, rmags.shape[1]) - bem_rr
      den = np.sum(diff * diff, axis=-1)
      den *= np.sqrt(den)
      den *= 3
      for ti in range(len(tris)):
          tri, tri_nn, tri_area = tris[ti], tn[ti], ta[ti]
          # Accumulate the coefficients for each triangle node and add to the
          # corresponding coefficient matrix
  
          # Simple version (bem_lin_field_coeffs_simple)
          # The following is equivalent to:
          # tri_rr = bem_rr[tri]
          # for j, coil in enumerate(coils['coils']):
          #     x = func(coil['rmag'], coil['cosmag'],
          #              tri_rr, tri_nn, tri_area)
          #     res = np.sum(coil['w'][np.newaxis, :] * x, axis=1)
          #     coeff[j][tri + off] += mult * res
  
          c = np.empty((diff.shape[0], tri.shape[0], diff.shape[2]))
          _jit_cross(c, diff[:, tri], tri_nn)
          c *= w_cosmags.reshape(
              w_cosmags.shape[0], 1, w_cosmags.shape[1]
          )
          for ti in range(3):
              x = np.sum(c[:, ti], axis=-1)
              x /= den[:, tri[ti]] / tri_area
              coeff[:, tri[ti]] += bincount(
                  bins, weights=x, minlength=bins[-1] + 1
              )
      return coeff
  
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 4 for calling a global function with example usage: _do_lin_field_coeff(bem_rr, tris, tn, ta, rmags, cosmags, ws, bins) and returns: coeff