code: def do_test_sparse(beta1=0.0, l1reg=0.0, l2reg=0.0):
      for dtype in _dtypes_to_test(
          use_gpu=test_utils.is_gpu_available()
      ):
          # Initialize variables for numpy implementation.
          m0, v0, m1, v1 = 0.0, 1.0, 0.0, 1.0
          var0_np = np.array([1.0, 2.0], dtype=dtype.as_numpy_dtype)
          grads0_np = np.array([0.1, 0.1], dtype=dtype.as_numpy_dtype)
          var1_np = np.array([3.0, 4.0], dtype=dtype.as_numpy_dtype)
          grads1_np = np.array([0.01, 0.01], dtype=dtype.as_numpy_dtype)
  
          var0 = tf.Variable(var0_np)
          var1 = tf.Variable(var1_np)
          grads0_np_indices = np.array([0, 1], dtype=np.int32)
          grads0 = tf.IndexedSlices(
              tf.constant(grads0_np),
              tf.constant(grads0_np_indices),
              tf.constant([2]),
          )
          grads1_np_indices = np.array([0, 1], dtype=np.int32)
          grads1 = tf.IndexedSlices(
              tf.constant(grads1_np),
              tf.constant(grads1_np_indices),
              tf.constant([2]),
          )
          opt = yogi.Yogi(
              beta1=beta1,
              l1_regularization_strength=l1reg,
              l2_regularization_strength=l2reg,
              initial_accumulator_value=1.0,
          )
  
          # Fetch params to validate initial values.
          np.testing.assert_allclose(
              np.asanyarray([1.0, 2.0]), var0.numpy()
          )
          np.testing.assert_allclose(
              np.asanyarray([3.0, 4.0]), var1.numpy()
          )
  
          # Run 3 steps of Yogi.
          for t in range(1, 4):
              beta1_power, beta2_power = get_beta_accumulators(
                  opt, dtype
              )
              test_utils.assert_allclose_according_to_type(
                  beta1**t, beta1_power
              )
              test_utils.assert_allclose_according_to_type(
                  0.999**t, beta2_power
              )
              opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
  
              var0_np, m0, v0 = yogi_update_numpy(
                  var0_np,
                  grads0_np,
                  t,
                  m0,
                  v0,
                  beta1=beta1,
                  l1reg=l1reg,
                  l2reg=l2reg,
              )
              var1_np, m1, v1 = yogi_update_numpy(
                  var1_np,
                  grads1_np,
                  t,
                  m1,
                  v1,
                  beta1=beta1,
                  l1reg=l1reg,
                  l2reg=l2reg,
              )
  
              # Validate updated params.
              test_utils.assert_allclose_according_to_type(
                  var0_np, var0.numpy()
              )
              test_utils.assert_allclose_according_to_type(
                  var1_np, var1.numpy()
              )
  
imports: import numpy
  import pytest
  import tensorflow
  from tensorflow_addons.optimizers import yogi
  from tensorflow_addons.utils import test_utils
label_desc: Use image node_id 4 for calling a global function with example usage: do_test_sparse(beta1, l1reg, l2reg) without return types