code: def _needs_matplotlib_backend(func: FuncType) -> FuncType:
      """Decorator to fix matplotlib backend before calling a function."""
  
      @wraps(func)
      def inner(*args: Any, **kwargs: Any) -> ReturnType:  # type: ignore
          """Replacement function that fixes matplotlib backend."""
          global _MATPLOTLIB_BACKEND_FIXED
          if not _MATPLOTLIB_BACKEND_FIXED:
              _fix_matplotlib_backend()
              _MATPLOTLIB_BACKEND_FIXED = True
          return func(*args, **kwargs)
  
      return inner
  
file_path: rasa/rasa/utils/plotting.py
imports: import logging
  import itertools
  import os
  from functools import wraps
  import numpy
  from typing import Any, Callable, List, Optional, Text, TypeVar, Union, Tuple
  import matplotlib
  from matplotlib.ticker import FormatStrFormatter
  import rasa.shared.utils.io
  from rasa.constants import RESULTS_FILE
label_desc: Use image node_id 2 for calling a global function with example usage: _needs_matplotlib_backend(func) and returns: inner, func