code: def test_sparse_nuclear():
      # TODO:
      #       To address the issue #347 and issue #36764.
      for dtype in _dtypes_with_checking_system(
          use_gpu=test_utils.is_gpu_available(),
          system=platform.system(),
      ):
          var0 = tf.Variable(tf.zeros([4, 2], dtype=dtype))
          var1 = tf.Variable(tf.constant(1.0, dtype, [4, 2]))
          grads0 = tf.IndexedSlices(
              tf.constant([[0.1, 0.1]], dtype=dtype),
              tf.constant([1]),
              tf.constant([4, 2]),
          )
          grads1 = tf.IndexedSlices(
              tf.constant([[0.01, 0.01], [0.01, 0.01]], dtype=dtype),
              tf.constant([2, 3]),
              tf.constant([4, 2]),
          )
          top_singular_vector0 = tf.constant(
              [
                  [0.0, 0.0],
                  [0.7071067, 0.7071067],
                  [0.0, 0.0],
                  [0.0, 0.0],
              ],
              dtype=dtype,
          )
          top_singular_vector1 = tf.constant(
              [
                  [-4.2146844e-08, -4.2146844e-08],
                  [0.0000000e00, 0.0000000e00],
                  [4.9999994e-01, 4.9999994e-01],
                  [4.9999994e-01, 4.9999994e-01],
              ],
              dtype=dtype,
          )
          learning_rate = 0.1
          lambda_ = 0.1
          ord = "nuclear"
          cg_opt = cg_lib.ConditionalGradient(
              learning_rate=learning_rate, lambda_=lambda_, ord=ord
          )
          _ = cg_opt.apply_gradients(
              zip([grads0, grads1], [var0, var1])
          )
  
          # Check we have slots
          assert ["conditional_gradient"] == cg_opt.get_slot_names()
          slot0 = cg_opt.get_slot(var0, "conditional_gradient")
          assert slot0.get_shape() == var0.get_shape()
          slot1 = cg_opt.get_slot(var1, "conditional_gradient")
          assert slot1.get_shape() == var1.get_shape()
  
          # Check that the parameters have been updated.
          test_utils.assert_allclose_according_to_type(
              np.array(
                  [
                      0
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[0][0],
                      0
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[0][1],
                  ]
              ),
              var0[0].numpy(),
          )
          test_utils.assert_allclose_according_to_type(
              np.array(
                  [
                      0
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[1][0],
                      0
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[1][1],
                  ]
              ),
              var0[1].numpy(),
          )
          test_utils.assert_allclose_according_to_type(
              np.array(
                  [
                      1.0 * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector1[2][0],
                      1.0 * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector1[2][1],
                  ]
              ),
              var1[2].numpy(),
          )
          # Step 2: the conditional_gradient contain the
          # previous update.
          cg_opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
  
          # Check that the parameters have been updated.
          np.testing.assert_allclose(np.array([0, 0]), var0[0].numpy())
          test_utils.assert_allclose_according_to_type(
              np.array(
                  [
                      (
                          0
                          - (1 - learning_rate)
                          * lambda_
                          * top_singular_vector0[1][0]
                      )
                      * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[1][0],
                      (
                          0
                          - (1 - learning_rate)
                          * lambda_
                          * top_singular_vector0[1][1]
                      )
                      * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector0[1][1],
                  ]
              ),
              var0[1].numpy(),
          )
          test_utils.assert_allclose_according_to_type(
              np.array(
                  [
                      (
                          1.0 * learning_rate
                          - (1 - learning_rate)
                          * lambda_
                          * top_singular_vector1[2][0]
                      )
                      * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector1[2][0],
                      (
                          1.0 * learning_rate
                          - (1 - learning_rate)
                          * lambda_
                          * top_singular_vector1[2][1]
                      )
                      * learning_rate
                      - (1 - learning_rate)
                      * lambda_
                      * top_singular_vector1[2][1],
                  ]
              ),
              var1[2].numpy(),
          )
  
imports: import numpy
  import pytest
  import platform
  import tensorflow
  from tensorflow_addons.utils import test_utils
  from tensorflow_addons.optimizers import conditional_gradient
label_desc: Use image node_id 20 for calling a global function with example usage: test_sparse_nuclear() without return types