class_docstr: A module that wraps another layer in which some weights will be replaced by 0 during training.
class_docstr_tok: ["A","module","that","wraps","another","layer","in","which","some","weights","will","be","replaced","by","0","during","training","."]
code: def __init__(
      self,
      module: nn.Module,  # Wrapped module
      weight_p: float,  # Weight dropout probability
      layer_names: str
      | MutableSequence = "weight_hh_l0",  # Name(s) of the parameters to apply dropout to
  ):
      self.module, self.weight_p, self.layer_names = (
          module,
          weight_p,
          L(layer_names),
      )
      for layer in self.layer_names:
          # Makes a copy of the weights of the selected layers.
          w = getattr(self.module, layer)
          delattr(self.module, layer)
          self.register_parameter(f"{layer}_raw", nn.Parameter(w.data))
          setattr(self.module, layer, w.clone())
          if isinstance(
              self.module, (nn.RNNBase, nn.modules.rnn.RNNBase)
          ):
              self.module.flatten_parameters = self._do_nothing
  
imports: from __future__ import annotations
  from ...data.all import *
  from ..core import *
label_desc: Use image node_id 1 to create a new WeightDropout object from inherited base classes: Module with example: obj = WeightDropout(module, weight_p, layer_names)