def denormalize(tensor):
    """ Reverses the normalisation on a tensor.

    Performs a reverse operation on a tensor, so the pixel value range is
    between 0 and 1. Useful for when plotting a tensor into an image.
    Normalisation: (image - mean) / std
    Denormalisation: image * std + mean

    Parameters
    ----------
    tensor: torch.Tensor (N, C, H, W)
        normalized image tensor.

    Returns
    -------
    torch.Tensor (N, C, H, W)
        demornalised image tensor with pixel values between [0, 1].

    Notes
    -----
    Symbols used to describe dimensions:

    * N: number of images in a batch.
    * C: number of channels.
    * H: height of the image.
    * W: width of the image.
    """
    means = [0.485, 0.456, 0.406]
    stds = [0.229, 0.224, 0.225]
    denormalized = tensor.clone()
    for cnt in range(len(denormalized[0])):
        denormalized[0, cnt] = denormalized[0, cnt] * stds[cnt] + means[cnt]

    return denormalized