code: def _apply_decision_rule(
      decision_rule: Union[Literal["EN"], Literal["L1"]],
      beta: float,
      best_advs: ep.Tensor,
      best_advs_norms: ep.Tensor,
      x_k: ep.Tensor,
      x: ep.Tensor,
      found_advs: ep.Tensor,
  ) -> Tuple[ep.Tensor, ep.Tensor]:
      if decision_rule == "EN":
          norms = beta * flatten(x_k - x).abs().sum(axis=-1) + flatten(
              x_k - x
          ).square().sum(axis=-1)
      else:
          # decision rule = L1
          norms = flatten(x_k - x).abs().sum(axis=-1)
  
      new_best = ep.logical_and(norms < best_advs_norms, found_advs)
      new_best_kd = atleast_kd(new_best, best_advs.ndim)
      best_advs = ep.where(new_best_kd, x_k, best_advs)
      best_advs_norms = ep.where(new_best, norms, best_advs_norms)
  
      return best_advs, best_advs_norms
  
file_path: foolbox/foolbox/attacks/ead.py
imports: from typing import Union, Tuple, Any, Optional
  from typing_extensions import Literal
  import math
  import eagerpy
  from ..models import Model
  from ..criteria import Misclassification, TargetedMisclassification
  from ..distances import l1
  from ..devutils import atleast_kd, flatten
  from .base import MinimizationAttack
  from .base import get_criterion
  from .base import T
  from .base import raise_if_kwargs
  from .base import verify_input_bounds
label_desc: Use image node_id 2 for calling a global function with example usage: _apply_decision_rule(decision_rule, beta, best_advs, best_advs_norms, x_k, x, found_advs) and returns: best_advs,  best_advs_norms