class_docstr: Layer-wise relevance propagation is based on a backward propagation
  mechanism applied sequentially to all layers of the model. Here, the
  model output score represents the initial relevance which is decomposed
  into values for each neuron of the underlying layers. The decomposition
  is defined by rules that are chosen for each layer, involving its weights
  and activations. Details on the model can be found in the original paper
  [https://doi.org/10.1371/journal.pone.0130140]. The implementation is
  inspired by the tutorial of the same group
  [https://doi.org/10.1016/j.dsp.2017.10.011] and the publication by
  Ancona et al. [https://openreview.net/forum?id=Sy21R9JAW].
class_docstr_tok: ["Layer-wise","relevance","propagation","is","based","on","a","backward","propagation","mechanism","applied","sequentially","to","all","layers","of","the","model",".","Here",",","the","model","output","score","represents","the","initial","relevance","which","is","decomposed","into","values","for","each","neuron","of","the","underlying","layers",".","The","decomposition","is","defined","by","rules","that","are","chosen","for","each","layer",",","involving","its","weights","and","activations",".","Details","on","the","model","can","be","found","in","the","original","paper","[","https",":","\/\/doi.org\/10.1371\/journal.pone.0130140","]",".","The","implementation","is","inspired","by","the","tutorial","of","the","same","group","[","https",":","\/\/doi.org\/10.1016\/j.dsp.2017.10.011","]","and","the","publication","by","Ancona","et","al",".","[","https",":","\/\/openreview.net\/forum","?","id=Sy21R9JAW","]","."]
docstr: Args:
  
      model (Module): The forward function of the model or
                  any modification of it. Custom rules for a given layer need to
                  be defined as attribute
                  `module.rule` and need to be of type PropagationRule.
  
      layer (torch.nn.Module or list(torch.nn.Module)): Layer or layers
                    for which attributions are computed.
                    The size and dimensionality of the attributions
                    corresponds to the size and dimensionality of the layer's
                    input or output depending on whether we attribute to the
                    inputs or outputs of the layer. If value is None, the
                    relevance for all layers is returned in attribution.
docstr_tok: ["Args",":","model","(","Module",")",":","The","forward","function","of","the","model","or","any","modification","of","it",".","Custom","rules","for","a","given","layer","need","to","be","defined","as","attribute","`","module.rule","`","and","need","to","be","of","type","PropagationRule",".","layer","(","torch.nn.Module","or","list","(","torch.nn.Module",")",")",":","Layer","or","layers","for","which","attributions","are","computed",".","The","size","and","dimensionality","of","the","attributions","corresponds","to","the","size","and","dimensionality","of","the","layer's","input","or","output","depending","on","whether","we","attribute","to","the","inputs","or","outputs","of","the","layer",".","If","value","is","None",",","the","relevance","for","all","layers","is","returned","in","attribution","."]
code: def __init__(self, model: Module, layer: ModuleOrModuleList) -> None:
      """
      Args:
  
          model (Module): The forward function of the model or
                      any modification of it. Custom rules for a given layer need to
                      be defined as attribute
                      `module.rule` and need to be of type PropagationRule.
  
          layer (torch.nn.Module or list(torch.nn.Module)): Layer or layers
                        for which attributions are computed.
                        The size and dimensionality of the attributions
                        corresponds to the size and dimensionality of the layer's
                        input or output depending on whether we attribute to the
                        inputs or outputs of the layer. If value is None, the
                        relevance for all layers is returned in attribution.
      """
      LayerAttribution.__init__(self, model, layer)
      LRP.__init__(self, model)
      if hasattr(self.model, "device_ids"):
          self.device_ids = cast(List[int], self.model.device_ids)
  
file_path: captum/captum/attr/_core/layer/layer_lrp.py
imports: import typing
  from typing import Any, cast, List, Tuple, Union
  from captum._utils.common import _format_tensor_into_tuples, _reduce_list, _sort_key_list
  from captum._utils.gradient import apply_gradient_requirements, compute_gradients, undo_gradient_requirements
  from captum._utils.typing import Literal, ModuleOrModuleList, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.lrp import LRP
  from captum.attr._utils.attribution import LayerAttribution
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 1 to create a new LayerLRP object from inherited base classes: LRP, LayerAttribution with example: obj = LayerLRP(model, layer)