code: def test_configure_callbacks_hook_multiple_calls(tmpdir):
      """Test that subsequent calls to `configure_callbacks` do not change the callbacks list."""
      model_callback_mock = Mock(spec=Callback, model=Callback())
  
      class TestModel(BoringModel):
          def configure_callbacks(self):
              return model_callback_mock
  
      model = TestModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          fast_dev_run=True,
          enable_checkpointing=False,
      )
  
      callbacks_before_fit = trainer.callbacks.copy()
      assert callbacks_before_fit
  
      trainer.fit(model)
      callbacks_after_fit = trainer.callbacks.copy()
      assert callbacks_after_fit == callbacks_before_fit + [
          model_callback_mock
      ]
  
      for fn in ("test", "validate"):
          trainer_fn = getattr(trainer, fn)
          trainer_fn(model)
  
          callbacks_after = trainer.callbacks.copy()
          assert callbacks_after == callbacks_after_fit
  
          trainer_fn(model)
          callbacks_after = trainer.callbacks.copy()
          assert callbacks_after == callbacks_after_fit
  
file_path: pytorch-lightning/tests/tests_pytorch/callbacks/test_callbacks.py
imports: from pathlib import Path
  from re import escape
  from unittest.mock import Mock
  import pytest
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning_utilities.test.warning import no_warning_call
label_desc: Use image node_id 2 for calling a global function with example usage: test_configure_callbacks_hook_multiple_calls(tmpdir) and returns: model_callback_mock