import torch


def loss_deepAR(mu_collection, sigma_collection, target):
    """
    Calculate the negative log-likelihood over the decoder length.[*] 
    
    [*] - Edit this code if using a non-Gaussian distribution.
    [*] - Edit this code for non-one output size

    -----------------------------------------------------------------------

    :param mu_collection: Tensor of shape [batch_size, decoder_len, 
    output_size]
    :param sigma_collection: Tensor of shape [batch_size, decoder_len,
    output_size]
    :param target: Target output tensor of shape [batch_size, decoder_len, 
        output_size]. 
    """
    distribution = torch.distributions.normal.Normal(mu_collection, sigma_collection)
    likelihood = torch.sum(distribution.log_prob(target))
    return -likelihood