class_docstr: A simple and fast gradient-based adversarial attack.
  
  Implements the `DeepFool`_ attack.
  
  Args:
      steps : Maximum number of steps to perform.
      candidates : Limit on the number of the most likely classes that should
          be considered. A small value is usually sufficient and much faster.
      overshoot : How much to overshoot the boundary.
      loss  Loss function to use inside the update function.
  
  
  .. _DeepFool:
          Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, Pascal Frossard,
          "DeepFool: a simple and accurate method to fool deep neural
          networks", https://arxiv.org/abs/1511.04599
code: def _get_loss_fn(
      self,
      model: Model,
      classes: ep.Tensor,
  ) -> Callable[
      [ep.Tensor, int], Tuple[ep.Tensor, Tuple[ep.Tensor, ep.Tensor]]
  ]:
      N = len(classes)
      rows = range(N)
      i0 = classes[:, 0]
  
      if self.loss == "logits":
  
          def loss_fun(
              x: ep.Tensor, k: int
          ) -> Tuple[ep.Tensor, Tuple[ep.Tensor, ep.Tensor]]:
              logits = model(x)
              ik = classes[:, k]
              l0 = logits[rows, i0]
              lk = logits[rows, ik]
              loss = lk - l0
              return loss.sum(), (loss, logits)
  
      elif self.loss == "crossentropy":
  
          def loss_fun(
              x: ep.Tensor, k: int
          ) -> Tuple[ep.Tensor, Tuple[ep.Tensor, ep.Tensor]]:
              logits = model(x)
              ik = classes[:, k]
              l0 = -ep.crossentropy(logits, i0)
              lk = -ep.crossentropy(logits, ik)
              loss = lk - l0
              return loss.sum(), (loss, logits)
  
      else:
          raise ValueError(
              f"expected loss to be 'logits' or 'crossentropy', got '{self.loss}'"
          )
  
      return loss_fun
  
imports: from typing import Union, Optional, Tuple, Any, Callable
  from typing_extensions import Literal
  import eagerpy
  import logging
  from abc import ABC
  from abc import abstractmethod
  from ..devutils import flatten
  from ..devutils import atleast_kd
  from ..models import Model
  from ..criteria import Criterion
  from ..distances import l2, linf
  from .base import MinimizationAttack
  from .base import T
  from .base import get_criterion
  from .base import raise_if_kwargs
  from .base import verify_input_bounds
label_desc: Use image node_id 2 for calling the DeepFoolAttack obj's underlying member method code with example usage: obj._get_loss_fn(model, classes) and returns: loss_fun, loss,  loss,  logits, loss,  loss,  logits