class_docstr: An abstract interface for loss wrappers that allows flexible control of
  real examples, adversarial examples and labels. These losses are used
  for defenses (during model training).
class_docstr_tok: ["An","abstract","interface","for","loss","wrappers","that","allows","flexible","control","of","real","examples",",","adversarial","examples","and","labels",".","These","losses","are","used","for","defenses","(","during","model","training",")","."]
docstr: :param model: Model instance, the model on which to apply the loss.
  :param hparams: dict, hyper-parameters for the loss.
  :param attack: cleverhans.attacks.Attack instance
docstr_tok: [":","param","model",":","Model","instance",",","the","model","on","which","to","apply","the","loss",".",":","param","hparams",":","dict",",","hyper-parameters","for","the","loss",".",":","param","attack",":","cleverhans.attacks.Attack","instance"]
code: def __init__(self, model, hparams=None, attack=None):
      """
      :param model: Model instance, the model on which to apply the loss.
      :param hparams: dict, hyper-parameters for the loss.
      :param attack: cleverhans.attacks.Attack instance
      """
      assert isinstance(model, Model)
      standard = attack is None or isinstance(attack, Attack)
      deprecated = callable(attack)
      if not standard and not deprecated:
          raise TypeError(
              "`attack` must be `None` or `Attack` subclass instance"
          )
      if deprecated:
          warnings.warn(
              "callable attacks are deprecated, switch to an Attack "
              "subclass. callable attacks will not be supported after "
              "2019-05-05."
          )
  
          class Wrapper(Attack):
              """
              Temporary wrapper class to be removed when deprecated callable
              arguments are removed.
  
              :param f: a callable object implementing the attack
              """
  
              def __init__(self, f):
                  dummy_model = Model()
                  super(Wrapper, self).__init__(model=dummy_model)
                  self.f = f
  
              def generate(self, x):
                  return self.f(x)
  
          attack = Wrapper(attack)
      self.model = model
      self.hparams = hparams
      self.attack = attack
  
imports: import copy
  import json
  import os
  import warnings
  import numpy
  import tensorflow
  from cleverhans.attacks import Attack
  from cleverhans.compat import softmax_cross_entropy_with_logits
  from cleverhans.model import Model
  from cleverhans.utils import safe_zip
label_desc: Use image node_id 1 to create a new Loss object from inherited base classes: object with example: obj = Loss(model, hparams, attack)