code: def test_load_external_callbacks():
      """Test that the connector collects Callback instances from factories registered through entry points."""
  
      def factory_no_callback():
          return []
  
      def factory_one_callback():
          return ExternalCallback()
  
      def factory_one_callback_list():
          return [ExternalCallback()]
  
      def factory_multiple_callbacks_list():
          return [ExternalCallback(), ExternalCallback()]
  
      with _make_entry_point_query_mock(factory_no_callback):
          callbacks = _load_external_callbacks(
              "lightning.pytorch.callbacks_factory"
          )
      assert callbacks == []
  
      with _make_entry_point_query_mock(factory_one_callback):
          callbacks = _load_external_callbacks(
              "lightning.pytorch.callbacks_factory"
          )
      assert isinstance(callbacks[0], ExternalCallback)
  
      with _make_entry_point_query_mock(factory_one_callback_list):
          callbacks = _load_external_callbacks(
              "lightning.pytorch.callbacks_factory"
          )
      assert isinstance(callbacks[0], ExternalCallback)
  
      with _make_entry_point_query_mock(
          factory_multiple_callbacks_list
      ):
          callbacks = _load_external_callbacks(
              "lightning.pytorch.callbacks_factory"
          )
      assert isinstance(callbacks[0], ExternalCallback)
      assert isinstance(callbacks[1], ExternalCallback)
  
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 1 for calling a global function with example usage: test_load_external_callbacks() and returns: list, ExternalCallback, list, list