code: def test_train_and_eval(self, use_pipeline, saved_model_dir):
      # `create_tempdir` creates an isolated directory for this test, and
      # will be properly cleaned up by the test.
      data_dir = self.create_tempdir()
      data_file = os.path.join(data_dir, "elwc.tfrecord")
      vocab_file = os.path.join(data_dir, "vocab.txt")
      model_dir = os.path.join(data_dir, "model")
  
      # Save data.
      with tf.io.TFRecordWriter(data_file) as writer:
          for _ in range(10):
              writer.write(ELWC.SerializeToString())
  
      with tf.io.gfile.GFile(vocab_file, "w") as writer:
          writer.write("\n".join(VOCAB) + "\n")
  
      with flagsaver.flagsaver(
          train_input_pattern=data_file,
          eval_input_pattern=data_file,
          model_dir=model_dir,
          vocab_file_path=vocab_file,
          train_batch_size=2,
          eval_batch_size=2,
          num_epochs=5,
          num_train_steps=10,
          num_valid_steps=10,
          vocab_size=len(VOCAB),
          use_pipeline=use_pipeline,
          hidden_layer_dims=[16, 8],
      ):
          # Train and eval model.
          tf.random.set_seed(1234)
          antique_ragged.main(0)
  
          # Check SavedModel is exported correctly.
          saved_model_path = os.path.join(model_dir, saved_model_dir)
          self.assertTrue(
              tf.saved_model.contains_saved_model(saved_model_path)
          )
  
      # Check SavedModel can be loaded and called with ragged tensors.
      saved_model = tf.keras.models.load_model(saved_model_path)
      inputs = {
          "query_tokens": tf.ragged.constant(
              [["this", "is", "a", "relevant", "question"]],
              row_splits_dtype=tf.int32,
          ),
          "document_tokens": tf.ragged.constant(
              [
                  [
                      ["this", "is", "a", "relevant", "answer"],
                      ["irrelevant", "data"],
                  ]
              ],
              row_splits_dtype=tf.int32,
          ),
      }
      scores = saved_model(inputs)
  
      # Assert model output is a ragged tensor and has the correct contents.
      self.assertIsInstance(scores, tf.RaggedTensor)
      self.assertGreater(scores[0, 0], scores[0, 1])
  
file_path: ranking/tensorflow_ranking/examples/keras/antique_ragged_test.py
imports: import os
  from absl.testing import flagsaver
  from absl.testing import parameterized
  import tensorflow
  from google.protobuf import text_format
  from tensorflow_ranking.examples.keras import antique_ragged
  from tensorflow_serving.apis import input_pb2
label_desc: Use image node_id 1 for calling the ModelTrainAndEvaluateTest obj's underlying member method code with example usage: obj.test_train_and_eval(use_pipeline, saved_model_dir) without return types