a
    þd$  ã                   @   s¬   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZmZ d dlmZ G dd„ deƒZG d	d
„ d
e	ƒZG dd„ deƒZG dd„ de
ƒZG dd„ deƒZdS )é    )ÚAnyÚCallableÚOptional)ÚLiteral)ÚPermutationInvariantTraining)Ú#ScaleInvariantSignalDistortionRatioÚSignalDistortionRatio)ÚScaleInvariantSignalNoiseRatioÚSignalNoiseRatio)Ú_deprecated_root_import_classc                       s8   e Zd ZdZd
eed ed eddœ‡ fdd	„Z‡  ZS )Ú_PermutationInvariantTrainingaÑ  Wrapper for deprecated import.

    >>> import torch
    >>> from torchmetrics.functional import scale_invariant_signal_noise_ratio
    >>> _ = torch.manual_seed(42)
    >>> preds = torch.randn(3, 2, 5) # [batch, spk, time]
    >>> target = torch.randn(3, 2, 5) # [batch, spk, time]
    >>> pit = _PermutationInvariantTraining(scale_invariant_signal_noise_ratio,
    ...     mode="speaker-wise", eval_func="max")
    >>> pit(preds, target)
    tensor(-2.1065)

    úspeaker-wiseÚmax)r   zpermutation-wise)r   ÚminN)Úmetric_funcÚmodeÚ	eval_funcÚkwargsÚreturnc                    s(   t ddƒ tƒ jf |||dœ|¤Ž d S )Nr   Úaudio)r   r   r   ©r   ÚsuperÚ__init__)Úselfr   r   r   r   ©Ú	__class__© úg/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchmetrics/audio/_deprecated.pyr      s    
z&_PermutationInvariantTraining.__init__)r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ú__classcell__r   r   r   r   r      s     üúr   c                       s,   e Zd ZdZdeeddœ‡ fdd„Z‡  ZS )Ú$_ScaleInvariantSignalDistortionRatioa  Wrapper for deprecated import.

    >>> from torch import tensor
    >>> target = tensor([3.0, -0.5, 2.0, 7.0])
    >>> preds = tensor([2.5, 0.0, 2.0, 8.0])
    >>> si_sdr = _ScaleInvariantSignalDistortionRatio()
    >>> si_sdr(preds, target)
    tensor(18.4030)

    FN©Ú	zero_meanr   r   c                    s$   t ddƒ tƒ jf d|i|¤Ž d S )Nr   r   r%   r   ©r   r%   r   r   r   r   r   1   s    
z-_ScaleInvariantSignalDistortionRatio.__init__)F©r   r   r    r!   Úboolr   r   r"   r   r   r   r   r#   %   s    þür#   c                       s(   e Zd ZdZeddœ‡ fdd„Z‡  ZS )Ú_ScaleInvariantSignalNoiseRatioa  Wrapper for deprecated import.

    >>> from torch import tensor
    >>> target = tensor([3.0, -0.5, 2.0, 7.0])
    >>> preds = tensor([2.5, 0.0, 2.0, 8.0])
    >>> si_snr = _ScaleInvariantSignalNoiseRatio()
    >>> si_snr(preds, target)
    tensor(15.0918)

    N)r   r   c                    s    t ddƒ tƒ jf i |¤Ž d S )Nr	   r   r   )r   r   r   r   r   r   F   s    
z(_ScaleInvariantSignalNoiseRatio.__init__)r   r   r    r!   r   r   r"   r   r   r   r   r)   :   s   ýr)   c                       s:   e Zd ZdZdee eeee eddœ‡ fdd„Z	‡  Z
S )	Ú_SignalDistortionRatioa`  Wrapper for deprecated import.

    >>> import torch
    >>> g = torch.manual_seed(1)
    >>> preds = torch.randn(8000)
    >>> target = torch.randn(8000)
    >>> sdr = _SignalDistortionRatio()
    >>> sdr(preds, target)
    tensor(-12.0589)
    >>> # use with pit
    >>> from torchmetrics.functional import signal_distortion_ratio
    >>> preds = torch.randn(4, 2, 8000)  # [batch, spk, time]
    >>> target = torch.randn(4, 2, 8000)
    >>> pit = _PermutationInvariantTraining(signal_distortion_ratio,
    ...     mode="speaker-wise", eval_func="max")
    >>> pit(preds, target)
    tensor(-11.6051)

    Né   F)Úuse_cg_iterÚfilter_lengthr%   Ú	load_diagr   r   c                    s*   t ddƒ tƒ jf ||||dœ|¤Ž d S )Nr   r   )r,   r-   r%   r.   r   )r   r,   r-   r%   r.   r   r   r   r   r   c   s    
ÿÿz_SignalDistortionRatio.__init__)Nr+   FN)r   r   r    r!   r   Úintr(   Úfloatr   r   r"   r   r   r   r   r*   N   s       ûùr*   c                       s,   e Zd ZdZdeeddœ‡ fdd„Z‡  ZS )Ú_SignalNoiseRatiozóWrapper for deprecated import.

    >>> from torch import tensor
    >>> target = tensor([3.0, -0.5, 2.0, 7.0])
    >>> preds = tensor([2.5, 0.0, 2.0, 8.0])
    >>> snr = _SignalNoiseRatio()
    >>> snr(preds, target)
    tensor(16.1805)

    FNr$   c                    s$   t ddƒ tƒ jf d|i|¤Ž d S )Nr
   r   r%   r   r&   r   r   r   r   }   s    
z_SignalNoiseRatio.__init__)Fr'   r   r   r   r   r1   q   s    þür1   N)Útypingr   r   r   Ztyping_extensionsr   Ztorchmetrics.audio.pitr   Ztorchmetrics.audio.sdrr   r   Ztorchmetrics.audio.snrr	   r
   Ztorchmetrics.utilities.printsr   r   r#   r)   r*   r1   r   r   r   r   Ú<module>   s   #