code: def manage_backend(plot_func):
      """
      Decorator for hypertools.plot that prevents unexpected changes to
      matplotlib rcParams (https://github.com/ContextLab/hypertools/issues/243)
      and handles temporarily changing the matplotlib backend for
      interactive and animated plots, as necessary.
  
      Parameters
      ----------
      plot_func : function
          Function around which to set/reset the plotting backend and
          rcParams (currently, always `hypertools.plot`).
  
      Returns
      -------
      plot_wrapper : function
          The decorated function.
  
      Notes
      ------
      1. Capturing & restoring the rcParams needs to happen here rather
         than in `set_interactive_backend` so it's done independently for
         each plot
      2. Written in a slightly roundabout way in order to skip unnecessary
         & duplicate calls when the decorated call to `hypertools.plot`
         happens inside the `hypertools.set_interactive_backend` context.
      """
  
      @wraps(plot_func)
      def plot_wrapper(*args, **kwargs):
          # record current rcParams
          old_rcParams = mpl.rcParams.copy()
          # assume using the mock-`contextlib.nullcontext` context
          backend_context = _null_backend_context
          tmp_backend = None
  
          if not IN_SET_CONTEXT:
              plot_kwargs = _get_runtime_args(
                  plot_func, *args, **kwargs
              )
              if plot_kwargs.get("animate") or plot_kwargs.get(
                  "interactive"
              ):
                  curr_backend = HypertoolsBackend(
                      mpl.get_backend()
                  ).normalize()
                  tmp_backend = plot_kwargs.get("mpl_backend")
                  if tmp_backend == "auto":
                      tmp_backend = HYPERTOOLS_BACKEND.normalize()
  
                  if tmp_backend not in ("disable", curr_backend):
                      # if all conditions are met, use the real context
                      backend_context = set_interactive_backend
  
          try:
              with backend_context(tmp_backend):
                  if BACKEND_WARNING is not None:
                      warnings.warn(BACKEND_WARNING)
  
                  return plot_func(*args, **kwargs)
  
          finally:
              # restore rcParams prior to plot
              with warnings.catch_warnings():
                  # if the matplotlibrc was cached from <=v3.3.0, a TON of
                  # (harmless as of v3.2.0) MatplotlibDeprecationWarnings
                  # about `axes.Axes3D`-related rcParams fields are issued
                  warnings.simplefilter(
                      "ignore", mpl.MatplotlibDeprecationWarning
                  )
                  mpl.rcParams.update(**old_rcParams)
  
      return plot_wrapper
  
imports: import inspect
  import sys
  import traceback
  import warnings
  from contextlib import contextmanager, redirect_stdout
  from functools import wraps
  from io import StringIO
  from os import getenv
  from typing import Iterable
  import matplotlib
  import matplotlib.pyplot
  from .._shared.exceptions import HypertoolsBackendError
label_desc: Use image node_id 8 for calling a global function with example usage: manage_backend(plot_func) and returns: plot_wrapper, plot_func