code: def _make_entry_point_query_mock(callback_factory):
      query_mock = Mock()
      entry_point = Mock()
      entry_point.name = "mocked"
      entry_point.load.return_value = callback_factory
      if _PYTHON_GREATER_EQUAL_3_10_0:
          query_mock.return_value = [entry_point]
          import_path = "importlib.metadata.entry_points"
      elif _PYTHON_GREATER_EQUAL_3_8_0:
          query_mock().get.return_value = [entry_point]
          import_path = "importlib.metadata.entry_points"
      else:
          query_mock.return_value = [entry_point]
          import_path = "pkg_resources.iter_entry_points"
      with mock.patch(import_path, query_mock):
          yield
  
file_path: pytorch-lightning/tests/tests_fabric/utilities/test_registry.py
imports: import contextlib
  from unittest import mock
  from unittest.mock import Mock
  from lightning.fabric.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0, _PYTHON_GREATER_EQUAL_3_10_0
  from lightning.fabric.utilities.registry import _load_external_callbacks
label_desc: Use image node_id 2 for calling a global function with example usage: _make_entry_point_query_mock(callback_factory) without return types