code: def _switch_backend_regular(backend):
      """
      Switch the plotting backend via `matplotlib.pyplot.switch_backend()`.
  
      Used to set/reset the backend in non-notebook environments, and as a
      fallback method of doing so in notebook environments when the
      IPython magic command fails.
  
      Parameters
      ----------
      backend : str
          the matplotlib backend to switch to
  
      Raises
      ------
      HypertoolsBackendError
          if switching the backend fails
  
      """
      backend = backend.as_python()
  
      try:
          plt.switch_backend(backend)
      except Exception as e:
          if isinstance(e, (ImportError, ModuleNotFoundError)):
              err_msg = (
                  f"Failed to switch the plotting backend to "
                  f"{backend}. You may be missing required dependencies, "
                  "or this backend may not be available for your system"
              )
          else:
              err_msg = (
                  "An unexpected error occurred while trying to switch "
                  f"the plotting backend to {backend}"
              )
  
          raise HypertoolsBackendError(err_msg) from e
  
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 3 for calling a global function with example usage: _switch_backend_regular(backend) without return types