code: def mpl_cleanup():
      # matplotlib/testing/decorators.py#L24
      # 1) Resets units registry
      # 2) Resets rc_context
      # 3) Closes all figures
      mpl = pytest.importorskip("matplotlib")
      mpl_units = pytest.importorskip("matplotlib.units")
      plt = pytest.importorskip("matplotlib.pyplot")
      orig_units_registry = mpl_units.registry.copy()
      with mpl.rc_context():
          mpl.use("template")
          yield
      mpl_units.registry.clear()
      mpl_units.registry.update(orig_units_registry)
      plt.close("all")
      # https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.6.0.html#garbage-collection-is-no-longer-run-on-figure-close  # noqa: E501
      gc.collect(1)
  
imports: import gc
  import numpy
  import pytest
  from pandas import DataFrame, IndexSlice, Series
  import matplotlib
  from pandas.io.formats.style import Styler
label_desc: Use image node_id 1 for calling a global function with example usage: mpl_cleanup() without return types