code: def _call_callbacks_load_state_dict(
      trainer: "pl.Trainer", checkpoint: Dict[str, Any]
  ) -> None:
      """Called when loading a model checkpoint, calls every callback's `load_state_dict`."""
      callback_states: Optional[
          Dict[Union[Type, str], Dict]
      ] = checkpoint.get("callbacks")
  
      if callback_states is None:
          return
  
      for callback in trainer.callbacks:
          state = callback_states.get(
              callback.state_key,
              callback_states.get(callback._legacy_state_key),
          )
          if state:
              state = deepcopy(state)
              callback.load_state_dict(state)
  
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 11 for calling a global function with example usage: _call_callbacks_load_state_dict(trainer, checkpoint) without return types