class_docstr: Computes element-wise product of guided backpropagation attributions
  with upsampled (non-negative) GradCAM attributions.
  GradCAM attributions are computed with respect to the layer
  provided in the constructor, and attributions
  are upsampled to match the input size. GradCAM is designed for
  convolutional neural networks, and is usually applied to the last
  convolutional layer.
  
  Note that if multiple input tensors are provided, attributions for
  each input tensor are computed by upsampling the GradCAM
  attributions to match that input's dimensions. If interpolation is
  not possible for the input tensor dimensions and interpolation mode,
  then an empty tensor is returned in the attributions for the
  corresponding position of that input tensor. This can occur if the
  input tensor does not have the same number of dimensions as the chosen
  layer's output or is not either 3D, 4D or 5D.
  
  Note that attributions are only meaningful for input tensors
  which are spatially alligned with the chosen layer, e.g. an input
  image tensor for a convolutional layer.
  
  More details regarding GuidedGradCAM can be found in the original
  GradCAM paper here:
  https://arxiv.org/abs/1610.02391
  
  Warning: Ensure that all ReLU operations in the forward function of the
  given model are performed using a module (nn.module.ReLU).
  If nn.functional.ReLU is used, gradients are not overridden appropriately.
class_docstr_tok: ["Computes","element-wise","product","of","guided","backpropagation","attributions","with","upsampled","(","non-negative",")","GradCAM","attributions",".","GradCAM","attributions","are","computed","with","respect","to","the","layer","provided","in","the","constructor",",","and","attributions","are","upsampled","to","match","the","input","size",".","GradCAM","is","designed","for","convolutional","neural","networks",",","and","is","usually","applied","to","the","last","convolutional","layer",".","Note","that","if","multiple","input","tensors","are","provided",",","attributions","for","each","input","tensor","are","computed","by","upsampling","the","GradCAM","attributions","to","match","that","input","'s","dimensions",".","If","interpolation","is","not","possible","for","the","input","tensor","dimensions","and","interpolation","mode",",","then","an","empty","tensor","is","returned","in","the","attributions","for","the","corresponding","position","of","that","input","tensor",".","This","can","occur","if","the","input","tensor","does","not","have","the","same","number","of","dimensions","as","the","chosen","layer","'s","output","or","is","not","either","3D",",","4D","or","5D",".","Note","that","attributions","are","only","meaningful","for","input","tensors","which","are","spatially","alligned","with","the","chosen","layer",",","e.g",".","an","input","image","tensor","for","a","convolutional","layer",".","More","details","regarding","GuidedGradCAM","can","be","found","in","the","original","GradCAM","paper","here",":","https",":","\/\/arxiv.org\/abs\/1610.02391","Warning",":","Ensure","that","all","ReLU","operations","in","the","forward","function","of","the","given","model","are","performed","using","a","module","(","nn.module.ReLU",")",".","If","nn.functional.ReLU","is","used",",","gradients","are","not","overridden","appropriately","."]
docstr: Args:
  
      model (nn.Module):  The reference to PyTorch model instance.
      layer (torch.nn.Module): Layer for which GradCAM attributions are computed.
                    Currently, only layers with a single tensor output are
                    supported.
      device_ids (list[int]): Device ID list, necessary only if model
                    is a DataParallel model. This allows reconstruction of
                    intermediate outputs from batched results across devices.
                    If model is given as the DataParallel model itself,
                    then it is not necessary to provide this argument.
docstr_tok: ["Args",":","model","(","nn.Module",")",":","The","reference","to","PyTorch","model","instance",".","layer","(","torch.nn.Module",")",":","Layer","for","which","GradCAM","attributions","are","computed",".","Currently",",","only","layers","with","a","single","tensor","output","are","supported",".","device_ids","(","list","[","int","]",")",":","Device","ID","list",",","necessary","only","if","model","is","a","DataParallel","model",".","This","allows","reconstruction","of","intermediate","outputs","from","batched","results","across","devices",".","If","model","is","given","as","the","DataParallel","model","itself",",","then","it","is","not","necessary","to","provide","this","argument","."]
code: def __init__(
      self,
      model: Module,
      layer: Module,
      device_ids: Union[None, List[int]] = None,
  ) -> None:
      r"""
      Args:
  
          model (nn.Module):  The reference to PyTorch model instance.
          layer (torch.nn.Module): Layer for which GradCAM attributions are computed.
                        Currently, only layers with a single tensor output are
                        supported.
          device_ids (list[int]): Device ID list, necessary only if model
                        is a DataParallel model. This allows reconstruction of
                        intermediate outputs from batched results across devices.
                        If model is given as the DataParallel model itself,
                        then it is not necessary to provide this argument.
      """
      GradientAttribution.__init__(self, model)
      self.grad_cam = LayerGradCam(model, layer, device_ids)
      self.guided_backprop = GuidedBackprop(model)
  
file_path: captum/captum/attr/_core/guided_grad_cam.py
imports: import warnings
  from typing import Any, List, Union
  import torch
  from captum._utils.common import _format_output, _format_tensor_into_tuples, _is_tuple
  from captum._utils.typing import TargetType, TensorOrTupleOfTensorsGeneric
  from captum.attr._core.guided_backprop_deconvnet import GuidedBackprop
  from captum.attr._core.layer.grad_cam import LayerGradCam
  from captum.attr._utils.attribution import GradientAttribution, LayerAttribution
  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 GuidedGradCam object from inherited base classes: GradientAttribution with example: obj = GuidedGradCam(model, layer, device_ids)