code: def test_confidence(tmp_path):
      """Test confidence limits."""
      evoked = read_evokeds(
          fname_evo_full, "Left Auditory", baseline=(None, 0)
      )
      evoked.crop(0.08, 0.08).pick("meg")  # MEG-only
      cov = make_ad_hoc_cov(evoked.info)
      sphere = make_sphere_model((0.0, 0.0, 0.04), 0.08)
      dip_py = fit_dipole(evoked, cov, sphere)[0]
      fname_test = tmp_path / "temp-dip.txt"
      dip_py.save(fname_test)
      dip_read = read_dipole(fname_test)
      with pytest.warns(RuntimeWarning, match="'noise/ft/cm', 'prob'"):
          dip_xfit = read_dipole(fname_dip_xfit_80)
      for dip_check in (dip_py, dip_read):
          assert_allclose(
              dip_check.pos, dip_xfit.pos, atol=5e-4
          )  # < 0.5 mm
          assert_allclose(
              dip_check.gof, dip_xfit.gof, atol=5e-1
          )  # < 0.5%
          assert_array_equal(
              dip_check.nfree, dip_xfit.nfree
          )  # exact match
          assert_allclose(
              dip_check.khi2, dip_xfit.khi2, rtol=2e-2
          )  # 2% miss
          assert set(dip_check.conf.keys()) == set(dip_xfit.conf.keys())
          for key in sorted(dip_check.conf.keys()):
              assert_allclose(
                  dip_check.conf[key],
                  dip_xfit.conf[key],
                  rtol=1.5e-1,
                  err_msg=key,
              )
  
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 14 for calling a global function with example usage: test_confidence(tmp_path) without return types