code: def test_should_switch_to_agg_backend_if_current_backend_fails(
      use_mock,
  ):
      # First call to `matplotlib.use` raises an exception, hence the default Agg
      # backend should be triggered
      _set_mpl_backend()
  
      assert use_mock.call_count == 2
      # Check that the most recent call to `matplotlib.use` has arg `Agg`
      use_mock.assert_called_with("Agg")
  
file_path: nilearn/nilearn/plotting/tests/test_matplotlib_backend.py
imports: from unittest.mock import patch
  import warnings
  import pytest
  from nilearn.plotting import _set_mpl_backend
label_desc: Use image node_id 3 for calling a global function with example usage: test_should_switch_to_agg_backend_if_current_backend_fails(use_mock) without return types