code: def test_ema(self):
      v = backend.Variable([[3.0, 4.0], [5.0, 6.0]])
      grads = backend.convert_to_tensor([[1.0, 1.0], [1.0, 1.0]])
      optimizer = optimizers.SGD(
          learning_rate=1.0,
          use_ema=True,
          ema_momentum=0.9,
          ema_overwrite_frequency=3,
      )
      optimizer.apply_gradients([(grads, v)])
      self.assertAllClose(v, [[2.0, 3.0], [4.0, 5.0]])
      self.assertAllClose(
          optimizer._model_variables_moving_average[0],
          [[2.0, 3.0], [4.0, 5.0]],  # initialized after first step
      )
      optimizer.apply_gradients([(grads, v)])
      self.assertAllClose(v, [[1.0, 2.0], [3.0, 4.0]])
      self.assertAllClose(
          optimizer._model_variables_moving_average[0],
          [[1.9, 2.9], [3.9, 4.9]],
      )
      optimizer.apply_gradients([(grads, v)])
      # Variables were overwritten with EMA
      self.assertAllClose(v, [[1.71, 2.71], [3.71, 4.71]])
      self.assertAllClose(
          optimizer._model_variables_moving_average[0],
          [[1.71, 2.71], [3.71, 4.71]],
      )
  
file_path: keras/keras/optimizers/optimizer_test.py
imports: import numpy
  import pytest
  from keras import backend
  from keras import constraints
  from keras import layers
  from keras import models
  from keras import optimizers
  from keras import testing
label_desc: Use image node_id 2 for calling the OptimizerTest obj's underlying member method code with example usage: obj.test_ema() without return types