code: def test_trainer_model_hook_system_eval(
      tmpdir,
      override_on_x_model_train,
      batches,
      verb,
      noun,
      dataloader,
      key,
  ):
      called = []
      model = HookedModel(called)
      if not override_on_x_model_train:
          setattr(model, f"on_{noun}_model_train", None)
      assert (
          is_overridden(f"on_{noun}_model_train", model)
          == override_on_x_model_train
      )
      callback = HookedCallback(called)
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=1,
          limit_val_batches=batches,
          limit_test_batches=batches,
          enable_progress_bar=False,
          enable_model_summary=False,
          callbacks=[callback],
      )
      fn = getattr(trainer, verb)
      fn(model, verbose=False)
      hooks = [
          {"name": f"{dataloader}_dataloader"},
          {"name": "train", "args": (False,)},
          {"name": f"on_{noun}_model_eval"},
          {
              "name": f"Callback.on_{noun}_start",
              "args": (trainer, model),
          },
          {"name": f"on_{noun}_start"},
          *model._eval_epoch(
              noun,
              trainer,
              model,
              batches,
              key,
              trainer.strategy.root_device,
          ),
          {"name": f"Callback.on_{noun}_end", "args": (trainer, model)},
          {"name": f"on_{noun}_end"},
          *(
              [{"name": f"on_{noun}_model_train"}]
              if override_on_x_model_train
              else []
          ),
      ]
      expected = [
          {"name": "configure_callbacks"},
          {"name": "prepare_data"},
          {
              "name": "Callback.setup",
              "args": (trainer, model),
              "kwargs": {"stage": verb},
          },
          {"name": "setup", "kwargs": {"stage": verb}},
          {"name": "configure_model"},
          {
              "name": "zero_grad",
              **(
                  {}
                  if _TORCH_GREATER_EQUAL_2_0
                  else {"kwargs": {"set_to_none": True}}
              ),
          },
          *(hooks if batches else []),
          {
              "name": "Callback.teardown",
              "args": (trainer, model),
              "kwargs": {"stage": verb},
          },
          {"name": "teardown", "kwargs": {"stage": verb}},
      ]
      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 9 for calling a global function with example usage: test_trainer_model_hook_system_eval(tmpdir, override_on_x_model_train, batches, verb, noun, dataloader, key) without return types