code: def _assert_ica_attributes(ica, data=None, limits=(1.0, 70)):
      """Assert some attributes of ICA objects."""
      __tracebackhide__ = True
      # This tests properties, but also serves as documentation of
      # the shapes these arrays can obtain and how they obtain them
  
      # Pre-whitener
      n_ch = len(ica.ch_names)
      assert ica.pre_whitener_.shape == (
          n_ch,
          n_ch if ica.noise_cov is not None else 1,
      )
  
      # PCA
      n_pca = ica.pca_components_.shape[0]
      assert ica.pca_components_.shape == (n_pca, n_ch), "PCA shape"
      assert_allclose(
          np.dot(ica.pca_components_, ica.pca_components_.T),
          np.eye(n_pca),
          atol=1e-6,
          err_msg="PCA orthogonality",
      )
      assert ica.pca_mean_.shape == (n_ch,)
  
      # Mixing/unmixing
      assert (
          ica.unmixing_matrix_.shape == (ica.n_components_,) * 2
      ), "Unmixing shape"
      assert (
          ica.mixing_matrix_.shape == (ica.n_components_,) * 2
      ), "Mixing shape"
      mix_unmix = np.dot(ica.mixing_matrix_, ica.unmixing_matrix_)
      s = linalg.svdvals(ica.unmixing_matrix_)
      nz = len(s) - (s > s[0] * 1e-12).sum()
      want = np.eye(ica.n_components_)
      want[:nz] = 0
      assert_allclose(
          mix_unmix, want, atol=1e-6, err_msg="Mixing as pinv"
      )
      assert (
          ica.pca_explained_variance_.shape[0]
          >= ica.unmixing_matrix_.shape[1]
      )
      # our PCA components should be unit vectors (the variances get put into
      # the unmixing_matrix_ to make it a whitener)
      norms = np.linalg.norm(ica.pca_components_, axis=1)
      assert_allclose(norms, 1.0)
      # let's check the whitening
      if data is not None:
          if data.ndim == 3:
              data = data.transpose(1, 0, 2).reshape(data.shape[1], -1)
          data = ica._transform_raw(RawArray(data, ica.info), 0, None)
          norms = np.linalg.norm(data, axis=1)
          # at least close to normal
          assert norms.min() > limits[0], "Not roughly unity"
          assert norms.max() < limits[1], "Not roughly unity"
      assert hasattr(ica, "reject_")
  
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 29 for calling a global function with example usage: _assert_ica_attributes(ica, data, limits) without return types