class_docstr: Implements DeepLIFT algorithm for the layer based on the following paper:
  Learning Important Features Through Propagating Activation Differences,
  Avanti Shrikumar, et. al.
  https://arxiv.org/abs/1704.02685
  
  and the gradient formulation proposed in:
  Towards better understanding of gradient-based attribution methods for
  deep neural networks,  Marco Ancona, et.al.
  https://openreview.net/pdf?id=Sy21R9JAW
  
  This implementation supports only Rescale rule. RevealCancel rule will
  be supported in later releases.
  Although DeepLIFT's(Rescale Rule) attribution quality is comparable with
  Integrated Gradients, it runs significantly faster than Integrated
  Gradients and is preferred for large datasets.
  
  Currently we only support a limited number of non-linear activations
  but the plan is to expand the list in the future.
  
  Note: As we know, currently we cannot access the building blocks,
  of PyTorch's built-in LSTM, RNNs and GRUs such as Tanh and Sigmoid.
  Nonetheless, it is possible to build custom LSTMs, RNNS and GRUs
  with performance similar to built-in ones using TorchScript.
  More details on how to build custom RNNs can be found here:
  https://pytorch.org/blog/optimizing-cuda-rnn-with-torchscript/
class_docstr_tok: ["Implements","DeepLIFT","algorithm","for","the","layer","based","on","the","following","paper",":","Learning","Important","Features","Through","Propagating","Activation","Differences",",","Avanti","Shrikumar",",","et",".","al",".","https",":","\/\/arxiv.org\/abs\/1704.02685","and","the","gradient","formulation","proposed","in",":","Towards","better","understanding","of","gradient-based","attribution","methods","for","deep","neural","networks",",","Marco","Ancona",",","et.al",".","https",":","\/\/openreview.net\/pdf","?","id=Sy21R9JAW","This","implementation","supports","only","Rescale","rule",".","RevealCancel","rule","will","be","supported","in","later","releases",".","Although","DeepLIFT","'s","(","Rescale","Rule",")","attribution","quality","is","comparable","with","Integrated","Gradients",",","it","runs","significantly","faster","than","Integrated","Gradients","and","is","preferred","for","large","datasets",".","Currently","we","only","support","a","limited","number","of","non-linear","activations","but","the","plan","is","to","expand","the","list","in","the","future",".","Note",":","As","we","know",",","currently","we","can","not","access","the","building","blocks",",","of","PyTorch","'s","built-in","LSTM",",","RNNs","and","GRUs","such","as","Tanh","and","Sigmoid",".","Nonetheless",",","it","is","possible","to","build","custom","LSTMs",",","RNNS","and","GRUs","with","performance","similar","to","built-in","ones","using","TorchScript",".","More","details","on","how","to","build","custom","RNNs","can","be","found","here",":","https",":","\/\/pytorch.org\/blog\/optimizing-cuda-rnn-with-torchscript\/"]
docstr: Args:
  
      model (nn.Module):  The reference to PyTorch model instance.
      layer (torch.nn.Module): Layer 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.
      multiply_by_inputs (bool, optional): Indicates whether to factor
                  model inputs' multiplier in the final attribution scores.
                  In the literature this is also known as local vs global
                  attribution. If inputs' multiplier isn't factored in
                  then that type of attribution method is also called local
                  attribution. If it is, then that type of attribution
                  method is called global.
                  More detailed can be found here:
                  https://arxiv.org/abs/1711.06104
  
                  In case of Layer DeepLift, if `multiply_by_inputs`
                  is set to True, final sensitivity scores
                  are being multiplied by
                  layer activations for inputs - layer activations for baselines.
                  This flag applies only if `custom_attribution_func` is
                  set to None.
docstr_tok: ["Args",":","model","(","nn.Module",")",":","The","reference","to","PyTorch","model","instance",".","layer","(","torch.nn.Module",")",":","Layer","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",".","multiply_by_inputs","(","bool",",","optional",")",":","Indicates","whether","to","factor","model","inputs","'","multiplier","in","the","final","attribution","scores",".","In","the","literature","this","is","also","known","as","local","vs","global","attribution",".","If","inputs","'","multiplier","is","n't","factored","in","then","that","type","of","attribution","method","is","also","called","local","attribution",".","If","it","is",",","then","that","type","of","attribution","method","is","called","global",".","More","detailed","can","be","found","here",":","https",":","\/\/arxiv.org\/abs\/1711.06104","In","case","of","Layer","DeepLift",",","if","`","multiply_by_inputs","`","is","set","to","True",",","final","sensitivity","scores","are","being","multiplied","by","layer","activations","for","inputs","-","layer","activations","for","baselines",".","This","flag","applies","only","if","`","custom_attribution_func","`","is","set","to","None","."]
code: def __init__(
      self,
      model: Module,
      layer: Module,
      multiply_by_inputs: bool = True,
  ) -> None:
      r"""
      Args:
  
          model (nn.Module):  The reference to PyTorch model instance.
          layer (torch.nn.Module): Layer 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.
          multiply_by_inputs (bool, optional): Indicates whether to factor
                      model inputs' multiplier in the final attribution scores.
                      In the literature this is also known as local vs global
                      attribution. If inputs' multiplier isn't factored in
                      then that type of attribution method is also called local
                      attribution. If it is, then that type of attribution
                      method is called global.
                      More detailed can be found here:
                      https://arxiv.org/abs/1711.06104
  
                      In case of Layer DeepLift, if `multiply_by_inputs`
                      is set to True, final sensitivity scores
                      are being multiplied by
                      layer activations for inputs - layer activations for baselines.
                      This flag applies only if `custom_attribution_func` is
                      set to None.
      """
      LayerAttribution.__init__(self, model, layer)
      DeepLift.__init__(self, model)
      self.model = model
      self._multiply_by_inputs = multiply_by_inputs
  
imports: import typing
  from typing import Any, Callable, cast, Sequence, Tuple, Union
  import torch
  from captum._utils.common import _expand_target, _format_additional_forward_args, _format_baseline, _format_tensor_into_tuples, ExpansionTypes
  from captum._utils.gradient import compute_layer_gradients_and_eval
  from captum._utils.typing import BaselineType, Literal, TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.deep_lift import DeepLift, DeepLiftShap
  from captum.attr._utils.attribution import LayerAttribution
  from captum.attr._utils.common import _call_custom_attribution_func, _compute_conv_delta_and_format_attrs, _format_callable_baseline, _tensorize_baseline, _validate_input
  from captum.log import log_usage
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 1 to create a new LayerDeepLift object from inherited base classes: LayerAttribution, DeepLift with example: obj = LayerDeepLift(model, layer, multiply_by_inputs)