code: def helper_pgd_attack(
      self,
      unrolled_optimizer,
      targeted,
      nb_iters=20,
      epsilon=0.5,
      clip_min=-5.0,
      clip_max=5.0,
      assert_threshold=0.5,
  ):
      def loss_fn(input_image, label, targeted):
          res = self.model.fprop(input_image)
          logits = res[self.model.O_LOGITS]
          multiplier = 1.0 if targeted else -1.0
          return (
              multiplier
              * tf.nn.sparse_softmax_cross_entropy_with_logits(
                  labels=label, logits=logits
              )
          )
  
      x_val_ph = tf.placeholder(tf.float32, shape=[100, 2])
      x_val = np.random.randn(100, 2).astype(np.float32)
      init_model_output = self.model.fprop(x_val_ph)
      init_model_logits = init_model_output[self.model.O_LOGITS]
      if targeted:
          labels = np.random.random_integers(0, 1, size=(100,))
      else:
          labels = tf.stop_gradient(
              tf.argmax(init_model_logits, axis=1)
          )
  
      def _project_perturbation(
          perturbation, epsilon, input_image, clip_min, clip_max
      ):
          clipped_perturbation = tf.clip_by_value(
              perturbation, -epsilon, epsilon
          )
          new_image = tf.clip_by_value(
              input_image + clipped_perturbation, clip_min, clip_max
          )
          return new_image - input_image
  
      x_adv = pgd_attack(
          loss_fn=partial(loss_fn, targeted=targeted),
          input_image=x_val_ph,
          label=labels,
          epsilon=epsilon,
          num_steps=nb_iters,
          optimizer=unrolled_optimizer,
          project_perturbation=_project_perturbation,
          clip_min=clip_min,
          clip_max=clip_max,
      )
  
      final_model_output = self.model.fprop(x_adv)
      final_model_logits = final_model_output[self.model.O_LOGITS]
  
      if not targeted:
          logits1, logits2 = self.sess.run(
              [init_model_logits, final_model_logits],
              feed_dict={x_val_ph: x_val},
          )
          preds1 = np.argmax(logits1, axis=1)
          preds2 = np.argmax(logits2, axis=1)
  
          self.assertTrue(
              np.mean(preds1 == preds2) < assert_threshold,
              np.mean(preds1 == preds2),
          )
  
      else:
          logits_adv = self.sess.run(
              final_model_logits, feed_dict={x_val_ph: x_val}
          )
          preds_adv = np.argmax(logits_adv, axis=1)
  
          self.assertTrue(
              np.mean(labels == preds_adv) > assert_threshold
          )
  
imports: from functools import partial
  import unittest
  import numpy
  import tensorflow
  from cleverhans.devtools.checks import CleverHansTest
  from cleverhans.attacks_tf import fgm, pgd_attack, UnrolledAdam, UnrolledGradientDescent, parallel_apply_transformations
  from cleverhans.devtools.mocks import random_feed_dict
  from cleverhans.model import Model
label_desc: Use image node_id 3 for calling the TestAttackTF obj's underlying member method code with example usage: obj.helper_pgd_attack(unrolled_optimizer, targeted, nb_iters, epsilon, clip_min, clip_max, assert_threshold) and returns: unknown, unknown