code: def test_training_logistic(self):
      self._config.gradient_descent_config.learning_rate = 0.05
      fea_embed = sparse_features.SparseFeatureEmbedding(
          self._config,
          {"weather": (10, 2), "day_of_week": (10, 2)},
          op_name="multiple_feature",
          service_address=self._kbs_address,
      )
  
      model = tf.keras.models.Sequential(
          [fea_embed, tf.keras.layers.Dense(2, activation="softmax")]
      )
      model.compile(
          optimizer="sgd",
          loss="categorical_crossentropy",
          metrics=["accuracy"],
      )
  
      # Create an optimizer.
      optimizer = tf.keras.optimizers.SGD(learning_rate=0.05)
  
      x_train = {
          "weather": [
              ["cold", "day"],
              ["hot", ""],
              ["warm", "day"],
              ["warm", ""],
          ],
          "day_of_week": [
              ["monday", "day"],
              ["tuesday", "day"],
              ["sunday", ""],
              ["saturday", ""],
          ],
      }
      y_train = np.array(
          [[0.0, 1.0], [0.0, 1.0], [1.0, 0.0], [1.0, 0.0]]
      )
      # Test the shape of model's output.
      self.assertEqual((4, 2), model(x_train).shape)
      loss_layer = tf.keras.losses.CategoricalCrossentropy(
          from_logits=True
      )
  
      logits = model(x_train)
      init_loss = loss_layer(logits, y_train)
      for _ in range(10):
          with tf.GradientTape() as tape:
              logits = model(x_train)
              loss = loss_layer(logits, y_train)
          grads = tape.gradient(loss, model.trainable_weights)
          # Update the trainable variables w.r.t. the logistic loss
          optimizer.apply_gradients(zip(grads, model.trainable_weights))
          print("===>loss: ", loss_layer(logits, y_train).numpy())
      # Checks the loss is dropped after 10 steps of training.
      logits = model(x_train)
      final_loss = loss_layer(logits, y_train)
      self.assertLess(final_loss.numpy(), init_loss.numpy())
  
imports: from absl.testing import parameterized
  from research.carls.models.caml import sparse_features
  from research.carls.testing import test_util
  import numpy
  import tensorflow
label_desc: Use image node_id 13 for calling the FeatureEmbeddingTest obj's underlying member method code with example usage: obj.test_training_logistic() without return types