docstr: Args:
  
      models (torch.nn.Module): One or more PyTorch modules (models) for
                    attribution visualization.
      classes (list[str]): List of strings corresponding to the names of
                    classes for classification.
      features (list[BaseFeature]): List of BaseFeatures, which correspond
                    to input arguments to the model. Each feature object defines
                    relevant transformations for converting to model input,
                    constructing baselines, and visualizing. The length of the
                    features list should exactly match the number of (tensor)
                    arguments expected by the given model.
                    For instance, an image classifier should only provide
                    a single BaseFeature, while a multimodal classifier may
                    provide a list of features, each corresponding to a different
                    tensor input and potentially different modalities.
      dataset (Iterable of Batch): Defines the dataset to visualize attributions
                    for. This must be an iterable of batch objects, each of which
                    may contain multiple input examples.
      score_func (Callable, optional): This function is applied to the model
                    output to obtain the score for each class. For instance,
                    this function could be the softmax or final non-linearity
                    of the network, applied to the model output. The indices
                    of the second dimension of the output should correspond
                    to the class names provided. If None, the model outputs
                    are taken directly and assumed to correspond to the
                    class scores.
                    Default: None
      use_label_for_attr (bool, optional): If true, the class index is passed
                    to the relevant attribution method. This is necessary in most
                    cases where there is an output neuron corresponding to each
                    class. When the model output is a scalar and class index
                    (e.g. positive, negative) is inferred from the output value,
                    this argument should be False.
                    Default: True
docstr_tok: ["Args",":","models","(","torch.nn.Module",")",":","One","or","more","PyTorch","modules","(","models",")","for","attribution","visualization",".","classes","(","list","[","str","]",")",":","List","of","strings","corresponding","to","the","names","of","classes","for","classification",".","features","(","list","[","BaseFeature","]",")",":","List","of","BaseFeatures",",","which","correspond","to","input","arguments","to","the","model",".","Each","feature","object","defines","relevant","transformations","for","converting","to","model","input",",","constructing","baselines",",","and","visualizing",".","The","length","of","the","features","list","should","exactly","match","the","number","of","(","tensor",")","arguments","expected","by","the","given","model",".","For","instance",",","an","image","classifier","should","only","provide","a","single","BaseFeature",",","while","a","multimodal","classifier","may","provide","a","list","of","features",",","each","corresponding","to","a","different","tensor","input","and","potentially","different","modalities",".","dataset","(","Iterable","of","Batch",")",":","Defines","the","dataset","to","visualize","attributions","for",".","This","must","be","an","iterable","of","batch","objects",",","each","of","which","may","contain","multiple","input","examples",".","score_func","(","Callable",",","optional",")",":","This","function","is","applied","to","the","model","output","to","obtain","the","score","for","each","class",".","For","instance",",","this","function","could","be","the","softmax","or","final","non-linearity","of","the","network",",","applied","to","the","model","output",".","The","indices","of","the","second","dimension","of","the","output","should","correspond","to","the","class","names","provided",".","If","None",",","the","model","outputs","are","taken","directly","and","assumed","to","correspond","to","the","class","scores",".","Default",":","None","use_label_for_attr","(","bool",",","optional",")",":","If","true",",","the","class","index","is","passed","to","the","relevant","attribution","method",".","This","is","necessary","in","most","cases","where","there","is","an","output","neuron","corresponding","to","each","class",".","When","the","model","output","is","a","scalar","and","class","index","(","e.g",".","positive",",","negative",")","is","inferred","from","the","output","value",",","this","argument","should","be","False",".","Default",":","True"]
code: def __init__(
      self,
      models: Union[List[Module], Module],
      classes: List[str],
      features: Union[List[BaseFeature], BaseFeature],
      dataset: Iterable[Batch],
      score_func: Optional[Callable] = None,
      use_label_for_attr: bool = True,
  ) -> None:
      r"""
      Args:
  
          models (torch.nn.Module): One or more PyTorch modules (models) for
                        attribution visualization.
          classes (list[str]): List of strings corresponding to the names of
                        classes for classification.
          features (list[BaseFeature]): List of BaseFeatures, which correspond
                        to input arguments to the model. Each feature object defines
                        relevant transformations for converting to model input,
                        constructing baselines, and visualizing. The length of the
                        features list should exactly match the number of (tensor)
                        arguments expected by the given model.
                        For instance, an image classifier should only provide
                        a single BaseFeature, while a multimodal classifier may
                        provide a list of features, each corresponding to a different
                        tensor input and potentially different modalities.
          dataset (Iterable of Batch): Defines the dataset to visualize attributions
                        for. This must be an iterable of batch objects, each of which
                        may contain multiple input examples.
          score_func (Callable, optional): This function is applied to the model
                        output to obtain the score for each class. For instance,
                        this function could be the softmax or final non-linearity
                        of the network, applied to the model output. The indices
                        of the second dimension of the output should correspond
                        to the class names provided. If None, the model outputs
                        are taken directly and assumed to correspond to the
                        class scores.
                        Default: None
          use_label_for_attr (bool, optional): If true, the class index is passed
                        to the relevant attribution method. This is necessary in most
                        cases where there is an output neuron corresponding to each
                        class. When the model output is a scalar and class index
                        (e.g. positive, negative) is inferred from the output value,
                        this argument should be False.
                        Default: True
      """
      if not isinstance(models, List):
          models = [models]
  
      if not isinstance(features, List):
          features = [features]
  
      self.classes = classes
      self.features = features
      self.dataset = dataset
      self.models = models
      self.attribution_calculation = AttributionCalculation(
          models, classes, features, score_func, use_label_for_attr
      )
      self._outputs: List[VisualizationOutput] = []
      self._config = FilterConfig(
          prediction="all", classes=[], num_examples=4
      )
      self._dataset_iter = iter(dataset)
      self._dataset_cache: List[Batch] = []
  
imports: from collections import namedtuple
  from itertools import cycle
  from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Tuple, Union
  import torch
  from captum.attr import IntegratedGradients
  from captum.attr._utils.batching import _batched_generator
  from captum.insights.attr_vis.attribution_calculation import AttributionCalculation, OutputScore
  from captum.insights.attr_vis.config import ATTRIBUTION_METHOD_CONFIG, ATTRIBUTION_NAMES_TO_METHODS
  from captum.insights.attr_vis.features import BaseFeature
  from captum.insights.attr_vis.server import namedtuple_to_dict
  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 AttributionVisualizer object  with example: obj = AttributionVisualizer(models, classes, features, dataset, score_func, use_label_for_attr)