code: def padded_neg_log_perplexity(predictions,
                                labels,
                                weights_fn=common_layers.weights_nonzero):
    
    num, den = common_layers.padded_cross_entropy(
        predictions, labels, 0.0, weights_fn=weights_fn, reduce_sum=False)
    return (-num, den)
docs: Average log-perplexity exluding padding 0s. No smoothing.