code: def test_accuracy():
      """Test dipole fitting to sub-mm accuracy."""
      evoked = read_evokeds(fname_evo)[0].crop(
          0.0,
          0.0,
      )
      evoked.pick("meg")
      evoked.pick([c for c in evoked.ch_names[::4]])
      for rad, perc_90 in zip((0.09, None), (0.002, 0.004)):
          bem = make_sphere_model(
              "auto",
              rad,
              evoked.info,
              relative_radii=(0.999, 0.998, 0.997, 0.995),
          )
          src = read_source_spaces(fname_src)
  
          fwd = make_forward_solution(evoked.info, None, src, bem)
          fwd = convert_forward_solution(
              fwd, force_fixed=True, use_cps=True
          )
          vertices = [src[0]["vertno"], src[1]["vertno"]]
          n_vertices = sum(len(v) for v in vertices)
          amp = 10e-9
          data = np.eye(n_vertices + 1)[:n_vertices]
          data[-1, -1] = 1.0
          data *= amp
          stc = SourceEstimate(data, vertices, 0.0, 1e-3, "sample")
          evoked.info.normalize_proj()
          sim = simulate_evoked(
              fwd, stc, evoked.info, cov=None, nave=np.inf
          )
  
          cov = make_ad_hoc_cov(evoked.info)
          dip = fit_dipole(sim, cov, bem, min_dist=0.001)[0]
  
          ds = []
          for vi in range(n_vertices):
              if vi < len(vertices[0]):
                  hi = 0
                  vertno = vi
              else:
                  hi = 1
                  vertno = vi - len(vertices[0])
              vertno = src[hi]["vertno"][vertno]
              rr = src[hi]["rr"][vertno]
              d = np.sqrt(np.sum((rr - dip.pos[vi]) ** 2))
              ds.append(d)
          # make sure that our median is sub-mm and the large majority are very
          # close (we expect some to be off by a bit e.g. because they are
          # radial)
          assert_array_less(
              np.percentile(ds, [50, 90]), [0.0005, perc_90]
          )
  
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from mne import Dipole, DipoleFixed, Epochs, Evoked, EvokedArray, SourceEstimate, convert_forward_solution, fit_dipole, head_to_mni, make_ad_hoc_cov, make_fixed_length_events, make_forward_solution, make_sphere_model, pick_info, pick_types, read_cov, read_dipole, read_evokeds, read_forward_solution, read_source_spaces, transform_surface_to, write_evokeds
  from mne._fiff.constants import FIFF
  from mne.bem import _bem_find_surface, read_bem_solution
  from mne.datasets import testing
  from mne.dipole import _BDIP_ERROR_KEYS, get_phantom_dipoles
  from mne.io import read_raw_ctf, read_raw_fif
  from mne.proj import make_eeg_average_ref_proj
  from mne.simulation import simulate_evoked
  from mne.surface import _compute_nearest
  from mne.transforms import _get_trans, apply_trans
  from mne.utils import _record_warnings, requires_mne, run_subprocess
label_desc: Use image node_id 10 for calling a global function with example usage: test_accuracy() without return types