code: def _call_callbacks_on_save_checkpoint(
      trainer: "pl.Trainer", checkpoint: Dict[str, Any]
  ) -> None:
      """Called when saving a model checkpoint, calls every callback's `on_save_checkpoint` hook."""
      pl_module = trainer.lightning_module
      if pl_module:
          prev_fx_name = pl_module._current_fx_name
          pl_module._current_fx_name = "on_save_checkpoint"
  
      for callback in trainer.callbacks:
          with trainer.profiler.profile(
              f"[Callback]{callback.state_key}.on_save_checkpoint"
          ):
              callback.on_save_checkpoint(
                  trainer, trainer.lightning_module, checkpoint
              )
  
      if pl_module:
          # restore current_fx when nested context
          pl_module._current_fx_name = prev_fx_name
  
imports: import logging
  from copy import deepcopy
  from typing import Any, Callable, Dict, Optional, Type, Union
  from packaging.version import Version
  import lightning.pytorch
  from lightning.fabric.utilities.device_dtype_mixin import _DeviceDtypeModuleMixin
  from lightning.pytorch.callbacks import Checkpoint, EarlyStopping
  from lightning.pytorch.trainer.states import TrainerStatus
  from lightning.pytorch.utilities.exceptions import _TunerExitException
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning.pytorch.utilities.rank_zero import rank_zero_warn
label_desc: Use image node_id 9 for calling a global function with example usage: _call_callbacks_on_save_checkpoint(trainer, checkpoint) without return types