def score_endpoints(question_emb,
                    question_len,
                    context_emb,
                    context_len,
                    hidden_size,
                    num_layers,
                    dropout_ratio,
                    mode,
                    use_cudnn=None):
  """Compute two scores over context words based on the input embeddings.

  Args:
    question_emb: <float32> [batch_size, max_question_len, hidden_size]
    question_len: <int32> [batch_size]
    context_emb: <float32>[batch_size, max_context_len, hidden_size]
    context_len: <int32> [batch_size]
    hidden_size: Size of hidden layers.
    num_layers: Number of LSTM layers.
    dropout_ratio: The probability of dropping out hidden units.
    mode: Object of type tf.estimator.ModeKeys.
    use_cudnn: Specify the use of cudnn. `None` denotes automatic selection.

  Returns:
    start_scores: <float32> [batch_size, max_context_words]
    end_scores: <float32> [batch_size, max_context_words]
  """
  # [batch_size, max_question_len]
  question_mask = tf.sequence_mask(
      question_len, tensor_utils.shape(question_emb, 1), dtype=tf.float32)

  # [batch_size, max_context_len, hidden_size]
  attended_emb = _attend_to_question(
      context_emb=context_emb,
      question_emb=question_emb,
      question_mask=question_mask,
      hidden_size=hidden_size)

  # [batch_size, max_context_len, hidden_size * 2]
  context_emb = tf.concat([context_emb, attended_emb], -1)

  with tf.variable_scope("contextualize_context"):
    # [batch_size, max_context_len, hidden_size]
    contextualized_context_emb = cudnn_layers.stacked_bilstm(
        input_emb=context_emb,
        input_len=context_len,
        hidden_size=hidden_size,
        num_layers=num_layers,
        dropout_ratio=dropout_ratio,
        mode=mode,
        use_cudnn=use_cudnn)
  with tf.variable_scope("contextualize_question"):
    # [batch_size, max_question_len, hidden_size]
    contextualized_question_emb = cudnn_layers.stacked_bilstm(
        input_emb=question_emb,
        input_len=question_len,
        hidden_size=hidden_size,
        num_layers=num_layers,
        dropout_ratio=dropout_ratio,
        mode=mode,
        use_cudnn=use_cudnn)
  if mode == tf_estimator.ModeKeys.TRAIN:
    contextualized_context_emb = tf.nn.dropout(contextualized_context_emb,
                                               1.0 - dropout_ratio)
    contextualized_question_emb = tf.nn.dropout(contextualized_question_emb,
                                                1.0 - dropout_ratio)

  # [batch_size, hidden_size]
  pooled_question_emb = _attention_pool(contextualized_question_emb,
                                        question_mask)

  if mode == tf_estimator.ModeKeys.TRAIN:
    pooled_question_emb = tf.nn.dropout(pooled_question_emb,
                                        1.0 - dropout_ratio)

  # [batch_size, max_context_len]
  with tf.variable_scope("start_scores"):
    start_scores = _bilinear_score(contextualized_context_emb,
                                   pooled_question_emb)
  with tf.variable_scope("end_scores"):
    end_scores = _bilinear_score(contextualized_context_emb,
                                 pooled_question_emb)
  context_log_mask = tf.log(
      tf.sequence_mask(
          context_len, tensor_utils.shape(context_emb, 1), dtype=tf.float32))
  start_scores += context_log_mask
  end_scores += context_log_mask
  return start_scores, end_scores
Compute two scores over context words based on the input embeddings.

  Args:
    question_emb: <float32> [batch_size, max_question_len, hidden_size]
    question_len: <int32> [batch_size]
    context_emb: <float32>[batch_size, max_context_len, hidden_size]
    context_len: <int32> [batch_size]
    hidden_size: Size of hidden layers.
    num_layers: Number of LSTM layers.
    dropout_ratio: The probability of dropping out hidden units.
    mode: Object of type tf.estimator.ModeKeys.
    use_cudnn: Specify the use of cudnn. `None` denotes automatic selection.

  Returns:
    start_scores: <float32> [batch_size, max_context_words]
    end_scores: <float32> [batch_size, max_context_words]
  
language/question_answering/decatt_docreader/layers/document_reader.py