def test_fx_validator_integration(tmp_path):
    """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=tmp_path,
        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(dict.fromkeys(not_supported, "result collection is not registered yet"))
    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)
Tries to log inside all `LightningModule` and `Callback` hooks to check any expected errors.
tests/tests_pytorch/trainer/logging_/test_logger_connector.py