code: def test_sparse_exact_ratio():
      for k in [5, 10, 100]:
          for alpha in [0.3, 0.7]:
              optimizer = tf.keras.optimizers.get("adam")
              vals, quick_vars = run_sparse_sample(k, optimizer)
              optimizer = Lookahead(
                  "adam", sync_period=k, slow_step_size=alpha
              )
              _, slow_vars = run_sparse_sample(k, optimizer)
              for val, quick, slow in zip(vals, quick_vars, slow_vars):
                  expected = val + (quick - val) * alpha
                  np.testing.assert_allclose(
                      expected.numpy(),
                      slow.numpy(),
                      rtol=1e-06,
                      atol=1e-06,
                  )
  
file_path: addons/tensorflow_addons/optimizers/tests/lookahead_test.py
imports: import numpy
  import pytest
  import tensorflow
  from tensorflow_addons.optimizers import Lookahead
label_desc: Use image node_id 4 for calling a global function with example usage: test_sparse_exact_ratio() without return types