code: def test_fx_validator_integration(tmpdir):
      """Tries to log inside all `LightningModule` and `Callback` hooks to check any expected errors."""
      not_supported = {
          None: "`self.trainer` reference is not registered",
          "setup": "You can't",
          "configure_model": "You can't",
          "configure_optimizers": "You can't",
          "on_fit_start": "You can't",
          "train_dataloader": "You can't",
          "val_dataloader": "You can't",
          "on_before_batch_transfer": "You can't",
          "transfer_batch_to_device": "You can't",
          "on_after_batch_transfer": "You can't",
          "on_validation_end": "You can't",
          "on_train_end": "You can't",
          "on_fit_end": "You can't",
          "teardown": "You can't",
          "on_sanity_check_start": "You can't",
          "on_sanity_check_end": "You can't",
          "prepare_data": "You can't",
          "configure_callbacks": "You can't",
          "on_validation_model_zero_grad": "You can't",
          "on_validation_model_eval": "You can't",
          "on_validation_model_train": "You can't",
          "lr_scheduler_step": "You can't",
          "on_save_checkpoint": "You can't",
          "on_load_checkpoint": "You can't",
          "on_exception": "You can't",
      }
      model = HookedModel(not_supported)
  
      with pytest.warns(UserWarning, match=not_supported[None]):
          model.log("foo", 1)
  
      callback = HookedCallback(not_supported)
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=2,
          limit_train_batches=1,
          limit_val_batches=1,
          limit_test_batches=1,
          limit_predict_batches=1,
          callbacks=callback,
      )
      trainer.fit(model)
  
      not_supported.update(
          {
              # `lightning_module` ref is now present from the `fit` call
              "test_dataloader": "You can't",
              "on_test_model_eval": "You can't",
              "on_test_model_train": "You can't",
              "on_test_end": "You can't",
          }
      )
      trainer.test(model, verbose=False)
  
      not_supported.update(
          {
              k: "result collection is not registered yet"
              for k in not_supported
          }
      )
      not_supported.update(
          {
              "predict_dataloader": "result collection is not registered yet",
              "on_predict_model_eval": "result collection is not registered yet",
              "on_predict_start": "result collection is not registered yet",
              "on_predict_epoch_start": "result collection is not registered yet",
              "on_predict_batch_start": "result collection is not registered yet",
              "predict_step": "result collection is not registered yet",
              "on_predict_batch_end": "result collection is not registered yet",
              "on_predict_epoch_end": "result collection is not registered yet",
              "on_predict_end": "result collection is not registered yet",
          }
      )
      trainer.predict(model)
  
imports: import operator
  from functools import partial
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.pytorch import LightningModule
  from lightning.pytorch.callbacks.callback import Callback
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.loggers import CSVLogger
  from lightning.pytorch.trainer import Trainer
  from lightning.pytorch.trainer.connectors.logger_connector.fx_validator import _FxValidator
  from lightning.pytorch.trainer.connectors.logger_connector.result import _ResultCollection
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_9_1
  from lightning.pytorch.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_11
  from lightning_utilities.core.imports import compare_version
  from torch.utils.data import DataLoader
  from torchmetrics import Accuracy, MeanAbsoluteError, MeanSquaredError, MetricCollection
  from torchmetrics import AveragePrecision
  from tests_pytorch.models.test_hooks import get_members
label_desc: Use image node_id 2 for calling a global function with example usage: test_fx_validator_integration(tmpdir) without return types