code: def _fast_sphere_dot_r0(
      r,
      rr1_orig,
      rr2s,
      lr1,
      lr2s,
      cosmags1,
      cosmags2s,
      w1,
      w2s,
      volume_integral,
      lut,
      n_fact,
      ch_type,
  ):
      """Lead field dot product computation for M/EEG in the sphere model.
  
      Parameters
      ----------
      r : float
          The integration radius. It is used to calculate beta as:
          beta = (r * r) / (lr1 * lr2).
      rr1 : array, shape (n_points x 3)
          Normalized position vectors of integrations points in first sensor.
      rr2s : list
          Normalized position vector of integration points in second sensor.
      lr1 : array, shape (n_points x 1)
          Magnitude of position vector of integration points in first sensor.
      lr2s : list
          Magnitude of position vector of integration points in second sensor.
      cosmags1 : array, shape (n_points x 1)
          Direction of integration points in first sensor.
      cosmags2s : list
          Direction of integration points in second sensor.
      w1 : array, shape (n_points x 1) | None
          Weights of integration points in the first sensor.
      w2s : list
          Weights of integration points in the second sensor.
      volume_integral : bool
          If True, compute volume integral.
      lut : callable
          Look-up table for evaluating Legendre polynomials.
      n_fact : array
          Coefficients in the integration sum.
      ch_type : str
          The channel type. It can be 'meg' or 'eeg'.
  
      Returns
      -------
      result : float
          The integration sum.
      """
      if w1 is None:  # operating on surface, treat independently
          out_shape = (len(rr2s), len(rr1_orig))
          sum_axis = 1  # operate along second axis only at the end
      else:
          out_shape = (len(rr2s),)
          sum_axis = None  # operate on flattened array at the end
      out = np.empty(out_shape)
      rr2 = np.concatenate(rr2s)
      lr2 = np.concatenate(lr2s)
      cosmags2 = np.concatenate(cosmags2s)
  
      # outer product, sum over coords
      ct = np.einsum("ik,jk->ij", rr1_orig, rr2)
      np.clip(ct, -1, 1, ct)
  
      # expand axes
      rr1 = rr1_orig[
          :, np.newaxis, :
      ]  # (n_rr1, n_rr2, n_coord) e.g. 4x4x3
      rr2 = rr2[np.newaxis, :, :]
      lr1lr2 = lr1[:, np.newaxis] * lr2[np.newaxis, :]
  
      beta = (r * r) / lr1lr2
      if ch_type == "meg":
          sums = _comp_sums_meg(
              beta.flatten(), ct.flatten(), lut, n_fact, volume_integral
          )
          sums.shape = (4,) + beta.shape
  
          # Accumulate the result, a little bit streamlined version
          # cosmags1 = cosmags1[:, np.newaxis, :]
          # cosmags2 = cosmags2[np.newaxis, :, :]
          # n1c1 = np.sum(cosmags1 * rr1, axis=2)
          # n1c2 = np.sum(cosmags1 * rr2, axis=2)
          # n2c1 = np.sum(cosmags2 * rr1, axis=2)
          # n2c2 = np.sum(cosmags2 * rr2, axis=2)
          # n1n2 = np.sum(cosmags1 * cosmags2, axis=2)
          n1c1 = np.einsum("ik,ijk->ij", cosmags1, rr1)
          n1c2 = np.einsum("ik,ijk->ij", cosmags1, rr2)
          n2c1 = np.einsum("jk,ijk->ij", cosmags2, rr1)
          n2c2 = np.einsum("jk,ijk->ij", cosmags2, rr2)
          n1n2 = np.einsum("ik,jk->ij", cosmags1, cosmags2)
          part1 = ct * n1c1 * n2c2
          part2 = n1c1 * n2c1 + n1c2 * n2c2
  
          result = (
              n1c1 * n2c2 * sums[0]
              + (2.0 * part1 - part2) * sums[1]
              + (n1n2 + part1 - part2) * sums[2]
              + (n1c2 - ct * n1c1) * (n2c1 - ct * n2c2) * sums[3]
          )
  
          # Give it a finishing touch!
          result *= _meg_const / lr1lr2
          if volume_integral:
              result *= r
      else:  # 'eeg'
          result = _comp_sum_eeg(
              beta.flatten(), ct.flatten(), lut, n_fact
          )
          result.shape = beta.shape
          # Give it a finishing touch!
          result *= _eeg_const
          result /= lr1lr2
          # now we add them all up with weights
      offset = 0
      result *= np.concatenate(w2s)
      if w1 is not None:
          result *= w1[:, np.newaxis]
      for ii, w2 in enumerate(w2s):
          out[ii] = np.sum(
              result[:, offset : offset + len(w2)], axis=sum_axis
          )
          offset += len(w2)
      return out
  
file_path: mne-python/mne/forward/_lead_dots.py
imports: import os
  import os.path
  import numpy
  from numpy.polynomial import legendre
  from ..parallel import parallel_func
  from ..utils import _get_extra_data_path, fill_doc, logger, verbose
label_desc: Use image node_id 7 for calling a global function with example usage: _fast_sphere_dot_r0(r, rr1_orig, rr2s, lr1, lr2s, cosmags1, cosmags2s, w1, w2s, volume_integral, lut, n_fact, ch_type) and returns: out