code: def __init__(self, not_supported):
      def call(hook, trainer=None, model=None, *_, **__):
          if trainer is None:
              # `state_dict`, `load_state_dict` do not have the `Trainer` available
              assert hook in ("state_dict", "load_state_dict")
              return
  
          lightning_module = trainer.lightning_module or model
  
          if hook in not_supported:
              with pytest.raises(
                  MisconfigurationException, match=not_supported[hook]
              ):
                  lightning_module.log("anything", 1)
          else:
              lightning_module.log(hook, 1)
  
      for h in get_members(Callback):
          setattr(self, h, partial(call, h))
  
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 to create a new HookedCallback object from inherited base classes: Callback with example: obj = HookedCallback(not_supported)