code: def main(unused_argv):
      logging.set_verbosity(logging.INFO)
  
      if FLAGS.dpsgd and FLAGS.batch_size % FLAGS.microbatches != 0:
          raise ValueError(
              "Number of microbatches should divide evenly batch_size"
          )
  
      # Load training and test data.
      train_data, train_labels, test_data, test_labels = load_mnist()
  
      # Instantiate the tf.Estimator.
      mnist_classifier = tf_estimator.Estimator(
          model_fn=cnn_model_fn, model_dir=FLAGS.model_dir
      )
  
      # Create tf.Estimator input functions for the training and test data.
      train_input_fn = tf_compat_v1_estimator.inputs.numpy_input_fn(
          x={"x": train_data},
          y=train_labels,
          batch_size=FLAGS.batch_size,
          num_epochs=FLAGS.epochs,
          shuffle=True,
      )
      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_TRAIN_EXAMPLES // FLAGS.batch_size
      for epoch in range(1, FLAGS.epochs + 1):
          # Train the model for one epoch.
          mnist_classifier.train(
              input_fn=train_input_fn, steps=steps_per_epoch
          )
  
          # Evaluate the model and print results
          eval_results = mnist_classifier.evaluate(
              input_fn=eval_input_fn
          )
          test_accuracy = eval_results["accuracy"]
          print(
              "Test accuracy after %d epochs is: %.3f"
              % (epoch, test_accuracy)
          )
  
          # Compute the privacy budget expended.
          if FLAGS.dpsgd:
              eps = compute_epsilon(
                  epoch * NUM_TRAIN_EXAMPLES // FLAGS.batch_size
              )
              print(
                  "For delta=1e-5, the current epsilon is: %.2f" % eps
              )
          else:
              print("Trained with vanilla non-private SGD optimizer")
  
file_path: privacy/tutorials/mnist_dpsgd_tutorial_vectorized.py
imports: from absl import app
  from absl import flags
  from absl import logging
  import dp_accounting
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow.compat.v1 import estimator
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_vectorized
label_desc: Use image node_id 4 for calling a global function with example usage: main(unused_argv) without return types