code: def _check_dipoles(dipoles, fwd, stc, evoked, residual=None):
      src = fwd["src"]
      pos1 = fwd["source_rr"][
          np.where(src[0]["vertno"] == stc.vertices[0])
      ]
      pos2 = fwd["source_rr"][
          np.where(src[1]["vertno"] == stc.vertices[1])[0]
          + len(src[0]["vertno"])
      ]
  
      # Check the position of the two dipoles
      assert dipoles[0].pos[0] in np.array([pos1, pos2])
      assert dipoles[1].pos[0] in np.array([pos1, pos2])
  
      ori1 = fwd["source_nn"][
          np.where(src[0]["vertno"] == stc.vertices[0])[0]
      ][0]
      ori2 = fwd["source_nn"][
          np.where(src[1]["vertno"] == stc.vertices[1])[0]
          + len(src[0]["vertno"])
      ][0]
  
      # Check the orientation of the dipoles
      assert (
          np.max(
              np.abs(
                  np.dot(dipoles[0].ori[0], np.array([ori1, ori2]).T)
              )
          )
          > 0.99
      )
  
      assert (
          np.max(
              np.abs(
                  np.dot(dipoles[1].ori[0], np.array([ori1, ori2]).T)
              )
          )
          > 0.99
      )
  
      if residual is not None:
          picks_grad = mne.pick_types(residual.info, meg="grad")
          picks_mag = mne.pick_types(residual.info, meg="mag")
          rel_tol = 0.02
          for picks in [picks_grad, picks_mag]:
              assert linalg.norm(
                  residual.data[picks], ord="fro"
              ) < rel_tol * linalg.norm(evoked.data[picks], ord="fro")
  
file_path: mne-python/mne/beamformer/tests/test_rap_music.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose
  from scipy import linalg
  import mne
  from mne.beamformer import rap_music, trap_music
  from mne.cov import regularize
  from mne.datasets import testing
  from mne.minimum_norm.tests.test_inverse import assert_var_exp_log
  from mne.utils import catch_logging
label_desc: Use image node_id 3 for calling a global function with example usage: _check_dipoles(dipoles, fwd, stc, evoked, residual) without return types