import torch


def psnr(prediction: torch.Tensor, label: torch.Tensor) -> torch.Tensor:
    """
    Function computes the Peak Signal to Noise Ratio
    PSNR = 10 * log10(max[y]**2 / MSE(y, y'))
    Source: https://github.com/ChristophReich1996/CellFlowNet
    :param prediction: (torch.Tensor) Prediction
    :param label: (torch.Tensor) Label
    :return: (torch.Tensor) PSNR value
    """
    assert prediction.numel() == label.numel(), 'Prediction tensor and label tensor must have the number of elements'
    return 10.0 * torch.log10(prediction.max() ** 2 / (torch.mean((prediction - label) ** 2) + 1e-08))