code: def test_feature_pairing(self):
      sess = tf.Session()
      fgsm = FastGradientMethod(self.model, sess=sess)
  
      def attack(x):
          return fgsm.generate(x)
  
      loss = FeaturePairing(self.model, weight=0.1, attack=attack)
      l = loss.fprop(self.x, self.y)
      vl1 = sess.run(l, feed_dict={self.x: self.vx, self.y: self.vy})
      vl2 = sess.run(l, feed_dict={self.x: self.vx, self.y: self.vy})
      self.assertClose(
          vl1, sum([4.296023369, 2.963884830]) / 2.0, atol=1e-6
      )
      self.assertClose(
          vl2, sum([4.296023369, 2.963884830]) / 2.0, atol=1e-6
      )
  
      loss = FeaturePairing(self.model, weight=10.0, attack=attack)
      l = loss.fprop(self.x, self.y)
      vl1 = sess.run(l, feed_dict={self.x: self.vx, self.y: self.vy})
      vl2 = sess.run(l, feed_dict={self.x: self.vx, self.y: self.vy})
      self.assertClose(
          vl1, sum([4.333082676, 3.00094414]) / 2.0, atol=1e-6
      )
      self.assertClose(
          vl2, sum([4.333082676, 3.00094414]) / 2.0, atol=1e-6
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import unittest
  import numpy
  import tensorflow
  from cleverhans.attacks import FastGradientMethod
  from cleverhans.loss import CrossEntropy, MixUp, FeaturePairing
  from cleverhans.devtools.checks import CleverHansTest
  from cleverhans.model import Model
label_desc: Use image node_id 5 for calling the TestDefenses obj's underlying member method code with example usage: obj.test_feature_pairing() and returns: fgsm