code: def test_given_predictions(self, model_fn):
      (
          inputs,
          labels,
          model,
          loss_fn,
          expected_adv_loss,
      ) = self._build_linear_regression_model_and_inputs(model_fn)
  
      with tf.GradientTape() as tape:
          tape.watch(inputs["feature"])
          outputs = model(inputs)
  
      # Wraps self.model to record the number of times it gets called. The counter
      # cannot be a local variable because assignments to names always go into the
      # innermost scope.
      # https://docs.python.org/3/tutorial/classes.html#python-scopes-and-namespaces
      call_count = collections.Counter()
  
      def wrapped_model(inputs):
          call_count["model"] += 1
          return model(inputs)
  
      adv_loss = adversarial_regularization.adversarial_loss(
          inputs,
          labels,
          wrapped_model,
          loss_fn,
          adv_config=self.adv_config,
          predictions=outputs,
          gradient_tape=tape,
      )
      self.assertAllClose(expected_adv_loss, self.evaluate(adv_loss))
      # The model should be called only once, i.e. not re-calculating the
      # predictions on original inputs.
      self.assertEqual(1, call_count["model"])
  
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 5 for calling the AdversarialLossTest obj's underlying member method code with example usage: obj.test_given_predictions(model_fn) and returns: model