def predict(self, encoder_outputs, training):
    'Return predicted sequence.'
    batch_size = tf.shape(encoder_outputs)[0]
    symbols_to_logits_fn = self._get_symbols_to_logits_fn(max_decode_length=self._MAX_DECODE_LENGTH, training=training)
    initial_ids = (tf.ones([batch_size], dtype=tf.int32) * input_utils.START)
    init_decode_length = 0
    num_heads = self._hparams['num_heads']
    dim_per_head = (self._hparams['hidden_size'] // num_heads)
    cache = {('layer_%d' % layer): {'k': tf.zeros([batch_size, init_decode_length, num_heads, dim_per_head]), 'v': tf.zeros([batch_size, init_decode_length, num_heads, dim_per_head])} for layer in range(self._hparams['num_hidden_layers'])}
    encoder_shape = tf.shape(encoder_outputs)
    mask = tf.ones([encoder_shape[0], encoder_shape[1]])
    attention_bias = model_utils.get_padding_bias(mask)
    cache['encoder_outputs'] = encoder_outputs
    cache['encoder_decoder_attention_bias'] = attention_bias
    (decoded_ids, _) = ops.beam_search.sequence_beam_search(symbols_to_logits_fn=symbols_to_logits_fn, initial_ids=initial_ids, initial_cache=cache, vocab_size=self._hparams['vocab_size'], beam_size=self._hparams['beam_size'], alpha=1, max_decode_length=self._MAX_DECODE_LENGTH, eos_id=input_utils.EOS)
    top_decoded_ids = decoded_ids[:, 0, 1:]
    return top_decoded_ids
Return predicted sequence.
def predict(self, encoder_outputs, training):
    
    batch_size = tf.shape(encoder_outputs)[0]
    symbols_to_logits_fn = self._get_symbols_to_logits_fn(max_decode_length=self._MAX_DECODE_LENGTH, training=training)
    initial_ids = (tf.ones([batch_size], dtype=tf.int32) * input_utils.START)
    init_decode_length = 0
    num_heads = self._hparams['num_heads']
    dim_per_head = (self._hparams['hidden_size'] // num_heads)
    cache = {('layer_%d' % layer): {'k': tf.zeros([batch_size, init_decode_length, num_heads, dim_per_head]), 'v': tf.zeros([batch_size, init_decode_length, num_heads, dim_per_head])} for layer in range(self._hparams['num_hidden_layers'])}
    encoder_shape = tf.shape(encoder_outputs)
    mask = tf.ones([encoder_shape[0], encoder_shape[1]])
    attention_bias = model_utils.get_padding_bias(mask)
    cache['encoder_outputs'] = encoder_outputs
    cache['encoder_decoder_attention_bias'] = attention_bias
    (decoded_ids, _) = ops.beam_search.sequence_beam_search(symbols_to_logits_fn=symbols_to_logits_fn, initial_ids=initial_ids, initial_cache=cache, vocab_size=self._hparams['vocab_size'], beam_size=self._hparams['beam_size'], alpha=1, max_decode_length=self._MAX_DECODE_LENGTH, eos_id=input_utils.EOS)
    top_decoded_ids = decoded_ids[:, 0, 1:]
    return top_decoded_ids