code: def reset_warnings(gallery_conf, fname):
      """Ensure we are future compatible and ignore silly warnings."""
      # In principle, our examples should produce no warnings.
      # Here we cause warnings to become errors, with a few exceptions.
      # This list should be considered alongside
      # setup.cfg -> [tool:pytest] -> filterwarnings
  
      # remove tweaks from other module imports or example runs
      warnings.resetwarnings()
      # restrict
      warnings.filterwarnings("error")
      # allow these, but show them
      warnings.filterwarnings(
          "always", '.*non-standard config type: "foo".*'
      )
      warnings.filterwarnings(
          "always", '.*config type: "MNEE_USE_CUUDAA".*'
      )
      warnings.filterwarnings(
          "always", ".*cannot make axes width small.*"
      )
      warnings.filterwarnings(
          "always", ".*Axes that are not compatible.*"
      )
      warnings.filterwarnings("always", ".*FastICA did not converge.*")
      # ECoG BIDS spec violations:
      warnings.filterwarnings(
          "always", ".*Fiducial point nasion not found.*"
      )
      warnings.filterwarnings(
          "always", ".*DigMontage is only a subset of.*"
      )
      warnings.filterwarnings(  # xhemi morph (should probably update sample)
          "always", ".*does not exist, creating it and saving it.*"
      )
      # internal warnings
      warnings.filterwarnings("default", module="sphinx")
      # allow these warnings, but don't show them
      for key in (
          "invalid version and will not be supported",  # pyxdf
          "distutils Version classes are deprecated",  # seaborn and neo
          "is_categorical_dtype is deprecated",  # seaborn
          "`np.object` is a deprecated alias for the builtin `object`",  # pyxdf
          # nilearn, should be fixed in > 0.9.1
          "In future, it will be an error for 'np.bool_' scalars to",
          # sklearn hasn't updated to SciPy's sym_pos dep
          "The 'sym_pos' keyword is deprecated",
          # numba
          "`np.MachAr` is deprecated",
          # joblib hasn't updated to avoid distutils
          "distutils package is deprecated",
          # jupyter
          "Jupyter is migrating its paths to use standard",
          r"Widget\..* is deprecated\.",
          # PyQt6
          "Enum value .* is marked as deprecated",
          # matplotlib PDF output
          "The py23 module has been deprecated",
          # pkg_resources
          "Implementing implicit namespace packages",
          "Deprecated call to `pkg_resources",
          # nilearn
          "pkg_resources is deprecated as an API",
          r"The .* was deprecated in Matplotlib 3\.7",
          # scipy
          r"scipy.signal.morlet2 is deprecated in SciPy 1\.12",
          # Matplotlib->tz
          r"datetime\.datetime\.utcfromtimestamp",
          # joblib
          r"ast\.Num is deprecated",
          r"Attribute n is deprecated and will be removed in Python 3\.14",
          # numpydoc
          r"ast\.NameConstant is deprecated and will be removed in Python 3\.14",
          # pooch
          r"Python 3\.14 will, by default, filter extracted tar archives.*",
      ):
          warnings.filterwarnings(  # deal with other modules having bad imports
              "ignore",
              message=".*%s.*" % key,
              category=DeprecationWarning,
          )
      warnings.filterwarnings(
          "ignore",
          message="Matplotlib is currently using agg, which is a non-GUI backend.*",
      )
      warnings.filterwarnings(
          "ignore",
          message=".*is non-interactive, and thus cannot.*",
      )
      # seaborn
      warnings.filterwarnings(
          "ignore",
          message="The figure layout has changed to tight",
          category=UserWarning,
      )
      # matplotlib 3.6 in nilearn and pyvista
      warnings.filterwarnings(
          "ignore", message=".*cmap function will be deprecated.*"
      )
      # xarray/netcdf4
      warnings.filterwarnings(
          "ignore",
          message=r"numpy\.ndarray size changed, may indicate.*",
          category=RuntimeWarning,
      )
      # qdarkstyle
      warnings.filterwarnings(
          "ignore",
          message=r".*Setting theme=.*6 in qdarkstyle.*",
          category=RuntimeWarning,
      )
      # pandas, via seaborn (examples/time_frequency/time_frequency_erds.py)
      for message in (
          "use_inf_as_na option is deprecated.*",
          r"iteritems is deprecated.*Use \.items instead\.",
          "is_categorical_dtype is deprecated.*",
          "The default of observed=False.*",
      ):
          warnings.filterwarnings(
              "ignore",
              message=message,
              category=FutureWarning,
          )
      # pandas in 50_epochs_to_data_frame.py
      warnings.filterwarnings(
          "ignore",
          message=r"invalid value encountered in cast",
          category=RuntimeWarning,
      )
      # xarray _SixMetaPathImporter (?)
      warnings.filterwarnings(
          "ignore",
          message=r"falling back to find_module",
          category=ImportWarning,
      )
      # Sphinx deps
      warnings.filterwarnings(
          "ignore",
          message="The str interface for _CascadingStyleSheet.*",
      )
      # mne-qt-browser until > 0.5.2 released
      warnings.filterwarnings(
          "ignore",
          r"mne\.io\.pick.channel_indices_by_type is deprecated.*",
      )
  
      # In case we use np.set_printoptions in any tutorials, we only
      # want it to affect those:
      np.set_printoptions(**_np_print_defaults)
  
imports: import faulthandler
  import gc
  import os
  import subprocess
  import sys
  import time
  import warnings
  from datetime import datetime, timezone
  from importlib.metadata import metadata
  from pathlib import Path
  import matplotlib
  import numpy
  import sphinx
  from numpydoc import docscrape
  from sphinx.domains.changeset import versionlabels
  from sphinx_gallery.sorting import ExplicitOrder, FileNameSortKey
  import mne
  import mne.html_templates._templates
  from mne.tests.test_docstring_parameters import error_ignores
  from mne.utils import _assert_no_instances, linkcode_resolve, run_subprocess, sizeof_fmt
  from mne.viz import Brain
label_desc: Use image node_id 2 for calling a global function with example usage: reset_warnings(gallery_conf, fname) without return types