class_docstr: Layer Integrated Gradients is a variant of Integrated Gradients that assigns
  an importance score to layer inputs or outputs, depending on whether we
  attribute to the former or to the latter one.
  
  Integrated Gradients is an axiomatic model interpretability algorithm that
  attributes / assigns an importance score to each input feature by approximating
  the integral of gradients of the model's output with respect to the inputs
  along the path (straight line) from given baselines / references to inputs.
  
  Baselines can be provided as input arguments to attribute method.
  To approximate the integral we can choose to use either a variant of
  Riemann sum or Gauss-Legendre quadrature rule.
  
  More details regarding the integrated gradients method can be found in the
  original paper:
  https://arxiv.org/abs/1703.01365
docstr: Args:
  
      forward_func (Callable): The forward function of the model or any
                  modification of it
      layer (ModuleOrModuleList): Layer or list of layers for which attributions
                  are computed. For each layer the output size of the attribute
                  matches this layer's input or output dimensions, depending on
                  whether we attribute to the inputs or outputs of the
                  layer, corresponding to the attribution of each neuron
                  in the input or output of this layer.
  
                  Please note that layers to attribute on cannot be
                  dependent on each other. That is, a subset of layers in
                  `layer` cannot produce the inputs for another layer.
  
                  For example, if your model is of a simple linked-list
                  based graph structure (think nn.Sequence), e.g. x -> l1
                  -> l2 -> l3 -> output. If you pass in any one of those
                  layers, you cannot pass in another due to the
                  dependence, e.g.  if you pass in l2 you cannot pass in
                  l1 or l3.
  
      device_ids (list[int]): Device ID list, necessary only if forward_func
                  applies a DataParallel model. This allows reconstruction of
                  intermediate outputs from batched results across devices.
                  If forward_func is given as the DataParallel model itself,
                  then it is not necessary to provide this argument.
      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 this 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 integrated gradients, if `multiply_by_inputs`
                  is set to True, final sensitivity scores are being multiplied by
                  layer activations for inputs - layer activations for baselines.
docstr_tok: ["Args",":","forward_func","(","Callable",")",":","The","forward","function","of","the","model","or","any","modification","of","it","layer","(","ModuleOrModuleList",")",":","Layer","or","list","of","layers","for","which","attributions","are","computed",".","For","each","layer","the","output","size","of","the","attribute","matches","this","layer","'s","input","or","output","dimensions",",","depending","on","whether","we","attribute","to","the","inputs","or","outputs","of","the","layer",",","corresponding","to","the","attribution","of","each","neuron","in","the","input","or","output","of","this","layer",".","Please","note","that","layers","to","attribute","on","can","not","be","dependent","on","each","other",".","That","is",",","a","subset","of","layers","in","`","layer","`","can","not","produce","the","inputs","for","another","layer",".","For","example",",","if","your","model","is","of","a","simple","linked-list","based","graph","structure","(","think","nn.Sequence",")",",","e.g",".","x","-",">","l1","-",">","l2","-",">","l3","-",">","output",".","If","you","pass","in","any","one","of","those","layers",",","you","can","not","pass","in","another","due","to","the","dependence",",","e.g",".","if","you","pass","in","l2","you","can","not","pass","in","l1","or","l3",".","device_ids","(","list","[","int","]",")",":","Device","ID","list",",","necessary","only","if","forward_func","applies","a","DataParallel","model",".","This","allows","reconstruction","of","intermediate","outputs","from","batched","results","across","devices",".","If","forward_func","is","given","as","the","DataParallel","model","itself",",","then","it","is","not","necessary","to","provide","this","argument",".","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","this","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","integrated","gradients",",","if","`","multiply_by_inputs","`","is","set","to","True",",","final","sensitivity","scores","are","being","multiplied","by","layer","activations","for","inputs","-","layer","activations","for","baselines","."]
code: def __init__(
      self,
      forward_func: Callable,
      layer: ModuleOrModuleList,
      device_ids: Union[None, List[int]] = None,
      multiply_by_inputs: bool = True,
  ) -> None:
      r"""
      Args:
  
          forward_func (Callable): The forward function of the model or any
                      modification of it
          layer (ModuleOrModuleList): Layer or list of layers for which attributions
                      are computed. For each layer the output size of the attribute
                      matches this layer's input or output dimensions, depending on
                      whether we attribute to the inputs or outputs of the
                      layer, corresponding to the attribution of each neuron
                      in the input or output of this layer.
  
                      Please note that layers to attribute on cannot be
                      dependent on each other. That is, a subset of layers in
                      `layer` cannot produce the inputs for another layer.
  
                      For example, if your model is of a simple linked-list
                      based graph structure (think nn.Sequence), e.g. x -> l1
                      -> l2 -> l3 -> output. If you pass in any one of those
                      layers, you cannot pass in another due to the
                      dependence, e.g.  if you pass in l2 you cannot pass in
                      l1 or l3.
  
          device_ids (list[int]): Device ID list, necessary only if forward_func
                      applies a DataParallel model. This allows reconstruction of
                      intermediate outputs from batched results across devices.
                      If forward_func is given as the DataParallel model itself,
                      then it is not necessary to provide this argument.
          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 this 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 integrated gradients, if `multiply_by_inputs`
                      is set to True, final sensitivity scores are being multiplied by
                      layer activations for inputs - layer activations for baselines.
  
      """
      LayerAttribution.__init__(
          self, forward_func, layer, device_ids=device_ids
      )
      GradientAttribution.__init__(self, forward_func)
      self.ig = IntegratedGradients(forward_func, multiply_by_inputs)
  
      if isinstance(layer, list) and len(layer) > 1:
          warnings.warn(
              "Multiple layers provided. Please ensure that each layer is"
              "**not** solely dependent on the outputs of"
              "another layer. Please refer to the documentation for more"
              "detail."
          )
  
imports: import functools
  import warnings
  from typing import Any, Callable, List, overload, Tuple, Union
  import torch
  from captum._utils.common import _extract_device, _format_additional_forward_args, _format_outputs
  from captum._utils.gradient import _forward_layer_eval, _run_forward
  from captum._utils.typing import BaselineType, Literal, ModuleOrModuleList, TargetType
  from captum.attr._core.integrated_gradients import IntegratedGradients
  from captum.attr._utils.attribution import GradientAttribution, LayerAttribution
  from captum.attr._utils.common import _format_input_baseline, _tensorize_baseline, _validate_input
  from captum.log import log_usage
  from torch import Tensor
  from torch.nn.parallel.scatter_gather import scatter
label_desc: Use image node_id 1 to create a new LayerIntegratedGradients object from inherited base classes: LayerAttribution, GradientAttribution with example: obj = LayerIntegratedGradients(forward_func, layer, device_ids, multiply_by_inputs)