code: def _set_mpl_backend():
      # We are doing local imports here to avoid polluting our namespace
      try:
          import matplotlib
      except ImportError:
          if importlib.util.find_spec("pytest") is not None:
              from .._utils.testing import skip_if_running_tests
  
              # No need to fail when running tests
              skip_if_running_tests("matplotlib not installed")
          raise
      else:
          from .._utils import compare_version
  
          # When matplotlib was successfully imported we need to check
          # that the version is greater that the minimum required one
          mpl_version = getattr(matplotlib, "__version__", "0.0.0")
          if not compare_version(
              mpl_version, ">=", OPTIONAL_MATPLOTLIB_MIN_VERSION
          ):
              raise ImportError(
                  f"A matplotlib version of at least "
                  f"{OPTIONAL_MATPLOTLIB_MIN_VERSION} "
                  f"is required to use nilearn. {mpl_version} was found. "
                  f"Please upgrade matplotlib"
              )
          current_backend = matplotlib.get_backend().lower()
  
          try:
              # Making sure the current backend is usable by matplotlib
              matplotlib.use(current_backend)
          except Exception:
              # If not, switching to default agg backend
              matplotlib.use("Agg")
          new_backend = matplotlib.get_backend().lower()
  
          if new_backend != current_backend:
              # Matplotlib backend has been changed, let's warn the user
              warnings.warn(f"Backend changed to {new_backend}...")
  
file_path: nilearn/nilearn/plotting/__init__.py
imports: import importlib
  import warnings
  from .None import cm
  from .find_cuts import find_cut_slices, find_parcellation_cut_coords, find_probabilistic_atlas_cut_coords, find_xyz_cut_coords
  from .html_connectome import view_connectome, view_markers
  from .html_stat_map import view_img
  from .html_surface import view_img_on_surf, view_surf
  from .img_plotting import plot_anat, plot_carpet, plot_connectome, plot_epi, plot_glass_brain, plot_img, plot_img_comparison, plot_markers, plot_prob_atlas, plot_roi, plot_stat_map, show
  from .matrix_plotting import plot_contrast_matrix, plot_design_matrix, plot_event, plot_matrix
  from .surf_plotting import plot_img_on_surf, plot_surf, plot_surf_contours, plot_surf_roi, plot_surf_stat_map
label_desc: Use image node_id 1 for calling a global function with example usage: _set_mpl_backend() without return types