code: def test_validate_unique_callback_state_key():
      """Test that we raise an error if the state keys collide, leading to missing state in the checkpoint."""
  
      class MockCallback(Callback):
          @property
          def state_key(self):
              return "same_key"
  
          def state_dict(self):
              # pretend these callbacks are stateful by overriding the `state_dict` hook
              return {"state": 1}
  
      with pytest.raises(
          RuntimeError,
          match="Found more than one stateful callback of type `MockCallback`",
      ):
          Trainer(callbacks=[MockCallback(), MockCallback()])
  
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 7 for calling a global function with example usage: test_validate_unique_callback_state_key() and returns: str, dict