code: def test_multi_iter_gen_adv_neighbor_for_features_with_different_shapes_v2(
      self,
  ):
      (
          x,
          w1,
          w2,
          adv_config,
          model_fn,
          loss_fn,
      ) = (
          self._test_multi_iter_gen_adv_neighbor_for_features_with_different_shapes_setup()
      )
      y = tf.constant([0.0])
  
      with tf.GradientTape() as tape:
          tape.watch(list(x.values()))
          loss = tf.reduce_sum(
              input_tensor=w1 * x["f1"]
          ) + tf.reduce_sum(input_tensor=w2 * x["f2"])
  
      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,
      )
      actual_neighbor = self.evaluate(adv_neighbor)
  
      # gradient = w
      # perturbation = adv_step_size * normalize(gradient) = 0.025 in each dim
      # Epsilon 0.15, projects back to roughly 0.04330
      # f2 does not need to be clipped.
      perturbation = 0.025 * 2
      projected_perturb = (
          perturbation * 0.15 / tf.sqrt(16 * tf.square(0.05))
      )
      self.assertAllClose(
          x["f1"] + projected_perturb, actual_neighbor["f1"]
      )
      self.assertAllClose(
          x["f2"] + projected_perturb, actual_neighbor["f2"]
      )
  
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 48 for calling the GenAdvNeighborTest obj's underlying member method code with example usage: obj.test_multi_iter_gen_adv_neighbor_for_features_with_different_shapes_v2() without return types