import math


def init_penalty(maxlen, smoothing):
    """Initializes the penalty used in cross-entropy computation

    maxlen: maximum allowed length of a sentence
    smoothing: smoothing factor to avoid dividing by 0 (default 0.01)

    returns: the penalty list
    """
    penalty = []
    for i in range(maxlen):
        penalty.append(math.log((i + 2 * smoothing) / smoothing))
    return penalty