code: def testMicrobatches(
      self, num_microbatches, fast_clipping, sequential, weighted
  ):
      l2_norm_clip = 1.0
      train_data = np.array(
          [[2.0, 3.0], [4.0, 5.0], [6.0, 7.0], [8.0, 9.0]]
      )
      train_labels = np.array([[1.0], [3.0], [-2.0], [-4.0]])
      if weighted:
          train_weights = np.array(
              [0.1, 0.2, 0.3, 0.4], dtype=np.float32
          )
          dataset = tf.data.Dataset.from_tensors(
              (train_data, train_labels, train_weights)
          )
      else:
          train_weights = None
          dataset = tf.data.Dataset.from_tensors(
              (train_data, train_labels)
          )
      learning_rate = 1.0
  
      optimizer = tf.keras.optimizers.SGD(learning_rate=learning_rate)
      loss = tf.keras.losses.MeanSquaredError()
  
      # Simple linear model returns w * x.
      layer = tf.keras.layers.Dense(
          1, use_bias=False, kernel_initializer="zeros"
      )
      registry = (
          layer_registry.make_default_layer_registry()
          if fast_clipping
          else None
      )
      if sequential:
          model = dp_keras_model.DPSequential(
              l2_norm_clip=l2_norm_clip,
              noise_multiplier=0.0,
              num_microbatches=num_microbatches,
              layer_registry=registry,
              layers=[
                  tf.keras.layers.InputLayer(input_shape=(2,)),
                  layer,
              ],
          )
      else:
          inputs = tf.keras.Input(shape=(2,), dtype=tf.float32)
          outputs = layer(inputs)
          model = dp_keras_model.DPModel(
              l2_norm_clip=l2_norm_clip,
              noise_multiplier=0.0,
              num_microbatches=num_microbatches,
              layer_registry=registry,
              inputs=inputs,
              outputs=outputs,
          )
      model.compile(optimizer=optimizer, loss=loss)
      model.fit(dataset, epochs=1, batch_size=4, shuffle=False)
  
      model_weights = np.squeeze(model.get_weights())
  
      effective_num_microbatches = (
          train_data.shape[0]
          if model._num_microbatches is None
          else num_microbatches
      )
  
      expected_grads = self._compute_expected_gradients(
          train_data,
          train_labels,
          train_weights,
          np.zeros(
              2,
          ),
          l2_norm_clip,
          effective_num_microbatches,
      )
      expected_weights = np.squeeze(-learning_rate * expected_grads)
      self.assertAllClose(model_weights, expected_weights)
  
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 4 for calling the DPKerasModelTest obj's underlying member method code with example usage: obj.testMicrobatches(num_microbatches, fast_clipping, sequential, weighted) without return types