code: def _comp_sum_eeg(beta, ctheta, lut_fun, n_fact):
      """Lead field dot products using Legendre polynomial (P_n) series."""
      # Compute the sum occurring in the evaluation.
      # The result is
      #   sums[:]    (2n+1)^2/n beta^n P_n
      n_chunk = 50000000 // (8 * max(n_fact.shape) * 2)
      lims = np.concatenate(
          [np.arange(0, beta.size, n_chunk), [beta.size]]
      )
      s0 = np.empty(beta.shape)
      for start, stop in zip(lims[:-1], lims[1:]):
          coeffs = lut_fun(ctheta[start:stop])
          betans = np.tile(
              beta[start:stop][:, np.newaxis], (1, n_fact.shape[0])
          )
          np.cumprod(betans, axis=1, out=betans)  # run inplace
          coeffs *= betans
          s0[start:stop] = np.dot(
              coeffs, n_fact
          )  # == weighted sum across cols
      return s0
  
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 5 for calling a global function with example usage: _comp_sum_eeg(beta, ctheta, lut_fun, n_fact) and returns: s0