code: def test_resume_callback_state_saved_by_type_stateful(tmpdir):
      """Test that a legacy checkpoint that didn't use a state key before can still be loaded, using
      state_dict/load_state_dict."""
      model = BoringModel()
      callback = OldStatefulCallback(state=111)
      trainer = Trainer(
          default_root_dir=tmpdir, max_steps=1, callbacks=[callback]
      )
      trainer.fit(model)
      ckpt_path = Path(trainer.checkpoint_callback.best_model_path)
      assert ckpt_path.exists()
  
      callback = OldStatefulCallback(state=222)
      trainer = Trainer(
          default_root_dir=tmpdir, max_steps=2, callbacks=[callback]
      )
      trainer.fit(model, ckpt_path=ckpt_path)
      assert callback.state == 111
  
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 3 for calling a global function with example usage: test_resume_callback_state_saved_by_type_stateful(tmpdir) without return types