code: def mock_pypi_api(mock_responses):
      def requests_get_patch(
          url, *args, **kwargs
      ):  # pylint: disable=unused-argument
          package_name = re.search(
              r"https://pypi\.org/pypi/(.+)/json", url
          ).group(1)
          return mock_responses[package_name]
  
      def decorator(test_func):
          @functools.wraps(test_func)
          def wrapper(*args, **kwargs):
              with mock.patch("requests.get", new=requests_get_patch):
                  return test_func(*args, **kwargs)
  
          return wrapper
  
      return decorator
  
imports: import functools
  import re
  import tempfile
  from contextlib import contextmanager
  from pathlib import Path
  from unittest import mock
  import pytest
  from dev.set_matrix import generate_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: mock_pypi_api(mock_responses) and returns: decorator, mock_responses, wrapper, test_func