import tensorflow as tf

        return res + bias_term

def _clip_and_normalize(word_probs, epsilon):
    '''
    word_probs: 1D tensor of [vsize]
    '''
    word_probs = tf.clip_by_value(word_probs, epsilon, 1.0 - epsilon)
    return word_probs / tf.reduce_sum(word_probs, axis=-1, keep_dims=True) # scale preds so that the class probas of each sample sum to 1


def CE_loss(word_probs, answers, loss_weights):
    '''
    word_probs: [batch_size, max_dec_steps, vocab]
    answers: [batch_size, max_dec_steps]
