code: def test_inverse_operator_channel_ordering(evoked, noise_cov):
      """Test MNE inverse computation is immune to channel reorderings."""
      # These are with original ordering
      evoked_orig = evoked.copy()
      fwd_orig = make_forward_solution(
          evoked.info,
          fname_trans,
          src_fname,
          fname_bem,
          eeg=True,
          mindist=5.0,
      )
      fwd_orig = convert_forward_solution(fwd_orig, surf_ori=True)
      depth = dict(
          exp=2.8, limit_depth_chs=False
      )  # test depth > 1 as well
      with catch_logging() as log:
          inv_orig = make_inverse_operator(
              evoked.info,
              fwd_orig,
              noise_cov,
              loose=0.2,
              depth=depth,
              verbose=True,
          )
      log = log.getvalue()
      assert "limit = 1/%s" % fwd_orig["nsource"] in log
      stc_1 = apply_inverse(evoked, inv_orig, lambda2, "dSPM")
  
      # Assume that a raw reordering applies to both evoked and noise_cov,
      # so we don't need to create those from scratch. Just reorder them,
      # then try to apply the original inverse operator
      new_order = np.arange(len(evoked.info["ch_names"]))
      randomiser = np.random.RandomState(42)
      randomiser.shuffle(new_order)
      evoked.data = evoked.data[new_order]
      with evoked.info._unlock(update_redundant=True, check_after=True):
          evoked.info["chs"] = [
              evoked.info["chs"][n] for n in new_order
          ]
  
      cov_ch_reorder = [
          c
          for c in evoked.info["ch_names"]
          if (c in noise_cov.ch_names)
      ]
  
      new_order_cov = [
          noise_cov.ch_names.index(name) for name in cov_ch_reorder
      ]
      noise_cov["data"] = noise_cov.data[
          np.ix_(new_order_cov, new_order_cov)
      ]
      noise_cov["names"] = [
          noise_cov["names"][idx] for idx in new_order_cov
      ]
  
      fwd_reorder = make_forward_solution(
          evoked.info,
          fname_trans,
          src_fname,
          fname_bem,
          eeg=True,
          mindist=5.0,
      )
      fwd_reorder = convert_forward_solution(fwd_reorder, surf_ori=True)
      inv_reorder = make_inverse_operator(
          evoked.info, fwd_reorder, noise_cov, loose=0.2, depth=depth
      )
  
      stc_2 = apply_inverse(evoked, inv_reorder, lambda2, "dSPM")
  
      assert_equal(stc_1.subject, stc_2.subject)
      assert_array_equal(stc_1.times, stc_2.times)
      assert_allclose(stc_1.data, stc_2.data, rtol=1e-5, atol=1e-5)
      assert inv_orig["units"] == inv_reorder["units"]
  
      # Reload with original ordering & apply reordered inverse
      evoked = evoked_orig
      noise_cov = read_cov(fname_cov)
  
      stc_3 = apply_inverse(evoked, inv_reorder, lambda2, "dSPM")
      assert_allclose(stc_1.data, stc_3.data, rtol=1e-5, atol=1e-5)
  
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 8 for calling a global function with example usage: test_inverse_operator_channel_ordering(evoked, noise_cov) without return types