code: def test_plot_ica_components():
      """Test plotting of ICA solutions."""
      res = 8
      fast_test = {"res": res, "contours": 0, "sensors": False}
      raw = _get_raw()
      ica = ICA(noise_cov=read_cov(cov_fname), n_components=8)
      ica_picks = _get_picks(raw)
      with pytest.warns(
          RuntimeWarning, match="(projection)|(unstable mixing matrix)"
      ):
          ica.fit(raw, picks=ica_picks)
  
      for components in [0, [0], [0, 1], [0, 1] * 2, None]:
          ica.plot_components(
              components,
              image_interp="cubic",
              colorbar=True,
              **fast_test,
          )
      plt.close("all")
  
      # test interactive mode (passing 'inst' arg)
      with catch_logging() as log:
          ica.plot_components(
              [0, 1],
              image_interp="cubic",
              inst=raw,
              res=16,
              verbose="debug",
              ch_type="grad",
          )
      log = log.getvalue()
      assert "grad data" in log
      assert "extrapolation mode local to mean" in log
      fig = plt.gcf()
  
      # test title click
      # ----------------
      lbl = fig.axes[1].get_label()
      ica_idx = int(lbl[-3:])
      titles = [ax.title for ax in fig.axes]
      title_pos_midpoint = (
          titles[1]
          .get_window_extent()
          .extents.reshape((2, 2))
          .mean(axis=0)
      )
      # first click adds to exclude
      _fake_click(fig, fig.axes[1], title_pos_midpoint, xform="pix")
      assert ica_idx in ica.exclude
      # clicking again removes from exclude
      _fake_click(fig, fig.axes[1], title_pos_midpoint, xform="pix")
      assert ica_idx not in ica.exclude
  
      # test topo click
      # ---------------
      _fake_click(fig, fig.axes[1], (0.0, 0.0), xform="data")
  
      c_fig = plt.gcf()
      labels = [ax.get_label() for ax in c_fig.axes]
  
      for label in ["topomap", "image", "erp", "spectrum", "variance"]:
          assert label in labels
  
      topomap_ax = c_fig.axes[labels.index("topomap")]
      title = topomap_ax.get_title()
      assert lbl.split(" ")[0] == title.split(" ")[0]
  
      # test provided axes
      _, ax = plt.subplots(1, 1)
      ica.plot_components(axes=ax, picks=0, **fast_test)
      _, ax = plt.subplots(2, 1)
      ica.plot_components(axes=ax, picks=[0, 1], **fast_test)
      _, ax = plt.subplots(2, 2)
      ica.plot_components(axes=ax, picks=[0, 1, 2, 3], **fast_test)
      _, ax = plt.subplots(3, 2)
      ica.plot_components(
          axes=ax,
          picks=[0, 1, 2, 3, 4, 5],
          nrows=2,
          ncols=2,
          **fast_test,
      )
  
      ica.info = None
      with pytest.raises(RuntimeError, match="fit the ICA"):
          ica.plot_components(1, ch_type="mag")
  
imports: import sys
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne import Annotations, Epochs, make_fixed_length_events, pick_types, read_cov, read_events
  from mne.io import read_raw_fif
  from mne.preprocessing import ICA, create_ecg_epochs, create_eog_epochs
  from mne.utils import _record_warnings, catch_logging
  from mne.viz.ica import _create_properties_layout, plot_ica_properties
  from mne.viz.utils import _fake_click, _fake_keypress
label_desc: Use image node_id 5 for calling a global function with example usage: test_plot_ica_components() without return types