code: def plot_ica_scores(
      ica,
      scores,
      exclude=None,
      labels=None,
      axhline=None,
      title="ICA component scores",
      figsize=None,
      n_cols=None,
      show=True,
  ):
      """Plot scores related to detected components.
  
      Use this function to asses how well your score describes outlier
      sources and how well you were detecting them.
  
      Parameters
      ----------
      ica : instance of mne.preprocessing.ICA
          The ICA object.
      scores : array-like of float, shape (n_ica_components,) | list of array
          Scores based on arbitrary metric to characterize ICA components.
      exclude : array-like of int
          The components marked for exclusion. If None (default), ICA.exclude
          will be used.
      labels : str | list | 'ecg' | 'eog' | None
          The labels to consider for the axes tests. Defaults to None.
          If list, should match the outer shape of ``scores``.
          If 'ecg' or 'eog', the ``labels_`` attributes will be looked up.
          Note that '/' is used internally for sublabels specifying ECG and
          EOG channels.
      axhline : float
          Draw horizontal line to e.g. visualize rejection threshold.
      title : str
          The figure title.
      figsize : tuple of int | None
          The figure size. If None it gets set automatically.
      n_cols : int | None
          Scores are plotted in a grid. This parameter controls how
          many to plot side by side before starting a new row. By
          default, a number will be chosen to make the grid as square as
          possible.
      show : bool
          Show figure if True.
  
      Returns
      -------
      fig : instance of Figure
          The figure object.
      """
      import matplotlib.pyplot as plt
  
      my_range = np.arange(ica.n_components_)
      if exclude is None:
          exclude = ica.exclude
      exclude = np.unique(exclude)
      if not isinstance(scores[0], (list, np.ndarray)):
          scores = [scores]
      n_scores = len(scores)
  
      if n_cols is None:
          # prefer more rows.
          n_rows = int(np.ceil(np.sqrt(n_scores)))
          n_cols = (n_scores - 1) // n_rows + 1
      else:
          n_cols = min(n_scores, n_cols)
          n_rows = (n_scores - 1) // n_cols + 1
  
      if figsize is None:
          figsize = (6.4 * n_cols, 2.7 * n_rows)
      fig, axes = plt.subplots(
          n_rows,
          n_cols,
          figsize=figsize,
          sharex=True,
          sharey=True,
          layout="constrained",
      )
  
      if isinstance(axes, np.ndarray):
          axes = axes.flatten()
      else:
          axes = [axes]
  
      fig.suptitle(title)
  
      if labels == "ecg":
          labels = [
              label for label in ica.labels_ if label.startswith("ecg/")
          ]
          labels.sort(
              key=lambda label: label.split("/")[1]
          )  # sort by index
          if len(labels) == 0:
              labels = [
                  label
                  for label in ica.labels_
                  if label.startswith("ecg")
              ]
      elif labels == "eog":
          labels = [
              label for label in ica.labels_ if label.startswith("eog/")
          ]
          labels.sort(
              key=lambda label: label.split("/")[1]
          )  # sort by index
          if len(labels) == 0:
              labels = [
                  label
                  for label in ica.labels_
                  if label.startswith("eog")
              ]
      elif isinstance(labels, str):
          labels = [labels]
      elif labels is None:
          labels = (None,) * n_scores
  
      if len(labels) != n_scores:
          raise ValueError(
              "Need as many labels (%i) as scores (%i)"
              % (len(labels), n_scores)
          )
  
      for label, this_scores, ax in zip(labels, scores, axes):
          if len(my_range) != len(this_scores):
              raise ValueError(
                  "The length of `scores` must equal the "
                  "number of ICA components."
              )
          ax.bar(my_range, this_scores, color="gray", edgecolor="k")
          for excl in exclude:
              ax.bar(
                  my_range[excl],
                  this_scores[excl],
                  color="r",
                  edgecolor="k",
              )
          if axhline is not None:
              if np.isscalar(axhline):
                  axhline = [axhline]
              for axl in axhline:
                  ax.axhline(axl, color="r", linestyle="--")
          ax.set_ylabel("score")
  
          if label is not None:
              if "eog/" in label:
                  split = label.split("/")
                  label = ", ".join([split[0], split[2]])
              elif "/" in label:
                  label = ", ".join(label.split("/"))
              ax.set_title("(%s)" % label)
          ax.set_xlabel("ICA components")
          ax.set_xlim(-0.6, len(this_scores) - 0.4)
      fig.canvas.draw()
      plt_show(show)
      return fig
  
imports: import warnings
  from functools import partial
  import numpy
  from scipy.stats import gaussian_kde
  from .._fiff.meas_info import create_info
  from .._fiff.pick import _picks_to_idx, pick_types
  from .._fiff.proj import _has_eeg_average_ref_proj
  from ..defaults import DEFAULTS, _handle_default
  from ..utils import _reject_data_segments, _validate_type, fill_doc, verbose
  from .epochs import plot_epochs_image
  from .evoked import _butterfly_on_button_press, _butterfly_onpick
  from .topomap import _plot_ica_topomap
  from .utils import _compute_scalings, _convert_psds, _get_cmap, _get_plot_ch_type, _handle_precompute, _make_event_color_dict, plt_show
label_desc: Use image node_id 9 for calling a global function with example usage: plot_ica_scores(ica, scores, exclude, labels, axhline, title, figsize, n_cols, show) and returns: fig