import torch


def snr(audio, perturbation, rel_length=torch.tensor([1.0])):
    """
    Signal to Noise Ratio computation

    Arguments
    ---------
    audio : torch.tensor
        the original padded audio
    perturbation : torch.tensor
        the padded perturbation
    rel_length : torch.tensor
        the relative length of the wavs in the batch
    """
    num = torch.max(audio, dim=1)
    den = torch.max(perturbation, dim=1)
    ratio = num[0]/den[0]
    
    snr = 20. * torch.log10(ratio)
    return torch.round(snr).long()