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()
  
      # Define a sequential Keras model
      model = tf.keras.Sequential(
          [
              tf.keras.layers.Conv2D(
                  16,
                  8,
                  strides=2,
                  padding="same",
                  activation="relu",
                  input_shape=(28, 28, 1),
              ),
              tf.keras.layers.MaxPool2D(2, 1),
              tf.keras.layers.Conv2D(
                  32, 4, strides=2, padding="valid", activation="relu"
              ),
              tf.keras.layers.MaxPool2D(2, 1),
              tf.keras.layers.Flatten(),
              tf.keras.layers.Dense(32, activation="relu"),
              tf.keras.layers.Dense(10),
          ]
      )
  
      if FLAGS.dpsgd:
          optimizer = DPKerasSGDOptimizer(
              l2_norm_clip=FLAGS.l2_norm_clip,
              noise_multiplier=FLAGS.noise_multiplier,
              num_microbatches=FLAGS.microbatches,
              learning_rate=FLAGS.learning_rate,
          )
          # Compute vector of per-example loss rather than its mean over a minibatch.
          loss = tf.keras.losses.CategoricalCrossentropy(
              from_logits=True, reduction=tf.losses.Reduction.NONE
          )
      else:
          optimizer = tf.keras.optimizers.SGD(
              learning_rate=FLAGS.learning_rate
          )
          loss = tf.keras.losses.CategoricalCrossentropy(
              from_logits=True
          )
  
      # Compile model with Keras
      model.compile(
          optimizer=optimizer, loss=loss, metrics=["accuracy"]
      )
  
      # Train model with Keras
      model.fit(
          train_data,
          train_labels,
          epochs=FLAGS.epochs,
          validation_data=(test_data, test_labels),
          batch_size=FLAGS.batch_size,
      )
  
      # Compute the privacy budget expended.
      if FLAGS.dpsgd:
          eps = compute_epsilon(
              FLAGS.epochs * 60000 // 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_keras.py
imports: from absl import app
  from absl import flags
  from absl import logging
  import dp_accounting
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.optimizers.dp_optimizer_keras import DPKerasSGDOptimizer
label_desc: Use image node_id 3 for calling a global function with example usage: main(unused_argv) without return types