def _build_example(query):
  """Creates a tf.Example for prediction with T5 from the input query.

  Args:
    query: a dict mapping query features to their values.

  Returns:
    a tf.train.Example consisting of the query features.
  """
  # Inputs and targets.
  inp = query["query"].encode("utf-8")
  trg = query["answer"]["name"].encode("utf-8")
  # Metadata.
  id_ = query["id"].encode("utf-8")
  recent = query["most_recent_answer"]["name"].encode("utf-8")
  frequent = query["most_frequent_answer"]["name"].encode("utf-8")
  rel = query["relation"].encode("utf-8")
  # Construct TFRecord.
  feature = {
      "id":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[id_])),
      "date":
          tf.train.Feature(
              int64_list=tf.train.Int64List(value=[int(query["date"])])),
      "relation":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[rel])),
      "query":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[inp])),
      "answer":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[trg])),
      "most_frequent_answer":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[frequent])),
      "most_recent_answer":
          tf.train.Feature(bytes_list=tf.train.BytesList(value=[recent])),
  }
  return tf.train.Example(features=tf.train.Features(feature=feature))
Creates a tf.Example for prediction with T5 from the input query.

  Args:
    query: a dict mapping query features to their values.

  Returns:
    a tf.train.Example consisting of the query features.
  
language/templama/templama.py