code: def test_tf_optimizer_with_sparse_gradient_using_keras(self):
      import tensorflow as tf
  
      ids = np.random.randint(0, 10, size=[40])
      labels = np.random.randint(0, 5, size=[40])
      id_rdd = self.sc.parallelize(ids)
      label_rdd = self.sc.parallelize(labels)
      training_rdd = id_rdd.zip(label_rdd).map(lambda x: [x[0], x[1]])
  
      dataset = TFDataset.from_rdd(
          training_rdd,
          features=(tf.int32, []),
          labels=(tf.int32, []),
          batch_size=8,
      )
      words_input = tf.keras.layers.Input(shape=(), name="words_input")
      embedding_layer = tf.keras.layers.Embedding(
          input_dim=10, output_dim=5, name="word_embedding"
      )
      word_embeddings = embedding_layer(words_input)
      embedding = tf.keras.layers.Flatten()(word_embeddings)
      output = tf.keras.layers.Dense(5, activation="softmax")(embedding)
      model = tf.keras.models.Model(
          inputs=[words_input], outputs=[output]
      )
      model.compile(
          optimizer="sgd", loss="sparse_categorical_crossentropy"
      )
  
      optimizer = TFOptimizer.from_keras(model, dataset)
      optimizer.optimize()
  
imports: import pytest
  from test.zoo.pipeline.utils.test_utils import ZooTestCase
  import tensorflow
  import numpy
  import os
  from zoo.tfpark import KerasModel, TFDataset, TFOptimizer
label_desc: Use image node_id 21 for calling the TestTFParkModel obj's underlying member method code with example usage: obj.test_tf_optimizer_with_sparse_gradient_using_keras() without return types