code: def __init__(self, not_supported):
      super().__init__()
      pl_module_hooks = get_members(LightningModule)
      pl_module_hooks.difference_update({"log", "log_dict"})
      pl_module_hooks.discard("configure_sharded_model")
      # remove `nn.Module` hooks
      module_hooks = get_members(torch.nn.Module)
      pl_module_hooks.difference_update(module_hooks)
  
      def call(hook, fn, *args, **kwargs):
          out = fn(*args, **kwargs)
  
          if hook in not_supported:
              with pytest.raises(
                  MisconfigurationException, match=not_supported[hook]
              ):
                  self.log("anything", 1)
          else:
              self.log(hook, 1)
          return out
  
      for h in pl_module_hooks:
          attr = getattr(self, h)
          setattr(self, h, partial(call, h, attr))
  
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 HookedModel object from inherited base classes: BoringModel with example: obj = HookedModel(not_supported)