code: def test_fx_validator():
      funcs_name = get_members(Callback)
  
      callbacks_func = {
          "on_before_backward",
          "on_after_backward",
          "on_before_optimizer_step",
          "on_before_zero_grad",
          "on_fit_end",
          "on_fit_start",
          "on_exception",
          "on_load_checkpoint",
          "load_state_dict",
          "on_sanity_check_end",
          "on_sanity_check_start",
          "state_dict",
          "on_save_checkpoint",
          "on_test_batch_end",
          "on_test_batch_start",
          "on_test_end",
          "on_test_epoch_end",
          "on_test_epoch_start",
          "on_test_start",
          "on_train_batch_end",
          "on_train_batch_start",
          "on_train_end",
          "on_train_epoch_end",
          "on_train_epoch_start",
          "on_train_start",
          "on_validation_batch_end",
          "on_validation_batch_start",
          "on_validation_end",
          "on_validation_epoch_end",
          "on_validation_epoch_start",
          "on_validation_start",
          "on_predict_batch_end",
          "on_predict_batch_start",
          "on_predict_end",
          "on_predict_epoch_end",
          "on_predict_epoch_start",
          "on_predict_start",
          "setup",
          "teardown",
      }
  
      not_supported = {
          "on_fit_end",
          "on_fit_start",
          "on_exception",
          "on_load_checkpoint",
          "load_state_dict",
          "on_sanity_check_end",
          "on_sanity_check_start",
          "on_predict_batch_end",
          "on_predict_batch_start",
          "on_predict_end",
          "on_predict_epoch_end",
          "on_predict_epoch_start",
          "on_predict_start",
          "state_dict",
          "on_save_checkpoint",
          "on_test_end",
          "on_train_end",
          "on_validation_end",
          "setup",
          "teardown",
      }
  
      # Detected new callback function. Need to add its logging permission to FxValidator and update this test
      assert funcs_name == callbacks_func
  
      validator = _FxValidator()
  
      for func_name in funcs_name:
          # This summarizes where and what is currently possible to log using `self.log`
          is_stage = (
              "train" in func_name
              or "test" in func_name
              or "validation" in func_name
          )
          is_start = "start" in func_name or "batch" in func_name
          is_epoch = "epoch" in func_name
          on_step = is_stage and not is_start and not is_epoch
          on_epoch = True
          # creating allowed condition
          allowed = (
              is_stage
              or "batch" in func_name
              or "epoch" in func_name
              or "grad" in func_name
              or "backward" in func_name
              or "optimizer_step" in func_name
          )
          allowed = (
              allowed
              and "pretrain" not in func_name
              and "predict" not in func_name
              and func_name
              not in [
                  "on_train_end",
                  "on_test_end",
                  "on_validation_end",
              ]
          )
          if allowed:
              validator.check_logging_levels(
                  fx_name=func_name, on_step=on_step, on_epoch=on_epoch
              )
              if not is_start and is_stage:
                  with pytest.raises(
                      MisconfigurationException, match="must be one of"
                  ):
                      validator.check_logging_levels(
                          fx_name=func_name,
                          on_step=True,
                          on_epoch=on_epoch,
                      )
          else:
              assert func_name in not_supported
              with pytest.raises(
                  MisconfigurationException, match="You can't"
              ):
                  validator.check_logging(fx_name=func_name)
  
      with pytest.raises(
          RuntimeError, match="Logging inside `foo` is not implemented"
      ):
          validator.check_logging("foo")
  
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 1 for calling a global function with example usage: test_fx_validator() without return types