code: def warn_external(message, category=None):
      """
      `warnings.warn` wrapper that sets *stacklevel* to "outside Matplotlib".
  
      The original emitter of the warning can be obtained by patching this
      function back to `warnings.warn`, i.e. ``_api.warn_external =
      warnings.warn`` (or ``functools.partial(warnings.warn, stacklevel=2)``,
      etc.).
      """
      frame = sys._getframe()
      for stacklevel in itertools.count(1):
          if frame is None:
              # when called in embedded context may hit frame is None
              break
          if not re.match(
              r"\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))",
              # Work around sphinx-gallery not setting __name__.
              frame.f_globals.get("__name__", ""),
          ):
              break
          frame = frame.f_back
      # preemptively break reference cycle between locals and the frame
      del frame
      warnings.warn(message, category, stacklevel)
  
imports: import functools
  import itertools
  import re
  import sys
  import warnings
  from .deprecation import deprecated, warn_deprecated, rename_parameter, delete_parameter, make_keyword_only, deprecate_method_override, deprecate_privatize_attribute, suppress_matplotlib_deprecation_warning, MatplotlibDeprecationWarning
label_desc: Use image node_id 11 for calling a global function with example usage: warn_external(message, category) without return types