code: def needs_mpl_agg(func):
      """Decorator requiring matplotlib with agg backend"""
      if not HAVE_MPL:
          return needs_mpl(func)
      import matplotlib.pyplot as plt
  
      @functools.wraps(func)
      def agg_func(*args, **kwargs):
          matplotlib.use("agg")
          plt.switch_backend("agg")
          return func(*args, **kwargs)
  
      return agg_func
  
file_path: nipy/nipy/testing/decorators.py
imports: import functools
  from unittest import skipIf
  from nibabel.optpkg import optional_package
  from nipy.utils import DataError, example_data, templates
label_desc: Use image node_id 6 for calling a global function with example usage: needs_mpl_agg(func) and returns: agg_func, needs_mpl, func