code: def test_trainer_model_hook_system_fit_no_val_and_resume_max_steps(
      tmpdir,
  ):
      # initial training to get a checkpoint
      model = BoringModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_steps=1,
          limit_val_batches=0,
          enable_progress_bar=False,
          enable_model_summary=False,
          callbacks=[HookedCallback([])],
      )
      trainer.fit(model)
      best_model_path = trainer.checkpoint_callback.best_model_path
  
      # resume from checkpoint with HookedModel
      called = []
      model = HookedModel(called)
      callback = HookedCallback(called)
  
      # already performed 1 step, resume and do 2 more
      train_batches = 2
      steps_after_reload = 1 + train_batches
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_steps=steps_after_reload,
          limit_val_batches=0,
          enable_progress_bar=False,
          enable_model_summary=False,
          callbacks=[callback],
      )
  
      trainer.fit(model, ckpt_path=best_model_path)
      loaded_ckpt = {
          "callbacks": ANY,
          "epoch": 0,
          "global_step": 1,
          "lr_schedulers": ANY,
          "optimizer_states": ANY,
          "pytorch-lightning_version": __version__,
          "state_dict": ANY,
          "loops": ANY,
      }
      saved_ckpt = {**loaded_ckpt, "global_step": steps_after_reload}
      expected = [
          {"name": "configure_callbacks"},
          {"name": "prepare_data"},
          {
              "name": "Callback.setup",
              "args": (trainer, model),
              "kwargs": {"stage": "fit"},
          },
          {"name": "setup", "kwargs": {"stage": "fit"}},
          {"name": "configure_model"},
          {"name": "on_load_checkpoint", "args": (loaded_ckpt,)},
          {
              "name": "Callback.on_load_checkpoint",
              "args": (trainer, model, loaded_ckpt),
          },
          {
              "name": "Callback.load_state_dict",
              "args": ({"foo": True},),
          },
          {"name": "configure_optimizers"},
          {"name": "Callback.on_fit_start", "args": (trainer, model)},
          {"name": "on_fit_start"},
          {
              "name": "zero_grad",
              **(
                  {}
                  if _TORCH_GREATER_EQUAL_2_0
                  else {"kwargs": {"set_to_none": True}}
              ),
          },
          {"name": "train_dataloader"},
          {"name": "Callback.on_train_start", "args": (trainer, model)},
          {"name": "on_train_start"},
          {
              "name": "Callback.on_train_epoch_start",
              "args": (trainer, model),
          },
          {"name": "on_train_epoch_start"},
          *model._train_batch(
              trainer,
              model,
              steps_after_reload,
              trainer.strategy.root_device,
              current_batch=1,
          ),
          {
              "name": "Callback.on_train_epoch_end",
              "args": (trainer, model),
          },
          {
              "name": "on_train_epoch_end"
          },  # before ModelCheckpoint because it's a "monitoring callback"
          # `ModelCheckpoint.save_checkpoint` is called here
          {"name": "Callback.state_dict"},
          {
              "name": "Callback.on_save_checkpoint",
              "args": (trainer, model, saved_ckpt),
          },
          {"name": "on_save_checkpoint", "args": (saved_ckpt,)},
          {"name": "Callback.on_train_end", "args": (trainer, model)},
          {"name": "on_train_end"},
          {"name": "Callback.on_fit_end", "args": (trainer, model)},
          {"name": "on_fit_end"},
          {
              "name": "Callback.teardown",
              "args": (trainer, model),
              "kwargs": {"stage": "fit"},
          },
          {"name": "teardown", "kwargs": {"stage": "fit"}},
      ]
      assert called == expected
  
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 8 for calling a global function with example usage: test_trainer_model_hook_system_fit_no_val_and_resume_max_steps(tmpdir) without return types