code: def do_test(
      dtype,
      optimizer,
      update_fn,
      do_sparse=False,
      do_decay_var_list=False,
      **optimizer_kwargs,
  ):
      """The major test function.
  
      Args:
          optimizer: The tensorflow optimizer class to be tested.
          update_fn: The numpy update function of the optimizer, the function
              signature must be
              update_fn(var: np.array,
                          grad_t: np.array,
                          slot_vars: dict,
                          **kwargs) -> (updated_var, updated_slot_vars)
              Note that slot_vars will be initialized to an empty dictionary
              for each variable, initial values should be handled in the
              update_fn.
          do_sparse: If True, test sparse update. Defaults to False, i.e.,
              dense update.
          do_decay_var_list: If True, test by passing a list of vars to ensure hashing is handled correctly
          **optimizer_kwargs:The parameters to pass to the construcor of the
              optimizer. Either a constant or a callable. This also passed to
              the optimizer_params in the update_fn.
      """
      # TODO: Fix #347 issue
      if do_sparse and test_utils.is_gpu_available():
          pytest.skip("Wait #347 to be fixed")
  
      # Initialize variables for numpy implementation.
      np_slot_vars0, np_slot_vars1 = {}, {}
      var0_np = np.array([1.0, 2.0], dtype=dtype[0].as_numpy_dtype)
      grads0_np = np.array([0.1, 0.1], dtype=dtype[0].as_numpy_dtype)
      var1_np = np.array([3.0, 4.0], dtype=dtype[0].as_numpy_dtype)
      grads1_np = np.array([0.01, 0.01], dtype=dtype[0].as_numpy_dtype)
      # Create Tensorflow variables.
      var0 = tf.Variable(var0_np, name="var0_%d" % dtype[1])
      var1 = tf.Variable(var1_np, name="var1_%d" % dtype[1])
      if do_sparse:
          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]),
          )
      else:
          grads0 = tf.constant(grads0_np)
          grads1 = tf.constant(grads1_np)
      opt = optimizer(**optimizer_kwargs)
      # Create the update op.
      # Run 3 steps of the optimizer
      optimizer_kwargs.pop("exclude_from_weight_decay", None)
      for _ in range(3):
          if do_decay_var_list:
              opt.apply_gradients(
                  zip([grads0, grads1], [var0, var1]),
                  decay_var_list=[var0, var1],
              )
          else:
              opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
  
          var0_np, np_slot_vars0 = update_fn(
              var0_np, grads0_np, np_slot_vars0, **optimizer_kwargs
          )
          var1_np, np_slot_vars1 = update_fn(
              var1_np, grads1_np, np_slot_vars1, **optimizer_kwargs
          )
          # 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 importlib
  import numpy
  import pytest
  import tensorflow
  from tensorflow_addons.utils import test_utils
  from tensorflow_addons.optimizers import weight_decay_optimizers
label_desc: Use image node_id 1 for calling a global function with example usage: do_test(dtype, optimizer, update_fn, do_sparse, do_decay_var_list) without return types