code: def test_configure_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):
          trainer = Trainer(
              enable_checkpointing=False,
              enable_progress_bar=False,
              enable_model_summary=False,
          )
      assert trainer.callbacks == []
  
      with _make_entry_point_query_mock(factory_one_callback):
          trainer = Trainer(
              enable_checkpointing=False,
              enable_progress_bar=False,
              enable_model_summary=False,
          )
      assert isinstance(trainer.callbacks[0], ExternalCallback)
  
      with _make_entry_point_query_mock(factory_one_callback_list):
          trainer = Trainer(
              enable_checkpointing=False,
              enable_progress_bar=False,
              enable_model_summary=False,
          )
      assert isinstance(trainer.callbacks[0], ExternalCallback)
  
      with _make_entry_point_query_mock(
          factory_multiple_callbacks_list
      ):
          trainer = Trainer(
              enable_checkpointing=False,
              enable_progress_bar=False,
              enable_model_summary=False,
          )
      assert isinstance(trainer.callbacks[0], ExternalCallback)
      assert isinstance(trainer.callbacks[1], ExternalCallback)
  
imports: import contextlib
  import logging
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.fabric.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0, _PYTHON_GREATER_EQUAL_3_10_0
  from lightning.pytorch import Callback, LightningModule, Trainer
  from lightning.pytorch.callbacks import EarlyStopping, GradientAccumulationScheduler, LearningRateMonitor, ModelCheckpoint, ModelSummary, ProgressBar, TQDMProgressBar
  from lightning.pytorch.callbacks.batch_size_finder import BatchSizeFinder
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.connectors.callback_connector import _CallbackConnector
label_desc: Use image node_id 5 for calling a global function with example usage: test_configure_external_callbacks() and returns: list, ExternalCallback, list, list