code: def test_train_pgd(self, model_fn):
      w = np.array([[4.0], [-3.0]])
      x0 = np.array([[2.0, 3.0]])
      y0 = np.array([[0.0]])
      adv_multiplier = 0.2
      adv_step_size = 0.01
      learning_rate = 0.01
      pgd_iterations = 3
      pgd_epsilon = 2.5 * adv_step_size
      adv_config = configs.make_adv_reg_config(
          multiplier=adv_multiplier,
          adv_step_size=adv_step_size,
          adv_grad_norm="infinity",
          pgd_iterations=pgd_iterations,
          pgd_epsilon=pgd_epsilon,
      )
      y_hat = np.dot(x0, w)
      # The adversarial perturbation is constant across PGD iterations.
      x_adv = x0 + pgd_epsilon * np.sign((y_hat - y0) * w.T)
      y_hat_adv = np.dot(x_adv, w)
      grad_w_labeled_loss = 2.0 * (y_hat - y0) * x0.T
      grad_w_adv_loss = (
          adv_multiplier * 2.0 * (y_hat_adv - y0) * x_adv.T
      )
      w_new = w - learning_rate * (
          grad_w_labeled_loss + grad_w_adv_loss
      )
  
      inputs = {"feature": tf.constant(x0), "label": tf.constant(y0)}
      model = model_fn(input_shape=(2,), weights=w)
      adv_model = adversarial_regularization.AdversarialRegularization(
          model, label_keys=["label"], adv_config=adv_config
      )
      adv_model.compile(
          tf.keras.optimizers.SGD(learning_rate), loss="MSE"
      )
      adv_model.fit(x=inputs, batch_size=1, steps_per_epoch=1)
  
      self.assertAllClose(
          w_new, tf.keras.backend.get_value(model.weights[0])
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  from absl.testing import parameterized
  import neural_structured_learning.configs
  from neural_structured_learning.keras import adversarial_regularization
  import numpy
  import tensorflow
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 16 for calling the AdversarialRegularizationTest obj's underlying member method code with example usage: obj.test_train_pgd(model_fn) without return types