def compute_average_embs(self, question):
    """Compute the text encoding of questions.

    We take a bag of word approach. Question encoding is an average pooling
    of word embeddings.

    Args:
      question: a list of token ids

    Returns:
      a tensor for question encoding
    """
    question_mask = tf.cast(tf.not_equal(question, -1), tf.int32)
    # batch_size, max_question_len
    question_mask_3d = tf.cast(
        tf.expand_dims(question_mask, axis=2), tf.float32)
    question_embs = tf.nn.embedding_lookup(
        self.word_embeddings_mat, question * question_mask)
    # batch_size, max_question_len, hidden_size
    question_embs = tf.reduce_sum(question_embs * question_mask_3d, axis=1)
    # batch_size, hidden_size
    question_len = tf.reduce_sum(question_mask, axis=1, keepdims=True)
    # batch_size, 1
    question_embs /= tf.cast(question_len, tf.float32)
    # batch_size, hidden_size
    return question_embs
Compute the text encoding of questions.

    We take a bag of word approach. Question encoding is an average pooling
    of word embeddings.

    Args:
      question: a list of token ids

    Returns:
      a tensor for question encoding
    
language/emql/model.py