code: def main(unused_argv):
      del unused_argv
      # Load training and test data.
      np.random.seed(0)
  
      (
          train_x,
          train_y,
      ), _ = tf.keras.datasets.fashion_mnist.load_data()
      train_inds = np.where(train_y < 2)[0]
  
      train_x = -0.5 + train_x[train_inds] / 255.0
      train_y = np.eye(2)[train_y[train_inds]]
  
      # subsample dataset
      ss_inds = np.random.choice(
          train_x.shape[0], train_x.shape[0] // 2, replace=False
      )
      train_x = train_x[ss_inds]
      train_y = train_y[ss_inds]
  
      init_model = build_model(train_x, train_y)
      _ = train_model(init_model, train_x, train_y, save_weights=True)
  
      auditor = audit.AuditAttack(train_x, train_y, train_and_score)
  
      thresh, _, _ = auditor.run(
          FLAGS.pois_ct,
          FLAGS.attack_type,
          FLAGS.num_trials,
          alpha=FLAGS.alpha,
          threshold=None,
          l2_norm=FLAGS.attack_l2_norm,
      )
  
      _, eps, acc = auditor.run(
          FLAGS.pois_ct,
          FLAGS.attack_type,
          FLAGS.num_trials,
          alpha=FLAGS.alpha,
          threshold=thresh,
          l2_norm=FLAGS.attack_l2_norm,
      )
  
      epsilon_upper_bound = compute_epsilon(train_x.shape[0])
  
      print("Analysis epsilon is {}.".format(epsilon_upper_bound))
      print("At threshold={}, epsilon={}.".format(thresh, eps))
      print(
          "The best accuracy at distinguishing poisoning is {}.".format(
              acc
          )
      )
  
file_path: privacy/research/audit_2020/fmnist_audit.py
imports: import numpy
  import tensorflow.compat.v1
  from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp
  from tensorflow_privacy.privacy.analysis.rdp_accountant import get_privacy_spent
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_vectorized
  from absl import app
  from absl import flags
  import audit
label_desc: Use image node_id 6 for calling a global function with example usage: main(unused_argv) without return types