code: def test_sparse_correctness(
      self, optimizer_class, init_kwargs={}, **kwargs
  ):
      # This test verifies that applying a sparse gradient gives the same
      # numerical results as the same dense gradient.
  
      optimizer_sparse = optimizer_class(**init_kwargs)
      optimizer_dense = optimizer_class(**init_kwargs)
      var_sparse = backend.Variable(
          initializer=tf.ones, shape=(5, 3, 2)
      )
      var_dense = backend.Variable(initializer=tf.ones, shape=(5, 3, 2))
  
      for i in range(5):
          grads_sparse = tf.IndexedSlices(
              values=tf.ones((3, 3, 2)) * (10.0 - i),
              indices=(0, 2, 4),
              dense_shape=(5, 3, 2),
          )
          grads_dense = tf.convert_to_tensor(grads_sparse)
          optimizer_sparse.apply_gradients(
              zip([grads_sparse], [var_sparse])
          )
          optimizer_dense.apply_gradients(
              zip([grads_dense], [var_dense])
          )
          self.assertAllClose(var_sparse, var_dense)
  
file_path: keras/keras/backend/tensorflow/optimizer_sparse_test.py
imports: from unittest import mock
  import pytest
  import tensorflow
  from absl.testing import parameterized
  from keras import backend
  from keras import optimizers
  from keras import testing
label_desc: Use image node_id 2 for calling the OptimizerSparseTest obj's underlying member method code with example usage: obj.test_sparse_correctness(optimizer_class, init_kwargs) without return types