code: def _bem_inf_pots(mri_rr, bem_rr, mri_Q=None):
      """Compute the infinite medium potential in all 3 directions.
  
      Parameters
      ----------
      mri_rr : ndarray, shape (n_dipole_vertices, 3)
          Chunk of 3D dipole positions in MRI coordinates
      bem_rr: ndarray, shape (n_BEM_vertices, 3)
          3D vertex positions for one BEM surface
      mri_Q : ndarray, shape (3, 3)
          3x3 head -> MRI transform. I.e., head_mri_t.dot(np.eye(3))
  
      Returns
      -------
      ndarray : shape(n_dipole_vertices, 3, n_BEM_vertices)
      """
      # NOTE: the (μ_0 / (4π) factor has been moved to _prep_field_communication
      # Get position difference vector between BEM vertex and dipole
      diff = np.empty((len(mri_rr), 3, len(bem_rr)))
      for ri in range(mri_rr.shape[0]):
          rr = mri_rr[ri]
          this_diff = bem_rr - rr
          diff_norm = np.sum(this_diff * this_diff, axis=1)
          diff_norm *= np.sqrt(diff_norm)
          diff_norm[diff_norm == 0] = 1.0
          if mri_Q is not None:
              this_diff = np.dot(this_diff, mri_Q.T)
          this_diff /= diff_norm.reshape(-1, 1)
          diff[ri] = this_diff.T
  
      return diff
  
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 8 for calling a global function with example usage: _bem_inf_pots(mri_rr, bem_rr, mri_Q) and returns: diff