def batch_mel_spectral_distortion(
        y1, y2, sr, normalize_type="path", mel_fn=None
):
    """
    https://arxiv.org/pdf/2011.03568.pdf

    Same as Mel Cepstral Distortion, but computed on log-mel spectrograms.
    """
    if mel_fn is None or mel_fn.sample_rate != sr:
        mel_fn = torchaudio.transforms.MelSpectrogram(
            sr, n_fft=int(0.05 * sr), win_length=int(0.05 * sr),
            hop_length=int(0.0125 * sr), f_min=20, n_mels=80,
            window_fn=torch.hann_window
        ).to(y1[0].device)
    offset = 1e-6
    return batch_compute_distortion(
        y1, y2, sr, lambda y: torch.log(mel_fn(y) + offset).transpose(-1, -2),
        compute_rms_dist, normalize_type
    )
https://arxiv.org/pdf/2011.03568.pdf

Same as Mel Cepstral Distortion, but computed on log-mel spectrograms.
examples/speech_synthesis/utils.py