class_docstr: Implementation of a generic laser attack case.
class_docstr_tok: ["Implementation","of","a","generic","laser","attack","case","."]
docstr: Generate adversarial example params for a single image.
  
  :param x: Image to attack as a tensor (NRGB = (1, ...))
  :param y: Correct class of the image. If not provided, it is set to the prediction of the model.
  :return: Adversarial object params and adversarial class number.
docstr_tok: ["Generate","adversarial","example","params","for","a","single","image",".",":","param","x",":","Image","to","attack","as","a","tensor","(","NRGB","=","(","1",",","...",")",")",":","param","y",":","Correct","class","of","the","image",".","If","not","provided",",","it","is","set","to","the","prediction","of","the","model",".",":","return",":","Adversarial","object","params","and","adversarial","class","number","."]
code: def _generate_params_for_single_input(
      self, x: np.ndarray, y: Optional[int] = None
  ) -> Tuple[Optional[AdversarialObject], Optional[int]]:
      """
      Generate adversarial example params for a single image.
  
      :param x: Image to attack as a tensor (NRGB = (1, ...))
      :param y: Correct class of the image. If not provided, it is set to the prediction of the model.
      :return: Adversarial object params and adversarial class number.
      """
  
      image = np.expand_dims(x, 0)
      prediction = self.estimator.predict(image)
      if y is not None:
          actual_class = y
      else:
          actual_class = prediction.argmax()
      actual_class_confidence = prediction[0][actual_class]
  
      for _ in range(self.random_initializations):
          laser_params, predicted_class = self._attack_single_image(
              image, actual_class, actual_class_confidence
          )
          if laser_params is not None:
              logger.info("Found adversarial params: %s", laser_params)
              return laser_params, predicted_class
      logger.warning("Couldn't find adversarial laser parameters")
  
      return None, None
  
imports: import logging
  from typing import Callable, List, Optional, Tuple, Union, Any
  import numpy
  from art.attacks.attack import EvasionAttack
  from art.attacks.evasion.laser_attack.algorithms import greedy_search
  from art.attacks.evasion.laser_attack.utils import AdversarialObject, AdvObjectGenerator, DebugInfo, ImageGenerator, Line, wavelength_to_rgb
label_desc: Use image node_id 4 for calling the LaserAttack obj's underlying member method code with example usage: obj._generate_params_for_single_input(x, y) and returns: None,  None, laser_params,  predicted_class