code: def adversarial_accuracy(
      classifier: "CLASSIFIER_TYPE",
      x: np.ndarray,
      y: Optional[np.ndarray] = None,
      attack_name: Optional[str] = None,
      attack_params: Optional[Dict[str, Any]] = None,
      attack_crafter: Optional[EvasionAttack] = None,
  ) -> float:
      """
      Compute the adversarial accuracy of a classifier object over the sample `x` for a given adversarial crafting
      method `attack`, with optional true labels `y`. `attack_name` can be specified
      to use a preset attack, or `attack_crafter` for wider choices
      and customized parameters.
      Note that if `y` is not specified, the score does not exclude wrong predictions by the classifier.
  
      :param classifier: A trained model.
      :param x: Input samples of shape that can be fed into `classifier`.
      :param y: True labels of `x`.
      :param attack_name: A string specifying the attack to be used as a key to `art.metrics.metrics.SUPPORTED_METHODS`.
      :param attack_params: A dictionary with attack-specific parameters. If the attack has a norm attribute, then it will
                            be used as the norm for calculating the robustness; otherwise the standard Euclidean distance
                            is used (norm=2).
      :param attack_crafter: EvasionAttack instance with `generate' method to apply on `x` to create adversarial examples.
      :return: The adversarial accuracy of the classifier computed on `x`.
      """
  
      if attack_crafter is None:
          if attack_name is None:
              supported_methods = ", ".join(SUPPORTED_METHODS.keys())
              raise ValueError(
                  "At least one of `attack_name` or `attack_crafter` must be specified."
                  + f"Available values for `attack_name' include {supported_methods}."
              )
  
          if x.max() > 1.0 or x.min() < 0:
              logger.warning(
                  "The input range is outside [0,1]. Please consider using `attack_crafter` instead."
              )
  
          attack_crafter = get_crafter(
              classifier, attack_name, attack_params
          )
          attack_crafter.set_params(**{"minimal": True})
  
      adv_x = attack_crafter.generate(x)
  
      # Predict the labels for adversarial examples
      y_orig = np.argmax(classifier.predict(x), axis=1)
      y_pred = np.argmax(classifier.predict(adv_x), axis=1)
  
      if y is None:
          idxs = y_pred == y_orig
          return np.sum(idxs) / len(y_orig)
  
      if len(y.shape) > 1:
          y = np.argmax(y, axis=1)
      y_corr = y_orig == y
      return np.sum((y_pred == y_orig) & y_corr) / np.sum(y_corr)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from functools import reduce
  import logging
  from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING
  import numpy
  import numpy.linalg
  from scipy.optimize import fmin
  from scipy.stats import weibull_min
  from tqdm.auto import tqdm
  from art.config import ART_NUMPY_DTYPE
  from art.attacks.attack import EvasionAttack
  from art.attacks.evasion.auto_attack import AutoAttack
  from art.attacks.evasion.fast_gradient import FastGradientMethod
  from art.attacks.evasion.hop_skip_jump import HopSkipJump
  from art.utils import random_sphere
label_desc: Use image node_id 2 for calling a global function with example usage: adversarial_accuracy(classifier, x, y, attack_name, attack_params, attack_crafter) and returns: unknown, unknown