class_docstr: Abstract base class for all attack classes.
class_docstr_tok: ["Abstract","base","class","for","all","attack","classes","."]
docstr: Get the label to use in generating an adversarial example for x.
  The kwargs are fed directly from the kwargs of the attack.
  If 'y' is in kwargs, then assume it's an untargeted attack and
  use that as the label.
  If 'y_target' is in kwargs and is not none, then assume it's a
  targeted attack and use that as the label.
  Otherwise, use the model's prediction as the label and perform an
  untargeted attack.
docstr_tok: ["Get","the","label","to","use","in","generating","an","adversarial","example","for","x",".","The","kwargs","are","fed","directly","from","the","kwargs","of","the","attack",".","If","'","y","'","is","in","kwargs",",","then","assume","it","'s","an","untargeted","attack","and","use","that","as","the","label",".","If","'y_target","'","is","in","kwargs","and","is","not","none",",","then","assume","it","'s","a","targeted","attack","and","use","that","as","the","label",".","Otherwise",",","use","the","model","'s","prediction","as","the","label","and","perform","an","untargeted","attack","."]
code: def get_or_guess_labels(self, x, kwargs):
      """
      Get the label to use in generating an adversarial example for x.
      The kwargs are fed directly from the kwargs of the attack.
      If 'y' is in kwargs, then assume it's an untargeted attack and
      use that as the label.
      If 'y_target' is in kwargs and is not none, then assume it's a
      targeted attack and use that as the label.
      Otherwise, use the model's prediction as the label and perform an
      untargeted attack.
      """
      if "y" in kwargs and "y_target" in kwargs:
          raise ValueError("Can not set both 'y' and 'y_target'.")
      elif "y" in kwargs:
          labels = kwargs["y"]
      elif "y_target" in kwargs and kwargs["y_target"] is not None:
          labels = kwargs["y_target"]
      else:
          preds = self.model.get_probs(x)
          preds_max = reduce_max(preds, 1, keepdims=True)
          original_predictions = tf.to_float(tf.equal(preds, preds_max))
          labels = tf.stop_gradient(original_predictions)
          del preds
      if isinstance(labels, np.ndarray):
          nb_classes = labels.shape[1]
      else:
          nb_classes = labels.get_shape().as_list()[1]
      return labels, nb_classes
  
file_path: cleverhans/cleverhans_v3.1.0/cleverhans/attacks/attack.py
imports: from abc import ABCMeta
  import collections
  import warnings
  import numpy
  import tensorflow
  from cleverhans.compat import reduce_max
  from cleverhans.model import Model
  from cleverhans import utils
label_desc: Use image node_id 6 for calling the Attack obj's underlying member method code with example usage: obj.get_or_guess_labels(x, kwargs) and returns: labels,  nb_classes