code: def main(unused_argv):
      tf.compat.v1.logging.set_verbosity(3)
  
      # Load training and test data.
      train_data, train_labels, test_data, test_labels = load_imdb()
  
      # Instantiate the tf.Estimator.
      imdb_classifier = tf_estimator.Estimator(
          model_fn=nn_model_fn, model_dir=FLAGS.model_dir
      )
  
      # Create tf.Estimator input functions for the training and test data.
      eval_input_fn = tf_compat_v1_estimator.inputs.numpy_input_fn(
          x={"x": test_data}, y=test_labels, num_epochs=1, shuffle=False
      )
  
      # Training loop.
      steps_per_epoch = num_examples // sampling_batch
      test_accuracy_list = []
  
      for epoch in range(1, FLAGS.epochs + 1):
          for _ in range(steps_per_epoch):
              whether = np.random.random_sample(num_examples) > (
                  1 - sampling_batch / num_examples
              )
              subsampling = [
                  i for i in np.arange(num_examples) if whether[i]
              ]
              global microbatches
              microbatches = len(subsampling)
  
              train_input_fn = (
                  tf_compat_v1_estimator.inputs.numpy_input_fn(
                      x={"x": train_data[subsampling]},
                      y=train_labels[subsampling],
                      batch_size=len(subsampling),
                      num_epochs=1,
                      shuffle=False,
                  )
              )
              # Train the model for one step.
              imdb_classifier.train(input_fn=train_input_fn, steps=1)
  
          # Evaluate the model and print results
          eval_results = imdb_classifier.evaluate(
              input_fn=eval_input_fn
          )
          test_accuracy = eval_results["accuracy"]
          test_accuracy_list.append(test_accuracy)
          print(
              "Test accuracy after %d epochs is: %.3f"
              % (epoch, test_accuracy)
          )
  
          # Compute the privacy budget expended so far.
          if FLAGS.dpsgd:
              eps = compute_eps_poisson(
                  epoch,
                  FLAGS.noise_multiplier,
                  num_examples,
                  sampling_batch,
                  1e-5,
              )
              mu = compute_mu_poisson(
                  epoch,
                  FLAGS.noise_multiplier,
                  num_examples,
                  sampling_batch,
              )
              print(
                  "For delta=1e-5, the current epsilon is: %.2f" % eps
              )
              print("For delta=1e-5, the current mu is: %.2f" % mu)
  
              if mu > FLAGS.max_mu:
                  break
          else:
              print("Trained with vanilla non-private SGD optimizer")
  
file_path: privacy/research/GDP_2019/imdb_tutorial.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import app
  from absl import flags
  from keras.preprocessing import sequence
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow.compat.v1 import estimator
  from tensorflow_privacy.privacy.analysis.gdp_accountant import compute_eps_poisson
  from tensorflow_privacy.privacy.analysis.gdp_accountant import compute_mu_poisson
  from tensorflow_privacy.privacy.optimizers import dp_optimizer
label_desc: Use image node_id 3 for calling a global function with example usage: main(unused_argv) without return types