class_docstr: Hooks-based implementation of AbstractGradSampleModule
  
  Computes per-sample gradients using custom-written methods for each layer.
  See README.md for more details
docstr: Removes hooks added by ``add_hooks()``
docstr_tok: ["Removes","hooks","added","by","``","add_hooks","(",")","``"]
code: def remove_hooks(self) -> None:
      """
      Removes hooks added by ``add_hooks()``
      """
      self.disable_hooks()
  
      for p in self.parameters():
          if hasattr(p, "ddp_hooks"):
              while p.ddp_hooks:
                  handle = p.ddp_hooks.pop()
                  handle.remove()
              delattr(p, "ddp_hooks")
  
      if not hasattr(self, "autograd_grad_sample_hooks"):
          raise ValueError("Asked to remove hooks, but no hooks found")
      else:
          while self.autograd_grad_sample_hooks:
              handle = self.autograd_grad_sample_hooks.pop()
              handle.remove()
          delattr(self, "autograd_grad_sample_hooks")
          delattr(self._module, "autograd_grad_sample_hooks")
  
      # Remove functorch hooks
      for _module_name, module in trainable_modules(self._module):
          if hasattr(module, "ft_compute_sample_grad"):
              delattr(module, "ft_compute_sample_grad")
  
imports: from __future__ import annotations
  import logging
  import warnings
  from functools import partial
  from typing import Iterable, List, Tuple
  import torch
  import torch.nn
  from opacus.grad_sample.functorch import ft_compute_per_sample_gradient, prepare_layer
  from opacus.grad_sample.gsm_base import AbstractGradSampleModule
  from opacus.layers.dp_rnn import DPGRU, DPLSTM, DPRNN, RNNLinear
  from opacus.utils.module_utils import has_trainable_params, requires_grad, trainable_modules, trainable_parameters
label_desc: Use image node_id 5 for calling the GradSampleModule obj's underlying member method code with example usage: obj.remove_hooks() without return types