code: def main(argv):
      del argv  # Unused.
  
      hparams = get_hparams()
      train_dataset, test_dataset = prepare_datasets(hparams)
  
      adv_model = build_adv_model(hparams)
      adv_train_dataset = convert_to_adversarial_training_dataset(
          train_dataset
      )
      adv_test_dataset = convert_to_adversarial_training_dataset(
          test_dataset
      )
      adv_result = train_and_evaluate(
          adv_model, hparams, adv_train_dataset, adv_test_dataset
      )
  
      base_model = build_base_model(hparams)
      base_result = train_and_evaluate(
          base_model, hparams, train_dataset, test_dataset
      )
  
      for metric_name, result in base_result:
          print("Eval %s for base model: %s" % (metric_name, result))
      for metric_name, result in adv_result:
          print(
              "Eval %s for adversarial model: %s"
              % (metric_name, result)
          )
  
      models = {
          "base": base_model,
          # Takes the base model from adv_model so that input format is the same.
          "adv-regularized": adv_model.base_model,
      }
  
      adv_accuracy = evaluate_robustness(
          base_model, adv_test_dataset, models, hparams
      )
      print("----- Adversarial attack on base model -----")
      for name, accuracy in adv_accuracy.items():
          print("%s model accuracy: %f" % (name, accuracy))
      adv_accuracy = evaluate_robustness(
          adv_model, adv_test_dataset, models, hparams
      )
      print("----- Adversarial attack on adv model -----")
      for name, accuracy in adv_accuracy.items():
          print("%s model accuracy: %f" % (name, accuracy))
  
file_path: neural-structured-learning/neural_structured_learning/examples/adv_keras_cnn_mnist.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import app
  from absl import flags
  import attr
  import neural_structured_learning
  import tensorflow
label_desc: Use image node_id 9 for calling a global function with example usage: main(argv) without return types