def decode(self, targets, encoder_outputs, training):
    'Generate logits for each value in the target sequence.\n\n    Args:\n      targets: target values for the output sequence. int tensor with shape\n        [batch_size, target_length]\n      encoder_outputs: continuous representation of input sequence. float tensor\n        with shape [batch_size, input_length, hidden_size]\n      training: boolean, whether in training mode or not.\n\n    Returns:\n      float32 tensor with shape [batch_size, target_length, vocab_size]\n    '
    with tf.name_scope('decode'):
        length = tf.shape(targets)[1]
        decoder_self_attention_bias = model_utils.get_decoder_self_attention_bias(length)
        encoder_shape = tf.shape(encoder_outputs)
        mask = tf.ones([encoder_shape[0], encoder_shape[1]])
        attention_bias = model_utils.get_padding_bias(mask)
        targets = tf.pad(targets, [[0, 0], [1, 0]], constant_values=input_utils.START)
        targets = targets[:, :(- 1)]
        decoder_inputs = self._word_embedding_layer(targets)
        with tf.name_scope('add_pos_encoding'):
            pos_encoding = self._position_embedding_layer(decoder_inputs)
            decoder_inputs += pos_encoding
        if training:
            decoder_inputs = tf.nn.dropout(decoder_inputs, rate=self._hparams['layer_postprocess_dropout'])
        decoder_outputs = self._decoder(decoder_inputs, encoder_outputs, decoder_self_attention_bias, attention_bias, training=training)
        logits = self._word_layer(decoder_outputs)
        return logits
Generate logits for each value in the target sequence.

Args:
  targets: target values for the output sequence. int tensor with shape
    [batch_size, target_length]
  encoder_outputs: continuous representation of input sequence. float tensor
    with shape [batch_size, input_length, hidden_size]
  training: boolean, whether in training mode or not.

Returns:
  float32 tensor with shape [batch_size, target_length, vocab_size]
def decode(self, targets, encoder_outputs, training):
    'Generate logits for each value in the target sequence.\n\n    Args:\n      targets: target values for the output sequence. int tensor with shape\n        [batch_size, target_length]\n      encoder_outputs: continuous representation of input sequence. float tensor\n        with shape [batch_size, input_length, hidden_size]\n      training: boolean, whether in training mode or not.\n\n    Returns:\n      float32 tensor with shape [batch_size, target_length, vocab_size]\n    '
    with tf.name_scope('decode'):
        length = tf.shape(targets)[1]
        decoder_self_attention_bias = model_utils.get_decoder_self_attention_bias(length)
        encoder_shape = tf.shape(encoder_outputs)
        mask = tf.ones([encoder_shape[0], encoder_shape[1]])
        attention_bias = model_utils.get_padding_bias(mask)
        targets = tf.pad(targets, [[0, 0], [1, 0]], constant_values=input_utils.START)
        targets = targets[:, :(- 1)]
        decoder_inputs = self._word_embedding_layer(targets)
        with tf.name_scope('add_pos_encoding'):
            pos_encoding = self._position_embedding_layer(decoder_inputs)
            decoder_inputs += pos_encoding
        if training:
            decoder_inputs = tf.nn.dropout(decoder_inputs, rate=self._hparams['layer_postprocess_dropout'])
        decoder_outputs = self._decoder(decoder_inputs, encoder_outputs, decoder_self_attention_bias, attention_bias, training=training)
        logits = self._word_layer(decoder_outputs)
        return logits