code: def request_mocker(monkeypatch):
      """Monkeypatch requests and urllib functions for sending requests.
  
      This ensures that test functions do not retrieve data from the network, but
      can still run using mock data.
  
      request.send is patched with a Sender object, whose responses can be
      configured -- see the docstring for Sender.
  
      urllib's open is simply patched with a MagicMock. As nilearn dataset
      fetchers use requests, most tests won't use this; it is patched to make
      sure network mocking is not worked around by using urllib directly instead
      of requests, and for testing the FTP adapter.
  
      This fixture uses 'autouse' and is imported in conftest.py to make sure it
      is used by every test, even those that do not explicitly ask for it.
  
      """
      sender = Sender()
      monkeypatch.setattr("requests.sessions.Session.send", sender)
      monkeypatch.setattr(
          "urllib.request.OpenerDirector.open", MagicMock()
      )
      return sender
  
imports: import fnmatch
  import json
  import os
  import pickle
  import re
  import shutil
  import tempfile
  from collections import OrderedDict
  from pathlib import Path
  from unittest.mock import MagicMock
  import pytest
  from requests.exceptions import HTTPError
  from nilearn._utils.testing import serialize_niimg
label_desc: Use image node_id 2 for calling a global function with example usage: request_mocker(monkeypatch) and returns: sender