code: def neg_log_perplexity(batch, model_predictions):
    
    _, targets = batch
    model_predictions, targets = _make_list(model_predictions, targets)
    xent = []
    for (prediction, target) in zip(model_predictions, targets):
      hot_target = layers.one_hot(target, prediction.shape[-1])
      xent.append(np.sum(prediction * hot_target, axis=-1))
    return masked_mean(xent, targets)
docs: Calculate negative log perplexity.