code: def test_load_from_checkpoint_hook_calls(
      override_configure_model, tmpdir
  ):
      class CustomHookedDataModule(HookedDataModule):
          def state_dict(self):
              return {"foo": "bar"}
  
      class CustomHookedModel(HookedModel):
          pass
  
      if not override_configure_model:
          CustomHookedModel.configure_model = None
  
      lm_called, ldm_called = [], []
      model = CustomHookedModel(lm_called)
      assert (
          is_overridden("configure_model", model)
          == override_configure_model
      )
  
      datamodule = CustomHookedDataModule(ldm_called)
      trainer = Trainer()
      trainer.strategy.connect(model)
      trainer._data_connector.attach_data(model, datamodule=datamodule)
      ckpt_path = str(tmpdir / "file.ckpt")
      trainer.save_checkpoint(ckpt_path)
  
      datamodule_state_dict_key = datamodule.__class__.__qualname__
      saved_ckpt = {
          "callbacks": ANY,
          "epoch": 0,
          "global_step": 0,
          "lr_schedulers": ANY,
          "optimizer_states": ANY,
          "pytorch-lightning_version": __version__,
          "state_dict": ANY,
          "loops": ANY,
          datamodule_state_dict_key: {"foo": "bar"},
      }
  
      assert lm_called == [
          {"name": "on_save_checkpoint", "args": (saved_ckpt,)}
      ]
      assert ldm_called == [{"name": "state_dict"}]
  
      lm_called, ldm_called = [], []
      _ = CustomHookedModel.load_from_checkpoint(
          ckpt_path, called=lm_called
      )
      _ = CustomHookedDataModule.load_from_checkpoint(
          ckpt_path, called=ldm_called
      )
  
      expected_lm_called = (
          [{"name": "configure_model"}]
          if override_configure_model
          else []
      )
      expected_lm_called += [
          {
              "name": "on_load_checkpoint",
              "args": ({**saved_ckpt, "hyper_parameters": ANY},),
          }
      ]
      assert lm_called == expected_lm_called
      assert ldm_called == [
          {
              "name": "load_state_dict",
              "args": (saved_ckpt[datamodule_state_dict_key],),
          }
      ]
  
imports: from functools import partial, update_wrapper
  from inspect import getmembers, isfunction
  from unittest import mock
  from unittest.mock import ANY, PropertyMock
  import pytest
  import torch
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch import Callback, LightningDataModule, LightningModule, Trainer, __version__
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel, RandomDataset
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from torch import Tensor
  from torch.utils.data import DataLoader
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 13 for calling a global function with example usage: test_load_from_checkpoint_hook_calls(override_configure_model, tmpdir) and returns: dict