code: def _compare_inverses_approx(
      inv_1,
      inv_2,
      evoked,
      rtol,
      atol,
      depth_atol=1e-6,
      ctol=0.999999,
      check_nn=True,
      check_K=True,
  ):
      """Compare inverses."""
      # depth prior
      if inv_1["depth_prior"] is not None:
          assert_allclose(
              inv_1["depth_prior"]["data"],
              inv_2["depth_prior"]["data"],
              atol=depth_atol,
          )
      else:
          assert inv_2["depth_prior"] is None
      # orient prior
      if inv_1["orient_prior"] is not None:
          assert_allclose(
              inv_1["orient_prior"]["data"],
              inv_2["orient_prior"]["data"],
              atol=1e-7,
          )
      else:
          assert inv_2["orient_prior"] is None
      # source cov
      assert_allclose(
          inv_1["source_cov"]["data"],
          inv_2["source_cov"]["data"],
          atol=1e-7,
      )
      for key in (
          "units",
          "eigen_leads_weighted",
          "nsource",
          "coord_frame",
      ):
          assert_equal(inv_1[key], inv_2[key], err_msg=key)
      assert_equal(
          inv_1["eigen_leads"]["ncol"], inv_2["eigen_leads"]["ncol"]
      )
      K_1 = np.dot(
          inv_1["eigen_leads"]["data"] * inv_1["sing"].astype(float),
          inv_1["eigen_fields"]["data"],
      )
      K_2 = np.dot(
          inv_2["eigen_leads"]["data"] * inv_2["sing"].astype(float),
          inv_2["eigen_fields"]["data"],
      )
      # for free + surf ori, we only care about the ::2
      # (the other two dimensions have arbitrary direction)
      if inv_1["nsource"] * 3 == inv_1["source_nn"].shape[0]:
          # Technically this undersamples the free-orientation, non-surf-ori
          # inverse, but it's probably okay
          sl = slice(2, None, 3)
      else:
          sl = slice(None)
      if check_nn:
          assert_allclose(
              inv_1["source_nn"][sl], inv_2["source_nn"][sl], atol=1e-4
          )
      if check_K:
          assert_allclose(
              np.abs(K_1[sl]), np.abs(K_2[sl]), rtol=rtol, atol=atol
          )
  
      # Now let's do some practical tests, too
      evoked = EvokedArray(np.eye(len(evoked.ch_names)), evoked.info)
      for method in ("MNE", "dSPM"):
          stc_1 = apply_inverse(evoked, inv_1, lambda2, method)
          stc_2 = apply_inverse(evoked, inv_2, lambda2, method)
          assert_equal(stc_1.subject, stc_2.subject)
          assert_equal(stc_1.times, stc_2.times)
          stc_1 = stc_1.data
          stc_2 = stc_2.data
          norms = np.max(stc_1, axis=-1, keepdims=True)
          stc_1 /= norms
          stc_2 /= norms
          corr = np.corrcoef(stc_1.ravel(), stc_2.ravel())[0, 1]
          assert corr > ctol
          assert_allclose(
              stc_1,
              stc_2,
              rtol=rtol,
              atol=atol,
              err_msg="%s: %s" % (method, corr),
          )
  
imports: import copy
  import re
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less, assert_equal
  from scipy import sparse
  import mne
  from mne import Covariance, EvokedArray, SourceEstimate, combine_evoked, compute_raw_covariance, convert_forward_solution, make_ad_hoc_cov, make_forward_solution, make_sphere_model, pick_channels_forward, pick_types, pick_types_forward, read_cov, read_evokeds, read_forward_solution
  from mne.datasets import testing
  from mne.epochs import Epochs, EpochsArray, make_fixed_length_epochs
  from mne.event import read_events
  from mne.forward import apply_forward, is_fixed_orient, restrict_forward_to_stc
  from mne.io import read_info, read_raw_fif
  from mne.label import label_sign_flip, read_label
  from mne.minimum_norm import INVERSE_METHODS, apply_inverse, apply_inverse_cov, apply_inverse_epochs, apply_inverse_raw, apply_inverse_tfr_epochs, compute_rank_inverse, make_inverse_operator, prepare_inverse_operator, read_inverse_operator, write_inverse_operator
  from mne.source_estimate import VolSourceEstimate, read_source_estimate
  from mne.source_space._source_space import _get_src_nn
  from mne.surface import _normal_orth
  from mne.time_frequency import EpochsTFR
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 4 for calling a global function with example usage: _compare_inverses_approx(inv_1, inv_2, evoked, rtol, atol, depth_atol, ctol, check_nn, check_K) without return types