class_docstr: Feature pairing loss.
  :param model: Model instance, the model on which to apply the loss.
  :param weight: float, with of logic pairing loss.
  :param attack: function, given an input x, return an attacked x'.
class_docstr_tok: ["Feature","pairing","loss",".",":","param","model",":","Model","instance",",","the","model","on","which","to","apply","the","loss",".",":","param","weight",":","float",",","with","of","logic","pairing","loss",".",":","param","attack",":","function",",","given","an","input","x",",","return","an","attacked","x","'","."]
code: def fprop(self, x, y, **kwargs):
      x_adv = self.attack.generate(x)
      d1 = self.model.fprop(x, **kwargs)
      d2 = self.model.fprop(x_adv, **kwargs)
      pairing_loss = [
          tf.reduce_mean(tf.square(a - b))
          for a, b in zip(d1[Model.O_FEATURES], d2[Model.O_FEATURES])
      ]
      pairing_loss = tf.reduce_mean(pairing_loss)
      loss = tf.reduce_mean(
          softmax_cross_entropy_with_logits(
              labels=y, logits=d1[Model.O_LOGITS]
          )
      )
      loss += tf.reduce_mean(
          softmax_cross_entropy_with_logits(
              labels=y, logits=d2[Model.O_LOGITS]
          )
      )
      return loss + self.weight * pairing_loss
  
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 2 for calling the FeaturePairing obj's underlying member method code with example usage: obj.fprop(x, y) and returns: unknown