'A inference method.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer.  How many additional timesteps to decode.
beam_size: number of beams.
top_beams: an integer. How many of the beams to return.
last_position_only: a boolean, speed-up by computing last position only.
alpha: Float that controls the length penalty. larger the alpha, stronger
the preference for slonger translations.
Returns:
samples: an integer `Tensor`.'

def infer(self, features=None, decode_length=50, beam_size=1, top_beams=1, last_position_only=False, alpha=0.0):

    if (not self.has_input):
        beam_size = 1
        self._hparams.sampling_method = 'random'
    if _is_class_modality(self._hparams.problems[self._problem_idx].target_modality):
        beam_size = 1
    if (beam_size == 1):
        tf.logging.info('Greedy    Decoding')
        (samples, _, _) = self._greedy_infer(features, decode_length, last_position_only)
    else:
        tf.logging.info(('Beam    Decoding    with    beam    size    %d' % beam_size))
        samples = self._beam_decode(features, decode_length, beam_size, top_beams, last_position_only, alpha)
    return samples
