def ComputePredictions(self, theta, encoder_outputs, targets):
    """Computes logits.

    Args:
      theta: A NestedMap object containing weights values of this layer and its
        child layers.
      encoder_outputs: a NestedMap computed by encoder.
      targets: A dict of string to tensors representing the targets one is
        trying to predict. Each tensor in targets is of shape [batch, time].

    Returns:
      A NestedMap object containing logit tensors as values, each of shape
      [target_batch, max_target_length, vocab_size]. One of the keys must be
      'logits'.
    """
    assert getattr(encoder_outputs, 'src_segment_id', None) is None
    p = self.params
    self.contextualizer.SetContextMap(targets, theta.contextualizer)
    if 'weights' not in targets and 'paddings' in targets:
      targets.weights = 1.0 - targets.paddings
    if p.use_while_loop_based_unrolling:
      predictions = self.ComputePredictionsDynamic(theta, encoder_outputs,
                                                   targets)
    else:
      predictions = self.ComputePredictionsFunctional(theta, encoder_outputs,
                                                      targets)
    if encoder_outputs and isinstance(encoder_outputs.padding, tf.Tensor):
      # source_padding is of shape [time, batch]. Compute source_enc_len, which
      # is used for computing attention loss.
      predictions.source_enc_len = tf.reduce_sum(
          1 - encoder_outputs.padding, axis=0)
      if 'paddings' in targets:
        source_batch = py_utils.GetShape(encoder_outputs.padding)[1]
        target_batch = py_utils.GetShape(targets.paddings)[0]
        multiplier = target_batch // source_batch
        source_len = py_utils.RepeatDim(
            predictions.source_enc_len, multiplier, axis=0)
        target_len = tf.reduce_sum(1 - targets.paddings, axis=1)
        target_source_length_ratio = target_len / tf.maximum(source_len, 1.0)
        summary_utils.scalar('avg_target_source_length_ratio',
                             tf.reduce_mean(target_source_length_ratio))
    return predictions
Computes logits.

    Args:
      theta: A NestedMap object containing weights values of this layer and its
        child layers.
      encoder_outputs: a NestedMap computed by encoder.
      targets: A dict of string to tensors representing the targets one is
        trying to predict. Each tensor in targets is of shape [batch, time].

    Returns:
      A NestedMap object containing logit tensors as values, each of shape
      [target_batch, max_target_length, vocab_size]. One of the keys must be
      'logits'.
    
contrib/lingvo-patched-decoder.py