Ë
    ýÿæi%   ã                   óÈ  — d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ  G d„ de«      Z  G d„ de	«      Z! G d„ de«      Z" G d„ de«      Z# G d„ de«      Z$ G d„ de«      Z% G d„ de«      Z& G d„ de«      Z' G d „ d!e«      Z( G d"„ d#e«      Z) G d$„ d%e«      Z* G d&„ d'e«      Z+y())é    )ÚSequence)ÚAnyÚLiteralÚOptional)Ú	BLEUScore)ÚCharErrorRate)Ú	CHRFScore)ÚExtendedEditDistance)ÚMatchErrorRate)Ú
Perplexity)ÚSacreBLEUScore)ÚSQuAD)ÚTranslationEditRate)ÚWordErrorRate)ÚWordInfoLost)ÚWordInfoPreserved)Ú_deprecated_root_import_classc                   óL   ‡ — e Zd ZdZ	 	 	 d	dededeee      de	ddf
ˆ fd„Z
ˆ xZS )
Ú
_BLEUScorezâWrapper for deprecated import.

    >>> preds = ['the cat is on the mat']
    >>> target = [['there is a cat on the mat', 'a cat is on the mat']]
    >>> bleu = _BLEUScore()
    >>> bleu(preds, target)
    tensor(0.7598)

    NÚn_gramÚsmoothÚweightsÚkwargsÚreturnc                 óD   •— t        dd«       t        ‰| �  d|||dœ|¤Ž y )Nr   Útext)r   r   r   © ©r   ÚsuperÚ__init__)Úselfr   r   r   r   Ú	__class__s        €úr/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torchmetrics/text/_deprecated.pyr    z_BLEUScore.__init__   s(   ø€ ô 	& k°6Ô:Ü‰ÑÐQ ¨v¸wÑQÈ&ÓQó    )é   FN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚintÚboolr   r   Úfloatr   r    Ú__classcell__©r"   s   @r#   r   r      s]   ø„ ñð ØØ-1ñ	RàðRð ðRð ˜( 5™/Ñ*ð	Rð
 ðRð 
÷Rñ Rr$   r   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_CharErrorRatezüWrapper for deprecated import.

    >>> preds = ["this is the prediction", "there is an other sample"]
    >>> target = ["this is the reference", "there is another one"]
    >>> cer = _CharErrorRate()
    >>> cer(preds, target)
    tensor(0.3415)

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   ©r!   r   r"   s     €r#   r    z_CharErrorRate.__init__4   s   ø€ ô 	& o°vÔ>Ü‰ÑÑ"˜6Ó"r$   ©r&   r'   r(   r)   r   r    r-   r.   s   @r#   r0   r0   )   ó$   ø„ ñð#àð#ð 
÷#ñ #r$   r0   c                   óR   ‡ — e Zd ZdZ	 	 	 	 	 	 ddededededededed	d
fˆ fd„Zˆ xZ	S )Ú
_CHRFScorezâWrapper for deprecated import.

    >>> preds = ['the cat is on the mat']
    >>> target = [['there is a cat on the mat', 'a cat is on the mat']]
    >>> chrf = _CHRFScore()
    >>> chrf(preds, target)
    tensor(0.8640)

    Ún_char_orderÚn_word_orderÚbetaÚ	lowercaseÚ
whitespaceÚreturn_sentence_level_scorer   r   Nc           
      óJ   •— t        dd«       t        ‰| �  d||||||dœ|¤Ž y )Nr	   r   )r7   r8   r9   r:   r;   r<   r   r   )	r!   r7   r8   r9   r:   r;   r<   r   r"   s	           €r#   r    z_CHRFScore.__init__G   s=   ø€ ô 	& k°6Ô:Ü‰Ñð 	
Ø%Ø%ØØØ!Ø(Cñ	
ð ó	
r$   )é   é   ç       @FFF)
r&   r'   r(   r)   r*   r,   r+   r   r    r-   r.   s   @r#   r6   r6   <   st   ø„ ñð ØØØØ Ø,1ñ
àð
ð ð
ð ð	
ð
 ð
