import torch


def loss_fn(outputs, labels):
    """Computes the cross entropy loss given outputs and labels.
        
    Args:
        outputs: Output of the model (dimension batch_size x 10 (10 classes))
        labels: Correspondent true labels (dimension batch_size, where each 
                element is a value between 0-9)
    
    Returns:
        loss: cross entropy loss for all images in the batch
    
    Note: 
        The standard loss function from pyTorch nn.CrossEntropyLoss() can also be
        used and should turn the same result. 
        This function is an example on how you to easily define a custom loss function. 
    """
    num_examples = outputs.size()[0]
    return -torch.sum(outputs[range(num_examples), labels])/num_examples