class_docstr: Class for computing the relevance propagation and supplying
  the necessary forward hooks for all layers.
class_docstr_tok: ["Class","for","computing","the","relevance","propagation","and","supplying","the","necessary","forward","hooks","for","all","layers","."]
docstr: Each layer might need to save very specific data during the forward
  pass in order to allow for relevance propagation in the backward
  pass. For example, for max_pooling, we need to store the
  indices of the max values. In convolutional layers, we need to calculate
  the normalizations, to ensure the overall amount of relevance is conserved.
  
  Args:
      layer: Layer instance for which forward hook is needed.
  
  Returns:
      Layer-specific forward hook.
docstr_tok: ["Each","layer","might","need","to","save","very","specific","data","during","the","forward","pass","in","order","to","allow","for","relevance","propagation","in","the","backward","pass",".","For","example",",","for","max_pooling",",","we","need","to","store","the","indices","of","the","max","values",".","In","convolutional","layers",",","we","need","to","calculate","the","normalizations",",","to","ensure","the","overall","amount","of","relevance","is","conserved",".","Args",":","layer",":","Layer","instance","for","which","forward","hook","is","needed",".","Returns",":","Layer-specific","forward","hook","."]
code: def get_layer_fwd_hook(self, layer):
      """
      Each layer might need to save very specific data during the forward
      pass in order to allow for relevance propagation in the backward
      pass. For example, for max_pooling, we need to store the
      indices of the max values. In convolutional layers, we need to calculate
      the normalizations, to ensure the overall amount of relevance is conserved.
  
      Args:
          layer: Layer instance for which forward hook is needed.
  
      Returns:
          Layer-specific forward hook.
  
      """
  
      if isinstance(
          layer,
          (torch.nn.MaxPool1d, torch.nn.MaxPool2d, torch.nn.MaxPool3d),
      ):
          return self.max_pool_nd_fwd_hook
  
      if isinstance(
          layer, (torch.nn.Conv1d, torch.nn.Conv2d, torch.nn.Conv3d)
      ):
          return self.conv_nd_fwd_hook
  
      if isinstance(layer, self.allowed_pass_layers):
          return self.silent_pass  # No hook needed.
  
      if isinstance(layer, torch.nn.Linear):
          return self.linear_fwd_hook
  
      else:
          raise NotImplementedError(
              "The network contains layers that"
              " are currently not supported {0:s}".format(str(layer))
          )
  
imports: import torch
  import torch.nn
  import numpy
  import torch.nn.functional
label_desc: Use image node_id 4 for calling the RelevancePropagator obj's underlying member method code with example usage: obj.get_layer_fwd_hook(layer) and returns: self, self, self, self