code: def test_ema(self):
      with self.strategy.scope():
          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 = SGD(
              learning_rate=1.0,
              use_ema=True,
              ema_momentum=0.9,
              ema_overwrite_frequency=3,
          )
          self.strategy.run(
              lambda: 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
          )
          self.strategy.run(
              lambda: 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]],
          )
          self.strategy.run(
              lambda: 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/backend/tensorflow/optimizer_distribute_test.py
imports: import numpy
  import pytest
  import tensorflow
  from tensorflow.python.eager import context
  from keras import backend
  from keras import testing
  from keras.optimizers.sgd import SGD
label_desc: Use image node_id 9 for calling the OptimizerDistributeTest obj's underlying member method code with example usage: obj.test_ema() without return types