import torch


def cross_entropy_loss(outputs, labels):
    """Calculates cross entropy loss given outputs and actual labels
        Arguments:
        outputs (torch.Tensor) - predicted probabilities of the model. Size (Batch_size,N_out)
        labels (torch.Tensor) - truth labels for the current batch. Size (Batch_size)
        Returns:
        creloss (float) - cross entropy loss of the model predictions and actual labels
    """   
    m = outputs.size()[0]
    creloss = torch.mean(-torch.log(outputs[range(m), labels]))
    return creloss.item()