code: def testNoiseMultiplier(
      self,
      l2_norm_clip,
      noise_multiplier,
      num_microbatches,
      fast_clipping,
  ):
      # The idea behind this test is to start with a model whose parameters
      # are set to zero. We then run one step of a model that produces
      # an un-noised gradient of zero, and then compute the standard deviation
      # of the resulting weights to see if it matches the expected standard
      # deviation.
  
      # Data is one example of length 1000, set to zero, with label zero.
      train_data = np.zeros((4, 1000))
      train_labels = np.array([[0.0], [0.0], [0.0], [0.0]])
  
      learning_rate = 1.0
  
      optimizer = tf.keras.optimizers.SGD(learning_rate=learning_rate)
      loss = tf.keras.losses.MeanSquaredError()
  
      # Simple linear model returns w * x + b.
      model = dp_keras_model.DPSequential(
          l2_norm_clip=l2_norm_clip,
          noise_multiplier=noise_multiplier,
          num_microbatches=num_microbatches,
          layer_registry=layer_registry.make_default_layer_registry()
          if fast_clipping
          else None,
          layers=[
              tf.keras.layers.InputLayer(input_shape=(1000,)),
              tf.keras.layers.Dense(
                  1,
                  kernel_initializer="zeros",
                  bias_initializer="zeros",
              ),
          ],
      )
      model.compile(optimizer=optimizer, loss=loss)
      model.fit(train_data, train_labels, epochs=1, batch_size=4)
  
      effective_num_microbatches = (
          num_microbatches or train_data.shape[0]
      )
  
      model_weights = model.get_weights()
      measured_std = np.std(model_weights[0])
      expected_std = (
          l2_norm_clip * noise_multiplier / effective_num_microbatches
      )
  
      # Test standard deviation is close to l2_norm_clip * noise_multiplier.
      self.assertNear(measured_std, expected_std, 0.1 * expected_std)
  
file_path: privacy/tensorflow_privacy/privacy/keras_models/dp_keras_model_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.fast_gradient_clipping import layer_registry
  from tensorflow_privacy.privacy.keras_models import dp_keras_model
label_desc: Use image node_id 5 for calling the DPKerasModelTest obj's underlying member method code with example usage: obj.testNoiseMultiplier(l2_norm_clip, noise_multiplier, num_microbatches, fast_clipping) without return types