class_docstr: Tests for _compute_gradients method.
class_docstr_tok: ["Tests","for","_compute_gradients","method","."]
docstr: Tests that DP optimizers work with tf.keras.Model.
code: def testKerasModelBaselineSaving(self):
      """Tests that DP optimizers work with tf.keras.Model."""
  
      model = tf.keras.models.Sequential(
          layers=[
              tf.keras.layers.Dense(
                  1,
                  activation="linear",
                  name="dense",
                  kernel_initializer="zeros",
                  bias_initializer="zeros",
              )
          ]
      )
  
      optimizer = dp_optimizer_keras.DPKerasSGDOptimizer(
          l2_norm_clip=100.0,
          noise_multiplier=0.0,
          num_microbatches=None,
          learning_rate=0.05,
      )
      loss = tf.keras.losses.MeanSquaredError(reduction="none")
      model.compile(optimizer, loss)
  
      true_weights = np.array([[-5], [4], [3], [2]]).astype(np.float32)
      true_bias = np.array([6.0]).astype(np.float32)
      train_data = np.random.normal(scale=3.0, size=(1000, 4)).astype(
          np.float32
      )
      train_labels = (
          np.matmul(train_data, true_weights)
          + true_bias
          + np.random.normal(scale=0.0, size=(1000, 1)).astype(
              np.float32
          )
      )
  
      model.fit(
          train_data,
          train_labels,
          batch_size=8,
          epochs=1,
          shuffle=False,
      )
  
      tempdir = self.create_tempdir()
      model.save(tempdir, save_format="tf")
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras_vectorized
label_desc: Use image node_id 3 for calling the DPOptimizerComputeGradientsTest obj's underlying member method code with example usage: obj.testKerasModelBaselineSaving() without return types