class_docstr: Abstract base class for adversarial attacks. `Attack` represent an
  adversarial attack which search an adversarial example. subclass should
  implement the _apply() method.
  
  Args:
      model(Model): an instance of the class adversarialbox.base.Model.
class_docstr_tok: ["Abstract","base","class","for","adversarial","attacks",".","`","Attack","`","represent","an","adversarial","attack","which","search","an","adversarial","example",".","subclass","should","implement","the","_apply","(",")","method",".","Args",":","model","(","Model",")",":","an","instance","of","the","class","adversarialbox.base.Model","."]
docstr: Preprocess the adversary object.
  
  :param adversary: adversary
  :return: None
docstr_tok: ["Preprocess","the","adversary","object",".",":","param","adversary",":","adversary",":","return",":","None"]
code: def _preprocess(self, adversary):
      """
      Preprocess the adversary object.
  
      :param adversary: adversary
      :return: None
      """
      # assert self.model.channel_axis() == adversary.original.ndim
  
      if adversary.original_label is None:
          adversary.original_label = np.argmax(
              self.model.predict(adversary.original)
          )
      if (
          adversary.is_targeted_attack
          and adversary.target_label is None
      ):
          if adversary.target is None:
              raise ValueError(
                  "When adversary.is_targeted_attack is true, "
                  "adversary.target_label or adversary.target must be set."
              )
          else:
              adversary.target_label = np.argmax(
                  self.model.predict(adversary.target)
              )
  
      logging.info(
          "adversary:"
          "\n         original_label: {}"
          "\n         target_label: {}"
          "\n         is_targeted_attack: {}"
          "".format(
              adversary.original_label,
              adversary.target_label,
              adversary.is_targeted_attack,
          )
      )
  
file_path: AdvBox/adversarialbox/attacks/base.py
imports: from builtins import object
  import logging
  from abc import ABCMeta
  from abc import abstractmethod
  import numpy
  from future.utils import with_metaclass
label_desc: Use image node_id 4 for calling the Attack obj's underlying member method code with example usage: obj._preprocess(adversary) without return types