code: def test_callbacks_references_fit_ckpt_path(tmpdir):
      """Test that resuming from a checkpoint sets references as expected."""
      dm = ClassifDataModule()
      model = ClassificationModel()
      args = {
          "default_root_dir": tmpdir,
          "max_steps": 1,
          "logger": False,
          "limit_val_batches": 2,
          "num_sanity_val_steps": 0,
      }
  
      # initial training
      checkpoint = ModelCheckpoint(
          dirpath=tmpdir, monitor="val_loss", save_last=True
      )
      trainer = Trainer(**args, callbacks=[checkpoint])
      assert (
          checkpoint
          is trainer.callbacks[-1]
          is trainer.checkpoint_callback
      )
      trainer.fit(model, datamodule=dm)
  
      # resumed training
      new_checkpoint = ModelCheckpoint(
          dirpath=tmpdir, monitor="val_loss", save_last=True
      )
      # pass in a new checkpoint object, which should take
      # precedence over the one in the last.ckpt file
      trainer = Trainer(**args, callbacks=[new_checkpoint])
      assert checkpoint is not new_checkpoint
      assert (
          new_checkpoint
          is trainer.callbacks[-1]
          is trainer.checkpoint_callback
      )
      trainer.fit(
          model, datamodule=dm, ckpt_path=str(tmpdir / "last.ckpt")
      )
  
imports: import glob
  import logging
  import os
  import pickle
  from copy import deepcopy
  from typing import Generic, Mapping, TypeVar
  import cloudpickle
  import pytest
  import torch
  from lightning.fabric import seed_everything
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.states import TrainerFn
  from lightning_utilities.test.warning import no_warning_call
  from torch import Tensor
  import tests_pytorch.helpers.pipelines
  import tests_pytorch.helpers.utils
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
  from tests_pytorch.loops.test_loops import CustomException
label_desc: Use image node_id 7 for calling a global function with example usage: test_callbacks_references_fit_ckpt_path(tmpdir) without return types