import math


def PSNR(L2loss, I=2):
    """
    Function that calculates the PSNR metric according to eq. 3
    L2loss: a float
    I: set to 2 since the paper assumes the HR and SR pixel values are between [-1,1]
    """
    x = I ** 2 / L2loss  # calculating the argument for the log
    psnr = 10 * math.log10(x)  # calculating the psnr as in eq. 3
    return psnr