ð ð
ð &*ð
ð ð
ð 
÷
ñ 
r$   r6   c                   óX   ‡ — e Zd ZdZ	 	 	 	 	 	 dded   dededededed	ed
dfˆ fd„Zˆ xZ	S )Ú_ExtendedEditDistancea  Wrapper for deprecated import.

    >>> preds = ["this is the prediction", "here is an other sample"]
    >>> target = ["this is the reference", "here is another one"]
    >>> eed = _ExtendedEditDistance()
    >>> eed(preds=preds, target=target)
    tensor(0.3078)

    Úlanguage)ÚenÚjar<   ÚalphaÚrhoÚdeletionÚ	insertionr   r   Nc           
      óJ   •— t        dd«       t        ‰| �  d||||||dœ|¤Ž y )Nr
   r   )rC   r<   rF   rG   rH   rI   r   r   )	r!   rC   r<   rF   rG   rH   rI   r   r"   s	           €r#   r    z_ExtendedEditDistance.__init__h   s>   ø€ ô 	&Ð&<¸fÔEÜ‰Ñð 	
ØØ(CØØØØñ	
ð ó	
r$   )rD   Fr@   g333333Ó?gš™™™™™É?g      ð?)
r&   r'   r(   r)   r   r+   r,   r   r    r-   r.   s   @r#   rB   rB   ]   sy   ø„ ñð )-Ø,1ØØØØñ
à˜*Ñ%ð
ð &*ð
ð ð	
ð
 ð
ð ð
ð ð
ð ð
ð 
÷
ñ 
r$   rB   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_MatchErrorRatezýWrapper for deprecated import.

    >>> preds = ["this is the prediction", "there is an other sample"]
    >>> target = ["this is the reference", "there is another one"]
    >>> mer = _MatchErrorRate()
    >>> mer(preds, target)
    tensor(0.4444)

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   r2   s     €r#   r    z_MatchErrorRate.__init__‰   s    ø€ ô 	&Ð&6¸Ô?Ü‰ÑÑ"˜6Ó"r$   r3   r.   s   @r#   rL   rL   ~   r4   r$   rL   c                   ó:   ‡ — e Zd ZdZ	 ddee   deddfˆ fd„Zˆ xZS )Ú_Perplexitya	  Wrapper for deprecated import.

    >>> from torch import rand, randint
    >>> preds = rand(2, 8, 5)
    >>> target = randint(5, (2, 8))
    >>> target[0, 6:] = -100
    >>> perp = _Perplexity(ignore_index=-100)
    >>> perp(preds, target)
    tensor(5.8540)

    NÚignore_indexr   r   c                 ó@   •— t        dd«       t        ‰| �  dd|i|¤Ž y )Nr   r   rP   r   r   )r!   rP   r   r"   s      €r#   r    z_Perplexity.__init__ž   s$   ø€ ô
 	& l°FÔ;Ü‰ÑÑ= lÐ=°fÓ=r$   )N)	r&   r'   r(   r)   r   r*   r   r    r-   r.   s   @r#   rO   rO   ‘   s7   ø„ ñ
ð '+ñ>à˜s‘mð>ð ð>ð 
÷	>ñ >r$   rO   c                   ó^   ‡ — e Zd ZdZ	 	 	 	 	 ddededed   dedeee	      d	e
d
dfˆ fd„Zˆ xZS )Ú_SacreBLEUScorezóWrapper for deprecated import.

    >>> preds = ['the cat is on the mat']
    >>> target = [['there is a cat on the mat', 'a cat is on the mat']]
    >>> sacre_bleu = _SacreBLEUScore()
    >>> sacre_bleu(preds, target)
    tensor(0.7598)

    Nr   r   Útokenize)ÚnoneÚ13aÚzhÚintlÚcharr:   r   r   r   c           	      óH   •— t        dd«       t        ‰| �  d|||||dœ|¤Ž y )Nr   r   )r   r   rT   r:   r   r   r   )r!   r   r   rT   r:   r   r   r"   s          €r#   r    z_SacreBLEUScore.__init__²   s6   ø€ ô 	&Ð&6¸Ô?Ü‰Ñð 	
Ø &°8ÀyÐZañ	
Øekó	
r$   )r%   FrV   FN)r&   r'   r(   r)   r*   r+   r   r   r   r,   r   r    r-   r.   s   @r#   rS   rS   §   sv   ø„ ñð ØØAFØØ-1ñ
àð
ð ð
ð Ð=Ñ>ð	
ð
 ð
