class_docstr: Tests dp_optimizer_keras_sparse optimizers.
class_docstr_tok: ["Tests","dp_optimizer_keras_sparse","optimizers","."]
code: def testLargeBatchEmulation(self, cls, gradient_accumulation_steps):
      # Tests various optimizers with large batch emulation.
      # Uses clipping and noise, thus does not test specific values
      # of the variables and only tests how often variables are updated.
      var0 = tf.Variable([[1.0, 2.0]], dtype=tf.float32)
      var1 = tf.Variable([3.0], dtype=tf.float32)
      x = tf.constant([[2.0, 0.0], [0.0, 1.0]], dtype=tf.float32)
      loss = lambda: tf.matmul(var0, x, transpose_b=True) + var1
  
      opt = cls(
          l2_norm_clip=100.0,
          noise_multiplier=0.0,
          gradient_accumulation_steps=gradient_accumulation_steps,
          learning_rate=1.0,
      )
  
      for _ in range(gradient_accumulation_steps):
          self.assertAllCloseAccordingToType([[1.0, 2.0]], var0)
          self.assertAllCloseAccordingToType([3.0], var1)
          opt.minimize(loss, [var0, var1])
  
      self.assertNotAllClose([[1.0, 2.0]], var0)
      self.assertNotAllClose([3.0], var1)
      self.assertEqual(opt.iterations, 1)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.optimizers import dp_optimizer_keras_sparse
label_desc: Use image node_id 11 for calling the DPOptimizerTest obj's underlying member method code with example usage: obj.testLargeBatchEmulation(cls, gradient_accumulation_steps) without return types