code: def test_ica_rank_reduction(method):
      """Test recovery ICA rank reduction."""
      _skip_check_picard(method)
      # Most basic recovery
      raw = read_raw_fif(raw_fname).crop(0.5, stop).load_data()
      picks = pick_types(
          raw.info,
          meg=True,
          stim=False,
          ecg=False,
          eog=False,
          exclude="bads",
      )[:10]
      n_components = 5
      for n_pca_components in [6, 10]:
          with pytest.warns(UserWarning, match="did not converge"):
              ica = ICA(
                  n_components=n_components, method=method, max_iter=1
              ).fit(raw, picks=picks)
  
          rank_before = _compute_rank_int(
              raw.copy().pick(picks), proj=False
          )
          assert_equal(rank_before, len(picks))
          raw_clean = ica.apply(
              raw.copy(), n_pca_components=n_pca_components
          )
          rank_after = _compute_rank_int(
              raw_clean.copy().pick(picks), proj=False
          )
          # interaction between ICA rejection and PCA components difficult
          # to preduct. Rank_after often seems to be 1 higher then
          # n_pca_components
          assert (
              n_components
              < n_pca_components
              <= rank_after
              <= rank_before
          )
  
imports: import os
  import shutil
  from contextlib import nullcontext
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg, stats
  from scipy.io import loadmat, savemat
  from mne import Annotations, Epochs, EpochsArray, EvokedArray, Info, create_info, make_ad_hoc_cov, pick_channels_regexp, pick_types, read_events
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT, get_channel_type_constants
  from mne.cov import read_cov
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.io import RawArray, read_raw_ctf, read_raw_eeglab, read_raw_fif
  from mne.io.eeglab.eeglab import _check_load_mat
  from mne.preprocessing import ICA
  from mne.preprocessing import ica_find_ecg_events, ica_find_eog_events, read_ica
  from mne.preprocessing.ica import _ica_explained_variance, _sort_components, corrmap, get_score_funcs, read_ica_eeglab
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings, catch_logging, check_version
label_desc: Use image node_id 9 for calling a global function with example usage: test_ica_rank_reduction(method) without return types