code: def test_hooks_removed_after_summarize(max_depth):
      """Test that all hooks were properly removed after summary, even ones that were not run."""
      model = UnorderedModel()
      summary = ModelSummary(model, max_depth=max_depth)
      # hooks should be removed
      for _, layer in summary.summarize().items():
          handle = layer._hook_handle
          assert handle.id not in handle.hooks_dict_ref()
  
imports: from collections import OrderedDict
  from typing import Any
  import pytest
  import torch
  import torch.nn
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch import LightningModule, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.utilities.model_summary.model_summary import LEFTOVER_PARAMS_NAME, NOT_APPLICABLE, UNKNOWN_SIZE, ModelSummary, summarize
  from tests_pytorch.helpers.advanced_models import ParityModuleRNN
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 5 for calling a global function with example usage: test_hooks_removed_after_summarize(max_depth) without return types