code: def test_multi_iter_gen_adv_neighbor_proj_limits(
      self, use_while_loop
  ):
      # Simple linear regression.
      x = tf.constant([[-1.0, 1.0]])
      y = tf.constant([0.0])
      w = tf.constant([[3.0], [4.0]])
      loss_fn = tf.math.squared_difference
      model_fn = lambda input: tf.matmul(input, w)
      with tf.GradientTape() as tape:
          tape.watch(x)
          y_hat = model_fn(x)
          loss = loss_fn(y, y_hat)
      adv_config = configs.AdvNeighborConfig(
          feature_mask=tf.constant(1.0),
          adv_step_size=0.1,
          adv_grad_norm="l2",
          pgd_iterations=2,
          pgd_epsilon=0.15,
      )
      adv_neighbor, _ = adv_lib.gen_adv_neighbor(
          x,
          loss,
          adv_config,
          gradient_tape=tape,
          pgd_model_fn=model_fn,
          pgd_loss_fn=loss_fn,
          pgd_labels=y,
          use_while_loop=use_while_loop,
      )
  
      # Take two steps in the gradient direction. Project back onto epsilon ball
      # after iteration 2.
      expected_neighbor = [
          [-1.0 + 0.1 * 0.6 * 1.5, 1.0 + 0.1 * 0.8 * 1.5]
      ]
      actual_neighbor = self.evaluate(adv_neighbor)
      self.assertAllClose(expected_neighbor, actual_neighbor)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import neural_structured_learning.configs
  from neural_structured_learning.lib import adversarial_neighbor
  import numpy
  import tensorflow
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 4 for calling the GenAdvNeighborTest obj's underlying member method code with example usage: obj.test_multi_iter_gen_adv_neighbor_proj_limits(use_while_loop) without return types