class_docstr: Allows measuring model robustness for a given attack or set of attacks. This class
  can be used with any metric(s) as well as any set of attacks, either based on
  attacks / perturbations from captum.robust such as FGSM or PGD or external
  augmentation methods or perturbations such as torchvision transforms.
docstr: Adds attack to be evaluated when calling evaluate.
  
  Args:
  
      attack (Perturbation or Callable): This can either be an instance
          of a Captum Perturbation / Attack
          or any other perturbation or attack function such
          as a torchvision transform.
  
      name (str, optional): Name or identifier for attack, used as key for
          attack results. This defaults to attack.__class__.__name__
          if not provided and must be unique for all added attacks.
          Default: ``None``
  
      num_attempts (int, optional): Number of attempts that attack should be
          repeated. This should only be set to > 1 for non-deterministic
          attacks. The minimum, maximum, and average (best, worst, and
          average case) are tracked for attack attempts.
          Default: ``1``
  
      apply_before_preproc (bool, optional): Defines whether attack should be
          applied before or after preproc function.
          Default: ``True``
  
      attack_kwargs (dict, optional): Additional arguments to be provided to
          given attack. This should be provided as a dictionary of keyword
          arguments.
          Default: ``None``
  
      additional_attack_arg_names (list[str], optional): Any additional
          arguments for the attack which are specific to the particular input
          example or batch. An example of this is target, which is necessary
          for some attacks such as FGSM or PGD. These arguments are included
          if provided as a kwarg to evaluate.
          Default: ``None``
docstr_tok: ["Adds","attack","to","be","evaluated","when","calling","evaluate",".","Args",":","attack","(","Perturbation","or","Callable",")",":","This","can","either","be","an","instance","of","a","Captum","Perturbation","\/","Attack","or","any","other","perturbation","or","attack","function","such","as","a","torchvision","transform",".","name","(","str",",","optional",")",":","Name","or","identifier","for","attack",",","used","as","key","for","attack","results",".","This","defaults","to","attack.__class__.__name__","if","not","provided","and","must","be","unique","for","all","added","attacks",".","Default",":","``","None","``","num_attempts","(","int",",","optional",")",":","Number","of","attempts","that","attack","should","be","repeated",".","This","should","only","be","set","to",">","1","for","non-deterministic","attacks",".","The","minimum",",","maximum",",","and","average","(","best",",","worst",",","and","average","case",")","are","tracked","for","attack","attempts",".","Default",":","``","1","``","apply_before_preproc","(","bool",",","optional",")",":","Defines","whether","attack","should","be","applied","before","or","after","preproc","function",".","Default",":","``","True","``","attack_kwargs","(","dict",",","optional",")",":","Additional","arguments","to","be","provided","to","given","attack",".","This","should","be","provided","as","a","dictionary","of","keyword","arguments",".","Default",":","``","None","``","additional_attack_arg_names","(","list","[","str","]",",","optional",")",":","Any","additional","arguments","for","the","attack","which","are","specific","to","the","particular","input","example","or","batch",".","An","example","of","this","is","target",",","which","is","necessary","for","some","attacks","such","as","FGSM","or","PGD",".","These","arguments","are","included","if","provided","as","a","kwarg","to","evaluate",".","Default",":","``","None","``"]
code: def add_attack(
      self,
      attack: Union[Perturbation, Callable],
      name: Optional[str] = None,
      num_attempts: int = 1,
      apply_before_preproc: bool = True,
      attack_kwargs: Optional[Dict[str, Any]] = None,
      additional_attack_arg_names: Optional[List[str]] = None,
  ) -> None:
      r"""
      Adds attack to be evaluated when calling evaluate.
  
      Args:
  
          attack (Perturbation or Callable): This can either be an instance
              of a Captum Perturbation / Attack
              or any other perturbation or attack function such
              as a torchvision transform.
  
          name (str, optional): Name or identifier for attack, used as key for
              attack results. This defaults to attack.__class__.__name__
              if not provided and must be unique for all added attacks.
              Default: ``None``
  
          num_attempts (int, optional): Number of attempts that attack should be
              repeated. This should only be set to > 1 for non-deterministic
              attacks. The minimum, maximum, and average (best, worst, and
              average case) are tracked for attack attempts.
              Default: ``1``
  
          apply_before_preproc (bool, optional): Defines whether attack should be
              applied before or after preproc function.
              Default: ``True``
  
          attack_kwargs (dict, optional): Additional arguments to be provided to
              given attack. This should be provided as a dictionary of keyword
              arguments.
              Default: ``None``
  
          additional_attack_arg_names (list[str], optional): Any additional
              arguments for the attack which are specific to the particular input
              example or batch. An example of this is target, which is necessary
              for some attacks such as FGSM or PGD. These arguments are included
              if provided as a kwarg to evaluate.
              Default: ``None``
      """
      if name is None:
          name = attack.__class__.__name__
  
      if attack_kwargs is None:
          attack_kwargs = {}
  
      if additional_attack_arg_names is None:
          additional_attack_arg_names = []
  
      if name in self.attacks:
          raise RuntimeError(
              "Cannot add attack with same name as existing attack {}".format(
                  name
              )
          )
  
      self.attacks[name] = AttackInfo(
          attack_fn=attack,
          name=name,
          num_attempts=num_attempts,
          apply_before_preproc=apply_before_preproc,
          attack_kwargs=attack_kwargs,
          additional_args=additional_attack_arg_names,
      )
  
imports: import warnings
  from collections import namedtuple
  from typing import Any, Callable, cast, Dict, Generic, List, NamedTuple, Optional, Tuple, TypeVar, Union
  from captum._utils.common import _expand_additional_forward_args, _format_additional_forward_args, _reduce_list
  from captum.attr import Max, Mean, Min, Summarizer
  from captum.log import log_usage
  from captum.robust._core.perturbation import Perturbation
  from torch import Tensor
label_desc: Use image node_id 2 for calling the AttackComparator obj's underlying member method code with example usage: obj.add_attack(attack, name, num_attempts, apply_before_preproc, attack_kwargs, additional_attack_arg_names) without return types