code: def _compute_expected_gradients(
      self,
      data,
      labels,
      weights,
      w0,
      l2_norm_clip,
      num_microbatches,
  ):
      if weights is None:
          weights = np.array([1], dtype=np.float32)
      batch_size = data.shape[0]
      if num_microbatches is None:
          num_microbatches = batch_size
      preds = np.matmul(data, w0[:, np.newaxis])
      grads = 2 * data * (preds - labels) * weights[:, np.newaxis]
      grads = np.reshape(
          grads, [num_microbatches, batch_size // num_microbatches, -1]
      )
      mb_grads = np.mean(grads, axis=1)
      mb_grad_norms = np.linalg.norm(mb_grads, axis=1)
      scale = np.minimum(l2_norm_clip / mb_grad_norms, 1.0)
      mb_grads = mb_grads * scale[:, np.newaxis]
      final_grads = np.mean(mb_grads, axis=0)
      return final_grads
  
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 3 for calling the DPKerasModelTest obj's underlying member method code with example usage: obj._compute_expected_gradients(data, labels, weights, w0, l2_norm_clip, num_microbatches) and returns: final_grads