ð ˜( 5™/Ñ*ð
ð ð
ð 
÷
ñ 
r$   rS   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_SQuADaL  Wrapper for deprecated import.

    >>> preds = [{"prediction_text": "1976", "id": "56e10a3be3433e1400422b22"}]
    >>> target = [{"answers": {"answer_start": [97], "text": ["1976"]}, "id": "56e10a3be3433e1400422b22"}]
    >>> squad = _SQuAD()
    >>> squad(preds, target)
    {'exact_match': tensor(100.), 'f1': tensor(100.)}

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   r2   s     €r#   r    z_SQuAD.__init__Ì   s   ø€ Ü% g¨vÔ6Ü‰ÑÑ"˜6Ó"r$   r3   r.   s   @r#   r\   r\   Á   ó    ø„ ñð# ð #¨÷ #ñ #r$   r\   c                   óL   ‡ — e Zd ZdZ	 	 	 	 	 ddededededededd	fˆ fd
„Zˆ xZS )Ú_TranslationEditRatezêWrapper for deprecated import.

    >>> preds = ['the cat is on the mat']
    >>> target = [['there is a cat on the mat', 'a cat is on the mat']]
    >>> ter = _TranslationEditRate()
    >>> ter(preds, target)
    tensor(0.1538)

    Ú	normalizeÚno_punctuationr:   Úasian_supportr<   r   r   Nc           	      óH   •— t        dd«       t        ‰| �  d|||||dœ|¤Ž y )Nr   r   )ra   rb   r:   rc   r<   r   r   )r!   ra   rb   r:   rc   r<   r   r"   s          €r#   r    z_TranslationEditRate.__init__Ü   s;   ø€ ô 	&Ð&;¸VÔDÜ‰Ñð 	
ØØ)ØØ'Ø(Cñ	
ð ó	
r$   )FFTFF)r&   r'   r(   r)   r+   r   r    r-   r.   s   @r#   r`   r`   Ñ   sg   ø„ ñð  Ø$ØØ#Ø,1ñ
àð
ð ð
ð ð	
ð
 ð
ð &*ð
ð ð
ð 
÷
ñ 
r$   r`   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_WordErrorRatezüWrapper for deprecated import.

    >>> preds = ["this is the prediction", "there is an other sample"]
    >>> target = ["this is the reference", "there is another one"]
    >>> wer = _WordErrorRate()
    >>> wer(preds, target)
    tensor(0.5000)

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   r2   s     €r#   r    z_WordErrorRate.__init__û   s   ø€ Ü% o°vÔ>Ü‰ÑÑ"˜6Ó"r$   r3   r.   s   @r#   rf   rf   ð   r^   r$   rf   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_WordInfoLostzûWrapper for deprecated import.

    >>> preds = ["this is the prediction", "there is an other sample"]
    >>> target = ["this is the reference", "there is another one"]
    >>> wil = _WordInfoLost()
    >>> wil(preds, target)
    tensor(0.6528)

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   r2   s     €r#   r    z_WordInfoLost.__init__  s   ø€ Ü% n°fÔ=Ü‰ÑÑ"˜6Ó"r$   r3   r.   s   @r#   ri   ri      r^   r$   ri   c                   ó,   ‡ — e Zd ZdZdeddfˆ fd„Zˆ xZS )Ú_WordInfoPreservedzÿWrapper for deprecated import.

    >>> preds = ["this is the prediction", "there is an other sample"]
    >>> target = ["this is the reference", "there is another one"]
    >>> wip = WordInfoPreserved()
    >>> wip(preds, target)
    tensor(0.3472)

    r   r   Nc                 ó<   •— t        dd«       t        ‰| �  di |¤Ž y )Nr   r   r   r   r2   s     €r#   r    z_WordInfoPreserved.__init__  s   ø€ Ü%Ð&9¸6ÔBÜ‰ÑÑ"˜6Ó"r$   r3   r.   s   @r#   rl   rl     r^   r$   rl   N),Úcollections.abcr   Útypingr   r   r   Útorchmetrics.text.bleur   Útorchmetrics.text.cerr   Útorchmetrics.text.chrfr	   Útorchmetrics.text.eedr
   Útorchmetrics.text.merr   Útorchmetrics.text.perplexityr   Útorchmetrics.text.sacre_bleur   Útorchmetrics.text.squadr   Útorchmetrics.text.terr   Útorchmetrics.text.werr   Útorchmetrics.text.wilr   Útorchmetrics.text.wipr   Útorchmetrics.utilities.printsr   r   r0   r6   rB   rL   rO   rS   r\   r`   rf   ri   rl   r   r$   r#   Ú<module>r}      sÌ   ðÝ $ß )Ñ )å ,Ý /Ý ,Ý 6Ý 0Ý 3Ý 7Ý )Ý 5Ý /Ý .Ý 3Ý GôR�ô Rô,#�]ô #ô&
�ô 
ôB
Ð0ô 
ôB#�nô #ô&>�*ô >ô,
�nô 
ô4#ˆUô #ô 
Ð.ô 
ô>#�]ô #ô #�Lô #ô #Ð*õ #r$   