§
    ‚ŠtjÔª ã                   ó`  — d dl Z d dlZd dlZd dlmZmZ d dlZd dlZd dl	m
c 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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m Z   ej!        e"¦  «        Z#dej$        de%dej$        fd„Z&dej'        fd„Z(d„ Z)	 	 	 	 	 	 	 	 dd„Z* G d„ de¦  «        Z+dS )é    N)ÚCallableÚIterator)Únn)ÚEncoderDecoderCacheé   )ÚGenerationConfigÚGenerationMixin)ÚLogitsProcessorListÚ$SuppressTokensAtBeginLogitsProcessorÚSuppressTokensLogitsProcessorÚWhisperNoSpeechDetectionÚWhisperTimeStampLogitsProcessor)ÚStoppingCriteriaList)ÚBaseModelOutput)Úloggingé   )ÚTASK_IDSÚTO_LANGUAGE_CODEÚinputsÚfilter_widthÚreturnc                 ó,  — |dk    s	|dz  dk    rt          d¦  «        ‚|dz  }| j        d         |k    r| S t          j                             | ||ddfd¬¦  «        } |                      d|d¦  «                             ¦   «         d         d|f         }|S )	zŸ
    Applies a median filter of width `filter_width` along the last dimension of the input.

    The `inputs` tensor is assumed to be 3- or 4-dimensional.
    r   é   r   z&`filter_width` should be an odd numberéÿÿÿÿÚreflect)Úmode.)Ú
ValueErrorÚshaper   Ú
functionalÚpadÚunfoldÚsort)r   r   Ú	pad_widthÚresults       úl/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/whisper/generation_whisper.pyÚ_median_filterr&   +   s«   € ð �qÒÐ˜L¨1Ñ,°Ò1Ð1ÝÐAÑBÔBÐBà Ñ!€IØ„|�BÔ˜9Ò$Ð$Øˆõ Œ]×Ò˜v¨	°9¸aÀÐ'CÈ)ÐÑTÔT€Fð �]Š]˜2˜|¨QÑ/Ô/×4Ò4Ñ6Ô6°qÔ9¸#¸y¸.ÔI€FØ€Mó    Úmatrixc                 ó8  — | j         \  }}t          j        |dz   |dz   ft          j        ¬¦  «        t          j        z  }t          j        |dz   |dz   ft          j        ¬¦  «         }d|d<   t          d|dz   ¦  «        D ]‡}t          d|dz   ¦  «        D ]q}||dz
  |dz
  f         }||dz
  |f         }|||dz
  f         }	||k     r||	k     r|d}}
n||k     r||	k     r|d}}
n|	d}}
| |dz
  |dz
  f         |
z   |||f<   ||||f<   ŒrŒˆ|j         d         dz
  }|j         d         dz
  }d|ddd…f<   d|dd…df<   g }g }|dk    s|dk    r“|                     |dz
  ¦  «         |                     |dz
  ¦  «         |||f         dk    r|dz  }|dz  }n>|||f         dk    r|dz  }n*|||f         dk    r|dz  }nt          d|› d|› d	�¦  «        ‚|dk    °�|dk    °“t          j        |¦  «        ddd
…         }t          j        |¦  «        ddd
…         }||fS )z‘
    Measures similarity between two temporal sequences: the input audio and the output tokens. Used to generate
    token-level timestamps.
    r   ©Údtyper   )r   r   r   Nz9Internal error in dynamic time warping. Unexpected trace[ú, z]. Please file a bug report.r   )	r   ÚnpÚonesÚfloat32ÚinfÚrangeÚappendÚRuntimeErrorÚarray)r(   Úoutput_lengthÚinput_lengthÚcostÚtraceÚjÚiÚc0Úc1Úc2ÚcÚtÚtext_indicesÚtime_indicess                 r%   Ú_dynamic_time_warpingrB   @   sÈ  € ð
 #)¤,Ñ€M�<ÝŒ7�M AÑ% |°aÑ'7Ð8ÅÄ
ÐKÑKÔKÍbÌfÑT€DÝŒW�m aÑ'¨¸Ñ)9Ð:Å"Ä*ÐMÑMÔMÐM€Eà€Dˆ�JÝ�1�l QÑ&Ñ'Ô'ð ð ˆÝ�q˜-¨!Ñ+Ñ,Ô,ð 	ð 	ˆAØ�a˜!‘e˜Q ™U�lÔ#ˆBØ�a˜!‘e˜Q�h”ˆBØ�a˜˜Q™�h”ˆBà�BŠwˆw˜2 š7˜7Ø˜1�1��Ø�b’�˜R "šW˜WØ˜1�1��à˜1�1�à  A¡ q¨1¡u Ô-°Ñ1ˆD��A�‰JØˆE�!�Q�$‰KˆKð	ð  	Œ�AŒ˜Ñ€AØŒ�AŒ˜Ñ€AØ€Eˆ!ˆQˆQˆQˆ$�KØ€Eˆ!ˆ!ˆ!ˆQˆ$�Kà€LØ€LØ
ˆaŠ%ˆ%�1�q’5�5Ø×Ò˜A ™EÑ"Ô"Ð"Ø×Ò˜A ™EÑ"Ô"Ð"Ø��A�Œ;˜!ÒÐØ�‰FˆAØ�‰FˆAˆAØ�1�a�4Œ[˜AÒÐØ�‰FˆAˆAØ�1�a�4Œ[˜AÒÐØ�‰FˆAˆAåØpÈAÐpÐpÐQRÐpÐpÐpñô ð ð ˆaŠ%ˆ%�1�q’5�5õ ”8˜LÑ)Ô)¨$¨$¨B¨$Ô/€LÝ”8˜LÑ)Ô)¨$¨$¨B¨$Ô/€LØ˜Ð%Ð%r'   c                 ój   ‡— | �/t          ˆfd„| D ¦   «         d ¦  «        }|rt          ||d ¦  «        S d S )Nc              3   ó<   •K  — | ]}t          |‰¦  «        ¯|V — Œd S ©N)Ú
isinstance)Ú.0ÚclsÚlogit_processor_classs     €r%   ú	<genexpr>z2_get_attr_from_logit_processors.<locals>.<genexpr>x   s3   øè è € ÐjÐj¨Å:ÈcÐShÑCiÔCiÐj ÐjÐjÐjÐjÐjÐjr'   )ÚnextÚgetattr)Úlogits_processorrI   Úattribute_nameÚlogit_processors    `  r%   Ú_get_attr_from_logit_processorsrP   v   sO   ø€ ØÐ#ÝÐjÐjÐjÐjÐ/?ÐjÑjÔjÐlpÑqÔqˆØð 	BÝ˜?¨N¸DÑAÔAÐAØˆ4r'   ÚrightÚlongestFc           	      óô  — d}g }g }|dvrt          d|› �¦  «        ‚|dvrt          d|› �¦  «        ‚|dk    r|€t          d¦  «        ‚|rŸg }g }| D ]d}|d         d	         }|                     t          |t          j        ¦  «        r|n|d
         ¦  «         |r|                     |d         ¦  «         Œet          j        |d¬¦  «        }|rt          j        |d¬¦  «        }||fS |S | D �]}|��{t          d„ |D ¦   «         ¦  «        dk    �r]g }|D ]n}|	rOt          |d         ¦  «        dk    r6|d         d         |
k    r$|                     |d         dd…         ¦  «         ŒS|                     |d         ¦  «         Œot          j        |d¬¦  «        }|r t          j        d„ |D ¦   «         d¬¦  «        }|�|| d…         }|r|| d…         }|�Et          j        ||g¦  «        }|r-t          j        t          j        ||¬¦  «        dz  |g¦  «        }|                     |¦  «         |r|                     |¦  «         t          |t          |d         ¦  «        ¦  «        }�Œ�|�E|                     |¦  «         |r,|                     t          j        ||¬¦  «        dz  ¦  «         �ŒÈ|                     t          j
        g |¬¦  «        ¦  «         |r)|                     t          j
        g |¬¦  «        ¦  «         �Œ|dk    r|dz   n|}t          t          | ¦  «        ¦  «        D ]‘}|t          ||         ¦  «        z
  }|dk    rd|fn|df}t          j        ||         ||¬¦  «        ||<   |rGt          j        ||         |t          ||         ¦  «        dk    r||         d         nd¬¦  «        ||<   Œ’t          j        |d¬¦  «        }|rt          j        |d¬¦  «        }||fS |S )a¡  
    skip_ending_double_timestamps: when the segment ended with two timestamp tokens, whether to ignore the last timestamp token
    see https://github.com/huggingface/transformers/pull/35750

    _pad_to_max_length is used in different contexts:
    1. At the end of generation: we need to keep both ending timestamp tokens in the segment (see https://github.com/huggingface/transformers/pull/34537).
    2. In the middle of generation, e.g. when condition_on_prev_tokens=True and we want to use the last generated tokens as decoder_input_ids:
       we must skip one of the double ending timestamp tokens (see https://github.com/huggingface/transformers/pull/35750).
    r   )rQ   Úleftz5`padding_side` must be either 'right' or 'left', not )rR   Ú
max_lengthz8`padding` must be either 'longest' or 'max_length', not rU   Nz>`cut_off_length` must be specified when `padding='max_length'`r$   Ú	sequencesÚtoken_timestamps©Údimc                 ó   — g | ]
}|d          ‘ŒS ©Útokens© ©rG   Úds     r%   ú
<listcomp>z&_pad_to_max_length.<locals>.<listcomp>°   s   € Ð4_Ð4_Ð4_ÀQ°Q°x´[Ð4_Ð4_Ð4_r'   r\   r   éþÿÿÿr   c                 ój   — g | ]0}|d          d         |d         d         |d         d         …         ‘Œ1S )r$   rW   Úidxsr   r   r]   r^   s     r%   r`   z&_pad_to_max_length.<locals>.<listcomp>¾   s=   € ÐpÐpÐpÐVW�Q�x”[Ð!3Ô4°Q°v´Y¸q´\ÀAÀfÄIÈaÄLÐ5PÔQÐpÐpÐpr'   ©Údeviceç        r   rQ   )r    Úvalue)r   r2   rF   ÚtorchÚTensorÚstackÚlenÚcatÚ	ones_likeÚmaxÚtensorr1   ÚFr    )Úcurrent_segmentsÚpad_token_idre   Úpadding_sideÚpaddingÚbos_token_tensorÚcut_off_lengthÚreturn_token_timestampsÚforce_unique_generate_callÚskip_ending_double_timestampsÚtimestamp_beginÚmax_total_lengthrV   Útoken_timestamps_listÚsequences_listÚtimestamps_listÚsegmentsr$   rW   Úcurrent_segment_listr_   Úsequencer:   Ú
pad_lengthr    s                            r%   Ú_pad_to_max_lengthrƒ   ~   sù  € ð, ÐØ€IØÐàÐ,Ð,Ð,ÝÐ_ÐQ]Ð_Ð_Ñ`Ô`Ð`àÐ/Ð/Ð/ÝÐ]ÐT[Ð]Ð]Ñ^Ô^Ð^Ø	�LÒ	 Ð	  ^Ð%;ÝÐYÑZÔZÐZà!ð ØˆØˆØ(ð 	Cð 	CˆHØ˜a”[ Ô*ˆFØ×!Ò!­J°v½u¼|Ñ,LÔ,LÐ"e & &ÐRXÐYdÔReÑfÔfÐfØ&ð CØ×&Ò& vÐ.@Ô'AÑBÔBÐBøå”K °AÐ6Ñ6Ô6ˆ	Ø"ð 	/Ý$œ{¨?ÀÐBÑBÔBÐØÐ.Ð.Ð.ØÐà 0ð )Nñ )NÐØÑ+µÐ4_Ð4_ÐJ^Ð4_Ñ4_Ô4_Ñ0`Ô0`ÐcdÒ0dÑ0dØˆNØ)ð 7ð 7�Ø0ð 7µS¸¸8¼Ñ5EÔ5EÈÒ5IÐ5IÈaÐPXÌkÐZ\ÌoÐapÒNpÐNpð #×)Ò)¨!¨H¬+°c°r°cÔ*:Ñ;Ô;Ð;Ð;à"×)Ò)¨!¨H¬+Ñ6Ô6Ð6Ð6Ý”y °RÐ8Ñ8Ô8ˆHà&ð Ý#(¤9ØpÐpÐ[oÐpÑpÔpØð$ñ $ô $Ð ð
 Ð)Ø# ^ OÐ$4Ð$4Ô5�Ø*ð JØ'7¸¸Ð8HÐ8HÔ'IÐ$àÐ+Ý œ9Ð&6¸Ð%AÑBÔB�Ø*ð Ý',¤yÝœÐ)9À&ÐIÑIÔIÈCÑOÐQaÐbñ(ô (Ð$ð ×Ò˜XÑ&Ô&Ð&Ø&ð ?Ø%×,Ò,Ð-=Ñ>Ô>Ð>Ý"Ð#3µS¸À2¼Ñ5GÔ5GÑHÔHÐÑØÐ)Ø×ÒÐ-Ñ.Ô.Ð.Ø&ð eØ%×,Ò,­U¬_Ð=MÐV\Ð-]Ñ-]Ô-]Ð`cÑ-cÑdÔdÐdùà×Ò�Uœ\¨"°VÐ<Ñ<Ô<Ñ=Ô=Ð=Ø&ð NØ%×,Ò,­U¬\¸"ÀVÐ-LÑ-LÔ-LÑMÔMÐMùà-4¸Ò-DÐ-D�~¨Ñ)Ð)ÐJZÐÝ•3Ð'Ñ(Ô(Ñ)Ô)ð 
ð 
ˆØ%­¨I°a¬LÑ(9Ô(9Ñ9ˆ
Ø!-°Ò!8Ð!8ˆq�*ˆoˆo¸zÈ1¸oˆå”u˜Y qœ\¨s¸,ÐGÑGÔGˆ	�!‰Ø"ð 	Ý'(¤uØ% aÔ(ØÝ69Ð:OÐPQÔ:RÑ6SÔ6SÐVWÒ6WÐ6WÐ+¨AÔ.¨rÔ2Ð2Ð]`ð(ñ (ô (Ð! !Ñ$øõ ”˜I¨1Ð-Ñ-Ô-€Iàð Ý œ;Ð'<À!ÐDÑDÔDÐØÐ*Ð*Ð*àÐr'   c            7       óö  ‡ — e Zd Z	 dAd„Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBdej        dz  dedz  dedz  d	edz  d
e	e
ej        gee
         f         dz  dededz  dedz  deee         z  dz  dedz  dej        dz  dedz  dedz  deeedf         z  dz  dedz  dedz  dedz  de
dz  dej        dz  dedededz  dededz  dedz  d e	ej        gdf         dz  f4d!„Zˆ fd"„Zed#„ ¦   «         Zd$„ Zd%„ Zd&„ Zd'„ Zed(„ ¦   «         Zed)„ ¦   «         Zed*„ ¦   «         Zed+„ ¦   «         Zd,„ Zed-„ ¦   «         Zd.„ Z	 	 	 	 dCdej        dz  d0ej        e z  dz  dedz  de
d1ej        f
d2„Z!ed3„ ¦   «         Z"ed4„ ¦   «         Z#ed5„ ¦   «         Z$ed6„ ¦   «         Z%ed7„ ¦   «         Z&ed8„ ¦   «         Z'd9„ Z(ed:„ ¦   «         Z)ed;„ ¦   «         Z*ed<„ ¦   «         Z+d=„ Z,ed>„ ¦   «         Z-ed?„ ¦   «         Z.ed@„ ¦   «         Z/ˆ xZ0S )DÚWhisperGenerationMixinç{®Gáz”?Nc           	      óT  ‡‡‡‡— g Št          | j        j        ¦  «        D ]<Š‰                     t	          j        ˆfd„|j        D ¦   «         d¬¦  «        ¦  «         Œ=t	          j        ˆfd„|D ¦   «         ¦  «        Š‰                     g d¢¦  «        Šd}d|v �r|j	        dk     
                    d¦  «                             ¦   «         }|j	        dd…d|…f         }|�k|d	k    re||d	z
  z  }t	          j        |j        d
         |d	z
  |j        t          j        ¬¦  «        |dd…d
d	…f         z  }t	          j        ||gd¬¦  «        Šn|Š‰                     ‰dk    d
¦  «        Št	          j        ˆˆfd„t          ‰j        d	         ¦  «        D ¦   «         d¬¦  «        Š|p‰d
         j        d         }	|j        j        d
         }
t	          j        |
|	d	z   ft          j        |j        j        ¬¦  «        }|��Kt)          |t*          ¦  «        r‰dd|dz  …f         Š�n%t)          |t,          t.          t0          j        f¦  «        r;t5          t1          j        |¦  «        ¦  «        d	k    r‰dd|d
         dz  …f         ŠnÃt)          |t          j        ¦  «        r;t5          t	          j        |¦  «        ¦  «        d	k    r‰dd|d
         dz  …f         Šnnt)          |t*          ¦  «        r|
n|
t5          |¦  «        z  }t)          |t          j        ¦  «        r|                     ¦   «         n|}t1          j        ||¦  «        }|�‰dd…dd…|d…dd…f         Š‰j        d         d
k    r|S |�t)          |t*          ¦  «        rgt	          j        ‰ddd¬¦  «        }t	          j         ‰dd¬¦  «        }‰|z
  |z  ŠtC          ‰| j        j"        ¦  «        Š‰                      d	¬¦  «        Št          |
¦  «        D �]©}|�°t)          |t.          t,          t0          j        t          j        f¦  «        r~‰|dd||         dz  …f         }t	          j        |ddd¬¦  «        }t	          j         |dd¬¦  «        }||z
  |z  }tC          || j        j"        ¦  «        }|                      d
¬¦  «        }n‰|         }tG          |                     ¦   «          $                    ¦   «          %                    ¦   «          ¦  «        \  }}t1          j&        t1          j'        |¦  «        dd	¬¦  «         (                    tR          ¦  «        }||         |z  }t	          j        t	          j        |¦  «        t	          j*        |¦  «        t	          j*        |d         g¦  «        g¦  «        ||<   �Œ«|S )a“  
        Calculates token-level timestamps using the encoder-decoder cross-attentions and dynamic time-warping (DTW) to
        map each output token to a position in the input audio. If `num_frames` is specified, the encoder-decoder
        cross-attentions will be cropped before applying DTW.

        Returns:
            tensor containing the timestamps in seconds for each predicted token
        c                 ó    •— g | ]
}|‰         ‘ŒS r]   r]   )rG   Úxr:   s     €r%   r`   zDWhisperGenerationMixin._extract_token_timestamps.<locals>.<listcomp>   s   ø€ Ð._Ð._Ð._¸¨q°¬tÐ._Ð._Ð._r'   r   rX   c                 ó:   •— g | ]\  }}‰|         d d …|f         ‘ŒS rE   r]   )rG   ÚlÚhÚcross_attentionss      €r%   r`   zDWhisperGenerationMixin._extract_token_timestamps.<locals>.<listcomp>  s0   ø€ ÐUÐUÐU¹T¸QÀÐ/°Ô2°1°1°1°a°4Ô8ÐUÐUÐUr'   )r   r   r   r   NÚbeam_indicesr   r   r   ©re   r+   c           
      ór   •— g | ]3}t          j        ‰d d …d d …|d d …f         d‰d d …|f         ¬¦  «        ‘Œ4S )Nr   )rY   Úindex)rh   Úindex_select)rG   r:   Úunrolled_beam_indicesÚweightss     €€r%   r`   zDWhisperGenerationMixin._extract_token_timestamps.<locals>.<listcomp>(  sg   ø€ ð ð ð àõ Ô& w¨q¨q¨q°!°!°!°Q¸¸¸¨zÔ':ÀÐI^Ð_`Ð_`Ð_`ÐbcÐ_cÔIdÐeÑeÔeðð ð r'   ©r+   re   .ra   TF)rY   ÚkeepdimÚunbiased)rY   r–   )r   r   )Úconstant_values)+r1   ÚconfigÚdecoder_layersr2   rh   rl   r�   rj   ÚpermuterŽ   Úsumrn   r.   r   re   ÚlongÚmasked_fillrV   Úzerosr/   rF   ÚintÚlistÚtupler-   Úndarrayrk   Úuniqueri   ÚcpuÚrepeatÚstdÚmeanr&   Úmedian_filter_widthrB   ÚdoubleÚnumpyr    ÚdiffÚastypeÚboolro   )ÚselfÚgenerate_outputsÚalignment_headsÚtime_precisionÚ
num_framesÚnum_input_idsÚweight_lengthrŽ   Ú beam_indices_first_step_unrolledr6   Ú
batch_sizeÚ
timestampsÚrepeat_timer§   r¨   Ú	batch_idxr(   r@   rA   ÚjumpsÚ
jump_timesr�   r:   r“   r”   s                        @@@@r%   Ú_extract_token_timestampsz0WhisperGenerationMixin._extract_token_timestampsñ   sü  øøøø€ ð ÐÝ�t”{Ô1Ñ2Ô2ð 	ið 	iˆAØ×#Ò#¥E¤IÐ._Ð._Ð._Ð._Ð=MÔ=^Ð._Ñ._Ô._ÐefÐ$gÑ$gÔ$gÑhÔhÐhÐhõ ”+ÐUÐUÐUÐUÀ_ÐUÑUÔUÑVÔVˆØ—/’/ , , ,Ñ/Ô/ˆàˆàÐ-Ð-Ñ-ð .Ô:¸bÒ@×EÒEÀbÑIÔI×MÒMÑOÔOˆMØ+Ô8¸¸¸¸N¸]¸NÐ9JÔKˆLð
 Ð(¨]¸QÒ->Ð->à °Ñ!2Ñ2�å”J˜|Ô1°!Ô4°mÀaÑ6GÐP\ÔPcÕkpÔkuÐvÑvÔvØ# A A A q¨ s FÔ+ñ-ð 1õ ).¬	Ð3SÐUaÐ2bÐhjÐ(kÑ(kÔ(kÐ%Ð%à(4Ð%ð %:×$EÒ$EÐF[Ð_aÒFaÐcdÑ$eÔ$eÐ!õ ”kðð ð ð ð å"Ð#8Ô#>¸qÔ#AÑBÔBðñ ô ð ðñ ô ˆGð %ÐDÐ(8¸Ô(;Ô(AÀ!Ô(DˆØ%Ô/Ô5°aÔ8ˆ
Ý”[Ø˜¨Ñ)Ð*µ%´-ÐHXÔHbÔHið
ñ 
ô 
ˆ
ð Ñ!õ ˜*¥cÑ*Ô*ð @Ø! #Ð'8¨°q©Ð'8Ð"8Ô9�‘å˜J­­uµb´jÐ(AÑBÔBð 
@ÅsÍ2Ì9ÐU_ÑK`ÔK`ÑGaÔGaÐefÒGfÐGfØ! #Ð';¨°A¬¸!Ñ);Ð';Ð";Ô<��å˜J­¬Ñ7Ô7ð @½CÅÄÈZÑ@XÔ@XÑ<YÔ<YÐ]^Ò<^Ð<^Ø! #Ð';¨°A¬¸!Ñ);Ð';Ð";Ô<��õ -7°zÅ3Ñ,GÔ,GÐj˜j˜jÈZÕ[^Ð_iÑ[jÔ[jÑMj�Ý1;¸JÍÌÑ1WÔ1WÐg˜ZŸ^š^Ñ-Ô-Ð-Ð]g�
ÝœY z°;Ñ?Ô?�
ð Ð$Ø˜a˜a˜a    M N N°A°A°AÐ5Ô6ˆGð Œ=˜Ô˜qÒ Ð ØÐàÐ¥¨J½Ñ!<Ô!<Ðå”)˜G¨°TÀEÐJÑJÔJˆCÝ”:˜g¨2°tÐ<Ñ<Ô<ˆDØ ‘~¨Ñ,ˆGÝ$ W¨d¬kÔ.MÑNÔNˆGð —l’l q�lÑ)Ô)ˆGõ ˜zÑ*Ô*ð 	ñ 	ˆIØÐ%­*°ZÅ%ÍÍrÌzÕ[`Ô[gÐAhÑ*iÔ*iÐ%Ø  ¨CÐ1M°:¸iÔ3HÈAÑ3MÐ1MÐ!MÔN�õ ”i ¨B¸ÀuÐMÑMÔM�Ý”z &¨b¸$Ð?Ñ?Ô?�Ø  4™-¨3Ñ.�Ý'¨°´Ô0OÑPÔP�ð  Ÿš¨˜Ñ+Ô+��à  Ô+�å)>ÀÇ
Â
ÁÄ×@SÒ@SÑ@UÔ@U×@[Ò@[Ñ@]Ô@]Ð?]Ñ)^Ô)^Ñ&ˆL˜,Ý”F�2œ7 <Ñ0Ô0°&È!ÐLÑLÔL×SÒSÕTXÑYÔYˆEØ% eÔ,¨~Ñ=ˆJõ %*¤IÝ”˜]Ñ+Ô+­U¬\¸*Ñ-EÔ-EÅuÄ|ÐU_Ð`bÔUcÐTdÑGeÔGeÐfñ%ô %ˆJ�yÑ!Ñ!ð Ðr'   Fç{®Gáz„?Úinput_featuresÚgeneration_configrM   Ústopping_criteriaÚprefix_allowed_tokens_fnÚsynced_gpusÚreturn_timestampsÚtaskÚlanguageÚis_multilingualÚ
prompt_idsÚprompt_condition_typeÚcondition_on_prev_tokensÚtemperature.Úcompression_ratio_thresholdÚlogprob_thresholdÚno_speech_thresholdÚnum_segment_framesÚattention_maskr²   Útime_precision_featuresrw   Úreturn_segmentsÚreturn_dict_in_generaterx   Úmonitor_progressc                 ó¾  ‡@‡A—  | j         |fi |¤Ž\  }}| j        j        j        j        d         | j        j        j        j        d         z  }|| j        j        z  }|                      |||¬¦  «        \  }}||k    }|  	                    ||||¬¦  «        }|  
                    |||¬¦  «        } |                      |	||
|¬¦  «         |                      ||||¬¦  «         |                      |||||¬¦  «         |                      ||¬¦  «         |                      |||| j        ||¬	¦  «        }!|                      |¬
¦  «         |rd| j        j        _        d|v r|d         d         j        n|j        }"|!j        d         }#|                     dt+          |d¦  «        r|j        �|j        nd¦  «        }$d|v rd|_        |                      |||#|$|"¬¦  «        }|                      ||¬¦  «         t5          |t6          t8          f¦  «        s|gn|}%|%d         }|                      ||||¬¦  «        \  }&}'|j        Š@|                      ||'|&|!|||¬¦  «        \  }(})}}'}&}!}*|                       ||)|¬¦  «        }+d|v r|d         },d|,j!        _"        |€<t+          |d¦  «        r|j"        }n$t+          | j!        d¦  «        r| j!        j"        }nd}|'|&k      #                    ¦   «         �r|�! |tI          j%        |'|&fd¬¦  «        ¦  «         |  &                    ||'|&|)|(¬¦  «        \  }})}(|' '                    |"j(        dk    rtH          j)        ntH          j*        ¦  «        |z  |z  }-|&|'z
   +                    |¬¦  «        }.|  ,                    ||'|.||)|(¬¦  «        }/t[          |t\          d¦  «        }0|  /                    |)|!|+|(|*||| j        |!j        |0| |¬¦  «        \  }1}|  0                    | j        |1|¬ ¦  «         |�5|D ]2}2t+          |2d!¦  «        r |2 1                    |1j        d"         ¦  «         Œ3|  2                    |/|1|)|'|(|%|||||||*||||¬#¦  «        \  }3}4}5}*}6tg          |3¦  «        D ]p\  }7}8|(|7         }9|5|7         r|'|9xx         |.|9         z  cc<   Œ,|  4                    |8|4|-| |.||||9|7||1¬$¦  «        \  }:};|'|9xx         |;z  cc<   |+|9xx         |:z  cc<   Œq|rn|'|&k      #                    ¦   «         �°|�|j5        d%k    rd&„ |+D ¦   «         n|+}<|rÞ|j6        r×|s|sÓ|  7                    |4|6| j        |¦  «        ŠA‰@dk    r®t+          ‰Ad'¦  «        rG‰Aj8        �@t9          ˆ@ˆAfd(„ts          tu          ‰Aj8        ¦  «        ¦  «        D ¦   «         ¦  «        ‰A_8        t+          ‰Ad)¦  «        rG‰Aj;        �@t9          ˆ@ˆAfd*„ts          tu          ‰Aj;        ¦  «        ¦  «        D ¦   «         ¦  «        ‰A_;        ‰AS ty          |<|j=        | j        d+||¬,¦  «        }=|r$|j6        rt|           ?                    d-¦  «         d}n|s|s|=S |r|=\  }>}?|>|?d.œŠAn|=}>d/|>iŠA|r|<‰Ad0<   ‰AS )1ueP  
        Transcribes or translates log-mel input features to a sequence of auto-regressively generated token ids.

        <Tip warning={true}>

        Most generation-controlling parameters are set in `generation_config` which, if not passed, will be set to the
        model's default generation configuration. You can override any `generation_config` by passing the corresponding
        parameters to generate(), e.g. `.generate(inputs, num_beams=4, do_sample=True)`.

        For an overview of generation strategies and code examples, check out the [following
        guide](../generation_strategies).

        </Tip>

        Parameters:
            input_features (`torch.Tensor` of shape `(batch_size, feature_size, sequence_length)`, *optional*):
                Float values of log-mel features extracted from the raw speech waveform. The raw speech waveform can be obtained by
                loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a `numpy.ndarray` or a `torch.Tensor`,
                *e.g.*  via the torchcodec library (`pip install torchcodec`) or the soundfile library (`pip install soundfile`).
                To prepare the array into `input_features`, the [`AutoFeatureExtractor`] should be used for extracting the mel
                features, padding and conversion into a tensor of type `torch.FloatTensor`.
                See [`~WhisperFeatureExtractor.__call__`] for details.
            generation_config ([`~generation.GenerationConfig`], *optional*):
                The generation configuration to be used as base parametrization for the generation call. `**kwargs`
                passed to generate matching the attributes of `generation_config` will override them. If
                `generation_config` is not provided, the default will be used, which had the following loading
                priority: 1) from the `generation_config.json` model file, if it exists; 2) from the model
                configuration. Please note that unspecified parameters will inherit [`~generation.GenerationConfig`]'s
                default values, whose documentation should be checked to parameterize generation.
            logits_processor (`LogitsProcessorList`, *optional*):
                Custom logits processors that complement the default logits processors built from arguments and
                generation config. If a logit processor is passed that is already created with the arguments or a
                generation config an error is thrown. This feature is intended for advanced users.
            stopping_criteria (`StoppingCriteriaList`, *optional*):
                Custom stopping criteria that complement the default stopping criteria built from arguments and a
                generation config. If a stopping criteria is passed that is already created with the arguments or a
                generation config an error is thrown. This feature is intended for advanced users.
            prefix_allowed_tokens_fn (`Callable[[int, torch.Tensor], list[int]]`, *optional*):
                If provided, this function constraints the beam search to allowed tokens only at each step. If not
                provided no constraint is applied. This function takes 2 arguments: the batch ID `batch_id` and
                `input_ids`. It has to return a list with the allowed tokens for the next generation step conditioned
                on the batch ID `batch_id` and the previously generated tokens `inputs_ids`. This argument is useful
                for constrained generation conditioned on the prefix, as described in [Autoregressive Entity
                Retrieval](https://huggingface.co/papers/2010.00904).
            synced_gpus (`bool`, *optional*, defaults to `False`):
                Whether to continue running the while loop until max_length (needed to avoid deadlocking with
                `FullyShardedDataParallel` and DeepSpeed ZeRO Stage 3).
            return_timestamps (`bool`, *optional*):
                Whether to return the timestamps with the text. This enables the `WhisperTimestampsLogitsProcessor`.
                For audios longer than 30 seconds, it is necessary to set `return_timestamps=True`.
            task (`str`, *optional*):
                Task to use for generation, either "translate" or "transcribe".
            language (`str` or list of `str`, *optional*):
                Language token to use for generation, can be either in the form of `<|en|>`, `en` or `english`. For
                batched generation, a list of language tokens can be passed. You can find all the possible language
                tokens in the `model.generation_config.lang_to_id` dictionary.
            is_multilingual (`bool`, *optional*):
                Whether or not the model is multilingual.
            prompt_ids (`torch.Tensor`, *optional*):
                Rank-1 tensor of token IDs created by passing text to [`~WhisperProcessor.get_prompt_ids`] that is
                provided as a prompt to each chunk. This can be used to provide or "prompt-engineer" a context for
                transcription, e.g. custom vocabularies or proper nouns to make it more likely to predict those words
                correctly. It cannot be used in conjunction with `decoder_start_token_id` as it overwrites this value.
            prompt_condition_type (`str`, *optional*):
                Only relevant for long-form transcription. Condition type of `prompt_ids`. 'first-segment' means only the first segment is conditioned on `prompt_ids`. 'all-segments' means each segment is conditioned on `prompt_ids`. Make sure to enable `condition_on_prev_tokens` for 'all-segments'.
                Defaults to 'first-segment'. For short-term transcription only 'first-segment' is possible.
            condition_on_prev_tokens (`bool`, *optional*):
                Only relevant for long-form transcription. Whether to condition each segment on the previous segment.
                As shown in the [the Whisper paper](https://cdn.openai.com/papers/whisper.pdf), this can help to improve
                performance.
            temperature (`float` or list of `float`, *optional*):
                The temperature to be used for generation. Passing a single `float` value and `do_sample=True` activates
                generation using sampling. For long-form transcription, temperature fallback can be activated by passing
                a list of float values such as (0.0, 0.2, 0.4, 0.6, 0.8, 1.0). As shown in the [the Whisper paper](https://cdn.openai.com/papers/whisper.pdf), this can help to improve
                performance.
            compression_ratio_threshold (`float`, *optional*):
                Only relevant for long-form transcription. If defined, the zlib compression rate of each segment will be computed. If the compression rate of
                a segment is higher than `compression_ratio_threshold`, temperature fallback is activated: the generated segment is discarded and the generation is
                repeated using a higher temperature. The intuition behind this feature is that segments with very high compression rates
                suffer from a lot of repetition. The unwanted repetition can be reduced by injecting more randomness by increasing the temperature. If `compression_ratio_threshold` is defined
                make sure that `temperature` is a list of values. A common value for `compression_ratio_threshold` is 1.35.
                As shown in the [the Whisper paper](https://cdn.openai.com/papers/whisper.pdf), this can help to improve
                performance.
            logprob_threshold (`float`, *optional*):
                Only relevant for long-form transcription. If defined, the average log-probability of each segment will be computed. If the log-probability of
                a given segment is lower than `logprob_threshold`, temperature fallback is activated: the generated segment is discarded and the generation is
                repeated using a higher temperature. The intuition behind this feature is that segments of low log-probability
                can be improved by injecting more randomness by increasing the temperature. If `logprob_threshold` is defined
                make sure that `temperature` is a list of values. A common value for `logprob_threshold` is -1.0.
                As shown in the [the Whisper paper](https://cdn.openai.com/papers/whisper.pdf), this can help to improve
                performance.
            no_speech_threshold (`float`, *optional*):
                Only relevant for long-form transcription. If defined, the "no-speech" token combined with the `logprob_threshold`
                is used to determine whether a segment contains only silence. In this case, the transcription for this segment
                is skipped.
                As shown in the [the Whisper paper](https://cdn.openai.com/papers/whisper.pdf), this can help to improve
                performance.
            num_segment_frames (`int`, *optional*):
                The number of frames a single segment is made of. If not defined, `num_segment_frames` defaults to the model's stride
                times the maximum input length.
            attention_mask (`torch.Tensor`, *optional*):
                `attention_mask` needs to be passed when doing long-form transcription using a batch size > 1.
            time_precision (`int`, *optional*, defaults to 0.02):
                The duration of output token in seconds. *E.g.* 0.02 means that a generated token on average accounts
                for 20 ms.
            time_precision_features (`int`, *optional*, defaults to 0.01):
                The duration represented by a feature frame in seconds.
            return_token_timestamps (`bool`, *optional*):
                Whether to return token-level timestamps with the text. This can be used with or without the
                `return_timestamps` option. To get word-level timestamps, use the tokenizer to group the tokens into
                words.
            return_segments (`bool`, *optional*, defaults to `False`):
                Whether to additionally return a list of all segments. Note that this option can only be enabled
                when doing long-form transcription.
            return_dict_in_generate (`bool`, *optional*, defaults to `False`):
                Whether or not to return a [`~utils.ModelOutput`] instead of just returning the generated tokens.
                Note that when doing long-form transcription, `return_dict_in_generate` can only be enabled when
                `return_segments` is set True. In this case the generation outputs of each segment is added to each
                segment.
            force_unique_generate_call (`bool`, *optional*):
                Whether to force a unique call to the underlying GenerationMixin's [`~generation.GenerationMixin.generate`] method. This is useful for assisted decoding and testing purposes to ensure
                that only one call to [`~generation.GenerationMixin.generate`] is made and therefore decoder input token ids and eos token ids are returned.
            monitor_progress (`Callable[[torch.Tensor], None]`, *optional*):
                If provided, this function can be called to report the progress of the audio transcription. The function
                takes a tensor argument `p` of shape `(n, 2)`, where `n` is the batch size. `p[i, 0]`  contains the
                index of the audio frame that is currently being transcribed for batch item `i`. `p[i, 1]` contains
                the total number of frames for batch item `i`. No return value is expected.
            kwargs (`dict[str, Any]`, *optional*):
                Ad hoc parametrization of `generate_config` and/or additional model-specific kwargs that will be
                forwarded to the `forward` function of the model. If the model is an encoder-decoder model, encoder
                specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with *decoder_*.
        Return:
            [`~utils.ModelOutput`] or `dict[str, Any]` or `torch.LongTensor`:

                One of the following:
                - [`~utils.ModelOutput`] when `return_dict_in_generate=True` and (`return_timestamps=False` or `force_unique_generate_call=True`), including the decoder input ids and end of sequence id.
                - `dict[str, Any]` when (`return_dict_in_generate=True` and `return_timestamps=True`) or `return_segments=True` or `return_token_timestamps=True`.
                - `torch.LongTensor` in all other cases, excluding the decoder input ids and end of sequence id.

                The possible [`~utils.ModelOutput`] types are:
                - [`~generation.GenerateEncoderDecoderOutput`]
                - [`~generation.GenerateBeamEncoderDecoderOutput`]

                `segments` is a list of lists (one list per batch element) of `segment`.
                A `segment` is a dictionary with keys `start`, `end`, `tokens`, `idxs`, and `result`.
                - `start`: the start timestamp of the segment.
                - `end`: the end timestamp of the segment.
                - `tokens`: the tokens of the segment, excluding the decoder input ids and end of sequence id.
                - `idxs`: the start (included) and end (excluded) indices of the `tokens` of the segment in the underlying call to GenerationMixin's [`~generation.GenerationMixin.generate`] (present in `result`).
                - `result`: the result of the underlying call to GenerationMixin's [`~generation.GenerationMixin.generate`].

                When `return_timestamps=True`, `return_dict_in_generate=True` applies to each call of the underlying GenerationMixin's [`~generation.GenerationMixin.generate`], with outputs stored in `result` of each `segment`.

        Example:

        - *Longform transcription*: To transcribe or translate audios longer than 30 seconds, process the audio files without truncation and pass all mel features at once to generate. It is necessary to set `return_timestamps=True`.
        Indeed, long-form transcription uses a sequential algorithm based on timestamps predictions, with heuristics like compression ratio threshold, log probability threshold and temperature fallback. This algorithm is described in the [the Whisper original paper](https://cdn.openai.com/papers/whisper.pdf), section *3.8. Long-form Transcription*.

        ```python
        >>> import torch
        >>> from transformers import AutoProcessor, WhisperForConditionalGeneration
        >>> from datasets import load_dataset, Audio

        >>> processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
        >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
        >>> model.cuda()  # doctest: +IGNORE_RESULT

        >>> # load audios > 30 seconds
        >>> ds = load_dataset("distil-whisper/meanwhile", "default")["test"]
        >>> # resample to 16kHz
        >>> ds = ds.cast_column("audio", Audio(sampling_rate=16000))
        >>> # take first 8 audios and retrieve array
        >>> audio = ds[:8]["audio"]
        >>> audio = [x["array"] for x in audio]

        >>> # make sure to NOT truncate the input audio, to return the `attention_mask` and to pad to the longest audio
        >>> inputs = processor(audio, return_tensors="pt", truncation=False, padding="longest", return_attention_mask=True, sampling_rate=16_000)
        >>> inputs = inputs.to("cuda", torch.float32)

        >>> # transcribe audio to ids
        >>> generated_ids = model.generate(**inputs, return_timestamps=True)

        >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
        >>> transcription[0]
        " Folks, if you watch the show, you know, I spent a lot of time right over there. Patiently and astutely scrutinizing the boxwood and mahogany chest set of the day's biggest stories developing the central headline pawns, definitely maneuvering an oso topical night to F6, fainting a classic Sicilian, nade door variation on the news, all the while seeing eight moves deep and patiently marshalling the latest press releases into a fisher's shows in Lip Nitsky attack that culminates in the elegant lethal slow-played, all-passant checkmate that is my nightly monologue. But sometimes, sometimes, folks, I. CHEERING AND APPLAUSE Sometimes I startle away, cubside down in the monkey bars of a condemned playground on a super fun site. Get all hept up on goofballs. Rummage that were discarded tag bag of defective toys. Yank out a fist bowl of disembodied doll limbs, toss them on a stained kid's place mat from a defunct dennies. set up a table inside a rusty cargo container down by the Wharf and challenged toothless drifters to the godless bughouse blitz of tournament that is my segment. Meanwhile."
        ```

        The `monitor_progress` callback can be used to monitor the progress of the transcription:
        ```python
        >>> from tqdm import tqdm

        >>> # prepare inputs like above

        >>> # define a callback to monitor the progress of the transcription.
        >>> with tqdm(desc="Progress") as pbar:
        >>>     def monitor_progress(p_batch):
        >>>         i = torch.argmax(p_batch[:, 1])
        >>>         p = p_batch[i].detach().cpu()
        >>>         pbar.total = int(p[1])
        >>>         pbar.n = int(p[0])
        >>>         pbar.update()

        >>>     # transcribe audio to ids
        >>>     generated_ids = model.generate(**inputs, return_timestamps=True, monitor_progress=monitor_progress)

        >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)
        >>> transcription[0]
        Progress:  95%|â–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–Ž    | 8497/8901 [00:04<00:00, 2052.79it/s]
        " Folks, if you watch the show, you know, I spent a lot of time right over there. Patiently and astutely scrutinizing the boxwood and mahogany chest set of the day's biggest stories developing the central headline pawns, definitely maneuvering an oso topical night to F6, fainting a classic Sicilian, nade door variation on the news, all the while seeing eight moves deep and patiently marshalling the latest press releases into a fisher's shows in Lip Nitsky attack that culminates in the elegant lethal slow-played, all-passant checkmate that is my nightly monologue. But sometimes, sometimes, folks, I. CHEERING AND APPLAUSE Sometimes I startle away, cubside down in the monkey bars of a condemned playground on a super fun site. Get all hept up on goofballs. Rummage that were discarded tag bag of defective toys. Yank out a fist bowl of disembodied doll limbs, toss them on a stained kid's place mat from a defunct dennies. set up a table inside a rusty cargo container down by the Wharf and challenged toothless drifters to the godless bughouse blitz of tournament that is my segment. Meanwhile."
        ```

        - *Shortform transcription*: If passed mel input features are <= 30 seconds, there are two possibilities:
            - `return_timestamps=False`: the whole audio will be transcribed with a single call to GenerationMixin's [`~generation.GenerationMixin.generate`].
            - `return_timestamps=True`: the audio will be transcribed using the same logic as long-form transcription.

        ```python
        >>> import torch
        >>> from transformers import AutoProcessor, WhisperForConditionalGeneration
        >>> from datasets import load_dataset

        >>> processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
        >>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")

        >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")

        >>> inputs = processor(ds[0]["audio"]["array"], return_tensors="pt")
        >>> input_features = inputs.input_features

        >>> generated_ids = model.generate(inputs=input_features)

        >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
        >>> transcription
        ' Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'
        ```

        r   )r¿   Úinput_strideÚkwargs©rÓ   rw   rÍ   rÀ   )rÄ   Úis_shortformrÀ   ©rÆ   rÅ   rÇ   rÀ   ©rw   rÀ   rÐ   r×   ©rÀ   rÍ   rÌ   rÎ   rÊ   )rÀ   rÉ   )r·   rÀ   r™   rÏ   r×   )r×   ÚeagerÚencoder_outputsr   Ú	num_beamsNÚassistant_model)rÀ   rM   Úbegin_indexrß   re   ©rÊ   rÀ   )r·   rÐ   Útotal_input_framesrÙ   )r¿   ÚseekÚ
max_framesÚinit_tokensr·   rÊ   rÀ   )rÈ   r·   rÀ   Trx   FrX   )r¿   rä   rå   Úcur_bszÚbatch_idx_mapÚmps)rn   )r¿   rä   Úseek_num_framesrÏ   rç   rè   Úsuppress_tokens)rç   ræ   rq   rè   Údo_condition_on_prev_tokensrÈ   rÀ   r™   re   rë   rz   r×   )r™   Údecoder_input_idsrÀ   Úset_begin_indexr   )Úsegment_inputrí   rç   rä   rè   ÚtemperaturesrÀ   rM   rÁ   rÂ   rÃ   rw   rì   rÙ   r·   rÐ   r×   )Úseek_sequenceÚseek_outputsÚtime_offsetrz   rê   r²   rÑ   rÖ   Úprev_idxÚidxrw   rí   úfirst-segmentc                 ó"   — g | ]}|d d…         ‘ŒS )r   Nr]   )rG   r‰   s     r%   r`   z3WhisperGenerationMixin.generate.<locals>.<listcomp>Œ  s    € Ð-Ð-Ð-�qˆQˆqˆrˆrŒUÐ-Ð-Ð-r'   Úencoder_attentionsc              3   óD   •K  — | ]}‰j         |         d d ‰…         V — Œd S rE   )rø   ©rG   r:   Únum_return_sequencesÚoutputss     €€r%   rJ   z2WhisperGenerationMixin.generate.<locals>.<genexpr>�  sN   øè è € ð 7ð 7àð  Ô2°1Ô5Ð6LÐ6LÐ8LÐ6LÔMð7ð 7ð 7ð 7ð 7ð 7r'   Úencoder_hidden_statesc              3   óD   •K  — | ]}‰j         |         d d ‰…         V — Œd S rE   )rý   rú   s     €€r%   rJ   z2WhisperGenerationMixin.generate.<locals>.<genexpr>¢  sN   øè è € ð :ð :àð  Ô5°aÔ8Ð9OÐ9OÐ;OÐ9OÔPð:ð :ð :ð :ð :ð :r'   rQ   )rq   rr   re   rs   rw   rx   zãYou have passed `return_dict_in_generate=True` and `return_timestamps=True`, this automatically sets `return_segments=True` to access the results of the underlying calls to GenerationMixin's generate in the returned `segments`.)rV   rW   rV   r   )@Ú_prepare_generation_configÚmodelÚencoderÚconv1ÚstrideÚconv2r™   Úmax_source_positionsÚ_retrieve_total_input_framesÚ_set_return_outputsÚ_set_return_timestampsÚ_set_language_and_taskÚ_set_num_framesÚ_set_thresholds_and_conditionÚ_set_prompt_condition_typeÚ_retrieve_init_tokensÚ_check_decoder_input_idsÚ_attn_implementationre   r   ÚgetÚhasattrrß   Úbegin_suppress_tokensÚ_retrieve_logit_processorsÚ_set_condition_on_prev_tokensrF   r¡   r¢   Ú_retrieve_max_frames_and_seekrû   Ú _expand_variables_for_generationÚ_prepare_segmentsrÀ   rx   Úanyrh   rj   Ú_maybe_reduce_batchÚtoÚtyper/   Úfloat64ÚclampÚ_get_input_segmentrP   r   Ú_prepare_decoder_input_idsÚ_set_max_new_tokens_and_lengthrî   Úgenerate_with_fallbackÚ	enumerateÚ_retrieve_segmentrÉ   rÓ   Ú_stack_split_outputsrø   r1   rk   rý   rƒ   rr   ÚloggerÚwarning_once)Br¯   r¿   rÀ   rM   rÁ   rÂ   rÃ   rÄ   rÅ   rÆ   rÇ   rÈ   rÉ   rÊ   rË   rÌ   rÍ   rÎ   rÏ   rÐ   r²   rÑ   rw   rÒ   rÓ   rx   rÔ   r×   rÖ   r·   rã   rÙ   rz   ræ   re   rá   rß   rð   rå   rä   rè   rç   rì   rq   rà   ró   rê   rï   rë   rí   ÚprocÚseek_sequencesrò   Úshould_skipÚmodel_output_typer:   rñ   Úprev_ir   Úsegment_offsetÚfinal_segmentsÚpadded_outputsrV   rW   rû   rü   sB                                                                   @@r%   ÚgeneratezWhisperGenerationMixin.generate  sw	  øø€ ðV %D DÔ$CÐDUÐ$`Ð$`ÐY_Ð$`Ð$`Ñ!Ð˜6ð ”zÔ)Ô/Ô6°qÔ9¸D¼JÔ<NÔ<TÔ<[Ð\]Ô<^Ñ^ˆØ)¨D¬KÔ,LÑLÐØ)-×)JÒ)JØ)¸ÈVð *Kñ *
ô *
Ñ&ˆ
Ð&ð *Ð-?Ò?ˆð #'×":Ò":Ø$;Ø$;Ø/Ø/ð	 #;ñ #
ô #
Ðð ×5Ò5Ø/¸lÐ^oð 6ñ 
ô 
ˆð 	×#Ò#Ø D¸/Ð]nð 	$ñ 	
ô 	
ð 	
ð 	×ÒØ$;Ø/Ø)Øð	 	ñ 	
ô 	
ð 	
ð 	×*Ò*Ø/Ø/Ø(CØ 3Ø%=ð 	+ñ 	
ô 	
ð 	
ð 	×'Ò'Ø/Ø"7ð 	(ñ 	
ô 	
ð 	
ð ×0Ò0ØØ!Ø/Ø”;Ø1Øð 1ñ 
ô 
ˆð 	×%Ò%¨VÐ%Ñ4Ô4Ð4ð #ð 	=Ø5<ˆDŒJÔÔ2ð 9JÈVÐ8SÐ8S�Ð)Ô*¨1Ô-Ô4Ð4ÐYgÔYnˆØ!Ô'¨Ô*ˆØ—J’JØåÐ(¨+Ñ6Ô6ðØ;LÔ;VÐ;bð Ô'Ð'àñ	
ô 
ˆ	ð  Ð&Ð&à6:ÐÔ3à×:Ò:Ø/Ø-Ø#ØØð ;ñ 
ô 
Ðð 	×*Ò*Ø%=ÐQbð 	+ñ 	
ô 	
ð 	
õ -7°{ÅTÍ5ÀMÑ,RÔ,RÐc˜�}�}ÐXcˆØ" 1”oˆà×=Ò=Ø!Ø)Ø1Ø%ð	 >ñ 
ô 
Ñˆ
�Dð  1ÔEÐð ×1Ò1Ø)ØØ!Ø#Ø!Ø%=Ø/ð 2ñ 
ô 
ñ	
ØØØØØØØ'ð  ×1Ò1Ø!ØØ/ð 2ñ 
ô 
Ðð  Ð&Ð&Ø$Ð%6Ô7ˆOØKOˆOÔ-ÔHà%Ð-ÝÐ(Ð*FÑGÔGð 3Ø->Ô-YÐ*Ð*Ý˜Ô/Ð1MÑNÔNð 3Ø-1Ô-CÔ-^Ð*Ð*à-2Ð*ð �jÒ ×%Ò%Ñ'Ô'ñ v	ØÐ+Ø Ð ¥¤¨d°JÐ-?ÀQÐ!GÑ!GÔ!GÑHÔHÐHð 6:×5MÒ5MØ-ØØ%ØØ+ð 6Nñ 6ô 6Ñ2ˆN˜G ]ð —’¨¬¸Ò)=Ð)=�œ˜Å5Ä=ÑQÔQÐTbÑbÐeqÑqð ð  *¨DÑ0×7Ò7Ð<NÐ7ÑOÔOˆOð !×3Ò3Ø-ØØ /Ø#5ØØ+ð 4ñ ô ˆMõ >Ø Õ"?ÐARñô ˆOð )-×(GÒ(GØØ'Ø!1Ø+Ø,GØ%Ø"3Ø”{Ø"Ô)Ø /Ø /Øð )Hñ )ô )Ñ%Ð˜vð  ×/Ò/Ø”{Ø"3Ø"3ð 0ñ ô ð ð  Ð+Ø,ð Jð J�DÝ˜tÐ%6Ñ7Ô7ð JØ×,Ò,Ð->Ô-DÀRÔ-HÑIÔIÐIøð ×+Ò+Ø+Ø"3ØØØ+Ø)Ø"3Ø!1Ø"3Ø)AØ'Ø(?Ø,GØ)Ø%Ø-Øð# ,ñ ô ñØØØØ+Ø!õ, %.¨nÑ$=Ô$=ð 5ð 5Ñ ��=Ø& qÔ)�à˜q”>ð Ø˜�L�L”L O°FÔ$;Ñ;�L�L‘LØà+/×+AÒ+AØ"/Ø!-Ø +Ø$3Ø$3Ø#1Ø,CØ!-Ø#ØØ,CØ&7ð ,Bñ ,ô ,Ñ(�˜.ð �V��” Ñ.��‘à  Ð(Ð(Ô(¨HÑ4Ð(Ð(Ñ(Ð(à)ð Øðm �jÒ ×%Ò%Ñ'Ô'ñ v	ðx Ð&Ð+<Ô+RÐVeÒ+eÐ+eð .Ð-Ð,Ð-Ñ-Ô-Ð-à!ð 	ð $ð	à!Ô9ð	ð ,ð	ð 4Eð	ð ×/Ò/°Ð>OÐQUÔQ\Ð^dÑeÔeˆGØ# aÒ'Ð'Ý˜7Ð$8Ñ9Ô9ð ¸gÔ>XÐ>dÝ16ð 7ð 7ð 7ð 7ð 7å!&¥s¨7Ô+EÑ'FÔ'FÑ!GÔ!Gð7ñ 7ô 7ñ 2ô 2�GÔ.õ ˜7Ð$;Ñ<Ô<ð ÀÔA^ÐAjÝ49ð :ð :ð :ð :ð :å!&¥s¨7Ô+HÑ'IÔ'IÑ!JÔ!Jð:ñ :ô :ñ 5ô 5�GÔ1ð ˆNå+Ø+Ø*Ô7Ø”;Ø Ø$;Ø'Að
ñ 
ô 
ˆð #ð 	"Ð'8Ô'Pð 	"Ý×Òð vñô ð ð #ˆOˆOØ ð 	"Ð)@ð 	"Ø!Ð!à"ð 
	Ø*8Ñ'ˆIÐ'à&Ø$4ðð ˆGˆGð
 'ˆIà˜YðˆGð ð 	1Ø"0ˆG�JÑàˆr'   c                 ó–  •— t          j         |¦  «        }d„ t          |¦  «        D ¦   «         }d„ t          |¦  «        D ¦   «         }d„ t          |¦  «        D ¦   «         }d„ t          |¦  «        D ¦   «         }t          t          |¦  «        ¦  «        }|j        �|                      ||||¦  «         t          |¦  «        D �]~\  }}|d uo|dk    |_        |j        r|nd|_        |j        rd|_        t          j         |¦  «        }dD ]	}||v r||= Œ
|j	        d	         }|j
        d
k    rÃ||k     r½t          j        |d	d	d	d	d	||z
  fd	¬¦  «        }t          j        |d	d	d	||z
  f|j        ¬¦  «        }|                     d¦  «        �'t          j        |d         d	d	d	||z
  fd¬¦  «        |d<   |                     d¦  «        �)t          j        |d         d	d	d	d	d	||z
  fd	¬¦  «        |d<    t          ¦   «         j        |f|||	|
|||dœ|¤Ž}t#          |¦  «        }|                      |||||||¬¦  «        \  }}||k     r|d |…         }|d |…         }g }g }g } g }!t          |¦  «        D �]Y\  }"}#|#d         |j        k    rC|#|j        k                         ¦   «         }$|j        |j        k    r|$dz  }$|$d	k    r|#d |$ …         }#|                      |#||"||| j        j        |¦  «        \  ||"<   ||"<   |#d         |j        k    r
|#d d…         }#|#|||"         <   ||"         |||"         <   |d u p|dk     }%|j        o|%|||"         <   ||"         rv|                     ||"         ¦  «         |                     ||"         ¦  «         |                      ||"         ¦  «         d|v r!|!                     |d         |"         ¦  «         �Œ[|}t5          |¦  «        d	k    s|t5          |¦  «        dz
  k    r|}|} nEt7          j        | ¦  «        }t7          j        |¦  «        }d|v rt7          j        |!¦  «        |d<   �Œ€|||||fS )Nc                 ó   — g | ]}d ‘ŒS rE   r]   ©rG   Ú_s     r%   r`   zAWhisperGenerationMixin.generate_with_fallback.<locals>.<listcomp>á  s   € Ð;Ð;Ð; q˜dÐ;Ð;Ð;r'   c                 ó   — g | ]}d ‘ŒS rE   r]   r2  s     r%   r`   zAWhisperGenerationMixin.generate_with_fallback.<locals>.<listcomp>â  s   € Ð:Ð:Ð: a˜TÐ:Ð:Ð:r'   c                 ó   — g | ]}d ‘ŒS ©Fr]   r2  s     r%   r`   zAWhisperGenerationMixin.generate_with_fallback.<locals>.<listcomp>ã  s   € Ð8Ð8Ð8 A˜%Ð8Ð8Ð8r'   c                 ó   — g | ]}d ‘ŒS r6  r]   r2  s     r%   r`   zAWhisperGenerationMixin.generate_with_fallback.<locals>.<listcomp>ä  s   € Ð5Ð5Ð5 �uÐ5Ð5Ð5r'   rf   g      ð?r   )Ú	do_samplerË   rß   r   Ústatic)rg   Údecoder_attention_maskTrÞ   )rÀ   rM   rÁ   rÂ   rÃ   rí   rÐ   )rò   rí   rw   rÀ   rÙ   rä   rè   r   g      à?)Úcopyr1   r¡   rÎ   Ú_setup_no_speech_detectionr"  r8  rË   rß   r   Úcache_implementationrp   r    rr   r  Úsuperr/  r  Ú_postprocess_outputsrœ   Úeos_token_idÚ_need_fallbackr™   Ú
vocab_sizerÊ   r2   rk   rh   rj   )'r¯   rï   rí   rç   rä   rè   rð   rÀ   rM   rÁ   rÂ   rÃ   rw   rì   rÙ   r·   rÐ   r×   Úseek_sequence_listÚseek_outputs_listÚneeds_fallbackr)  Úfallback_index_mapÚfallback_idxrË   Úgenerate_kwargsÚkeyrò   r*  r(  Únew_fallback_index_mapÚnew_segment_inputÚnew_decoder_input_idsÚnew_decoder_attention_maskr:   rñ   Únum_paddingsÚis_low_temperatureÚ	__class__s'                                         €r%   r!  z-WhisperGenerationMixin.generate_with_fallbackÊ  s£  ø€ õ( ”˜6Ñ"Ô"ˆð <Ð;­E°'©N¬NÐ;Ñ;Ô;ÐØ:Ð:­5°©>¬>Ð:Ñ:Ô:ÐØ8Ð8­¨w©¬Ð8Ñ8Ô8ˆØ5Ð5¥e¨G¡n¤nÐ5Ñ5Ô5ˆÝ!¥%¨¡.¤.Ñ1Ô1ÐØÔ0Ð<Ø×+Ò+Ð,<¸mÐM^Ð`fÑgÔgÐgå)2°<Ñ)@Ô)@ð q	[ñ q	[Ñ%ˆL˜+Ø*5¸TÐ*AÐ*WÀkÐTWÒFWÐÔ'Ø;LÔ;VÐ,_¨K¨KÐ\_ÐÔ)Ø Ô*ð 0Ø./Ð!Ô+å"œi¨Ñ/Ô/ˆOØ@ð -ð -�Ø˜/Ð)Ð)Ø'¨Ð,øà'Ô-¨aÔ0ˆGØ Ô5¸ÒAÐAÀgÐPZÒFZÐFZÝ !¤ m°a¸¸A¸qÀ!ÀZÐRYÑEYÐ5ZÐbcÐ dÑ dÔ d�Ý$%¤EØ%¨¨1¨a°¸gÑ1EÐ'FÐN_ÔNlð%ñ %ô %Ð!ð #×&Ò&Ð'?Ñ@Ô@ÐLÝ@AÄØ'Ð(@ÔAÀAÀqÈ!ÈZÐZaÑMaÐCbÐjnðAñ Aô A�OÐ$<Ñ=ð #×&Ò&Ð'8Ñ9Ô9ÐEÝ9:¼Ø'Ð(9Ô:¸QÀÀ1ÀaÈÈJÐY`ÑL`Ð<aÐijð:ñ :ô :�OÐ$5Ñ6ð ,�5™7œ7Ô+Øð
à"3Ø!1Ø"3Ø)AØ'Ø"3Ø-ð
ð 
ð "ð
ð 
ˆLõ !% \Ñ 2Ô 2Ðð ,0×+DÒ+DØ)Ø"3Ø(?Ø"3Ø)ØØ+ð ,Eñ ,ô ,Ñ(ˆN˜Lð ˜Ò#Ð#Ø!/°°°Ô!9�Ø+¨H¨W¨HÔ5�ð &(Ð"Ø "ÐØ$&Ð!Ø)+Ð&å$-¨nÑ$=Ô$=ð %_ñ %_Ñ ��=à  Ô$Ð(9Ô(FÒFÐFØ$1Ð5FÔ5SÒ$S×#XÒ#XÑ#ZÔ#Z�LØ(Ô5Ð9JÔ9WÒWÐWà$¨Ñ)˜Ø# qÒ(Ð(Ø(5°n¸°}°nÔ(E˜ð 59×4GÒ4GØ!Ø ØØ$Ø%Ø”KÔ*Øñ5ô 5Ñ1�˜qÑ! ;¨q¡>ð ! Ô$Ð(9Ô(FÒFÐFØ$1°#°2°#Ô$6�Mà<IÐ"Ð#5°aÔ#8Ñ9Ø;GÈ¼?Ð!Ð"4°QÔ"7Ñ8Ø%0°DÐ%8Ð%M¸KÈ#Ò<MÐ"à%Ô>ÐUÐCUð ,Ð,>¸qÔ,AÑBð " !Ô$ð _Ø*×1Ò1Ð2DÀQÔ2GÑHÔHÐHØ%×,Ò,¨]¸1Ô-=Ñ>Ô>Ð>Ø)×0Ò0Ð1BÀ1Ô1EÑFÔFÐFØ/°6Ð9Ð9Ø2×9Ò9¸&ÐAYÔ:ZÐ[\Ô:]Ñ^Ô^Ð^ùà!7Ðõ Ð%Ñ&Ô&¨!Ò+Ð+¨|½sÀ<Ñ?PÔ?PÐSTÑ?TÒ/TÐ/TØ!3�Ø0�Ø�õ !&¤Ð,AÑ BÔ BÐÝ!œKÐ(9Ñ:Ô:ˆMØ'¨6Ð1Ð1Ý38´;Ð?YÑ3ZÔ3Z�Ð/Ñ0ùà˜|¨[Ð:UÐWhÐhÐhr'   c                 óÞ   ‡ — ‰ �P|j         dk    rEt          |dd ¦  «        }‰ d         |k    r
‰ dd …         n‰ Š ˆ fd„t          |¦  «        D ¦   «         }nd„ t          |¦  «        D ¦   «         }|S )Nrö   Úprev_sot_token_idr   r   c                 ó   •— g | ]}d ‰ig‘ŒS r[   r]   )rG   r3  rÈ   s     €r%   r`   z<WhisperGenerationMixin._prepare_segments.<locals>.<listcomp>c  s!   ø€ ÐTÐTÐT¸Q (¨JÐ!7Ð 8ÐTÐTÐTr'   c                 ó   — g | ]}g ‘ŒS r]   r]   r2  s     r%   r`   z<WhisperGenerationMixin._prepare_segments.<locals>.<listcomp>e  s   € Ð>Ð>Ð> q Ð>Ð>Ð>r'   )rÉ   rL   r1   )rÈ   r·   rÀ   rR  rq   s   `    r%   r  z(WhisperGenerationMixin._prepare_segments^  s•   ø€ àÐ!Ð&7Ô&MÐQ`Ò&`Ð&`Ý 'Ð(9Ð;NÐPTÑ UÔ UÐØ+5°a¬=Ð<MÒ+MÐ+M˜ A B Bœ˜ÐS]ˆJØTÐTÐTÐTÅ%È
ÑBSÔBSÐTÑTÔTÐÐà>Ð>­E°*Ñ,=Ô,=Ð>Ñ>Ô>ÐàÐr'   c                 ó¾  ‡ ‡‡‡— |j         d         }t          ‰t          j        ¦  «        r‰d d …|d …f         ‰fS |r[t	          |d¦  «        rKt          |d¦  «        }	|	�|	|z
  }	|	|         }	‰                      ‰|j        |	|j         d         ¬¦  «        ‰d<   d
ˆ fd„	Š‰d         d d …|d …f         }
ˆˆˆfd„t          |
j         d	         ¦  «        D ¦   «         Š|
‰fS )Nr   r±   r³   )r³   r´   rW   c           	      óT  •‡— |�;|dk    r5d„ t          | |‰         d t          | ¦  «        …         ¦  «        D ¦   «         S |dv rˆfd„| D ¦   «         S |dv rt          ˆfd„| D ¦   «         ¦  «        S |dk    �r|sd S g }t          ‰j        j        ¦  «        D ]é}| j        j        |         j        ‰         d           	                    ¦   «         | j        j        |         j
        ‰         d           	                    ¦   «         | j        j        |         j        ‰         d           	                    ¦   «         | j        j        |         j
        ‰         d           	                    ¦   «         f}|                     |¦  «         Œêt          |¦  «        S | ‰          	                    ¦   «         S )NÚscoresc                 óH   — g | ]\  }}||                               ¦   «         ‘Œ S r]   ©r¥   )rG   ÚvÚbeam_idxs      r%   r`   z]WhisperGenerationMixin._postprocess_outputs.<locals>.split_by_batch_index.<locals>.<listcomp>‰  s*   € ÐsÐsÐs©m¨q°(˜˜(œŸšÑ)Ô)ÐsÐsÐsr'   ©rW  rø   rý   Úlogitsc                 óD   •— g | ]}|‰                               ¦   «         ‘ŒS r]   rY  ©rG   rZ  rº   s     €r%   r`   z]WhisperGenerationMixin._postprocess_outputs.<locals>.split_by_batch_index.<locals>.<listcomp>‹  s)   ø€ Ð;Ð;Ð;¨q˜˜)œ×(Ò(Ñ*Ô*Ð;Ð;Ð;r'   ©Údecoder_attentionsÚdecoder_hidden_statesr�   c              3   óN   •K  — | ]}t          ˆfd „|D ¦   «         ¦  «        V — Œ dS )c              3   óX   •K  — | ]$}|‰         d                                ¦   «         V — Œ%d S rE   rY  )rG   Úwrº   s     €r%   rJ   zfWhisperGenerationMixin._postprocess_outputs.<locals>.split_by_batch_index.<locals>.<genexpr>.<genexpr>�  s8   øè è € Ð"GÐ"GÀ 1 Y¤<°Ô#5×#9Ò#9Ñ#;Ô#;Ð"GÐ"GÐ"GÐ"GÐ"GÐ"Gr'   N)r¢   r_  s     €r%   rJ   z\WhisperGenerationMixin._postprocess_outputs.<locals>.split_by_batch_index.<locals>.<genexpr>�  s@   øè è € ÐXÐXÈA�UÐ"GÐ"GÐ"GÐ"GÀQÐ"GÑ"GÔ"GÑGÔGÐXÐXÐXÐXÐXÐXr'   Úpast_key_values)Úziprk   r¢   r1   r™   rš   Úself_attention_cacheÚlayersÚkeysr¥   ÚvaluesÚcross_attention_cacher2   r   )	rk  rI  rº   rÙ   rŽ   Úall_past_key_valuesÚ	layer_idxÚlayer_cacher¯   s	     `     €r%   Úsplit_by_batch_indexzIWhisperGenerationMixin._postprocess_outputs.<locals>.split_by_batch_index‡  sÂ  øø€ ØÐ'¨C°8ªO¨OØsÐs½sÀ6È<ÐXaÔKbÐcpÕehÐioÑepÔepÐcpÔKqÑ?rÔ?rÐsÑsÔsÐsØÐYÐYÐYØ;Ð;Ð;Ð;°FÐ;Ñ;Ô;Ð;ØÐYÐYÐYÝÐXÐXÐXÐXÐQWÐXÑXÔXÑXÔXÐXØÐ)Ò)Ñ)Ø#ð  à˜4Ø&(Ð#Ý!& t¤{Ô'AÑ!BÔ!Bð <ð <�IàÔ3Ô:¸9ÔEÔJÈ9ÔUÐVZÔ[×_Ò_ÑaÔaØÔ3Ô:¸9ÔEÔLÈYÔWÐX\Ô]×aÒaÑcÔcØÔ4Ô;¸IÔFÔKÈIÔVÐW[Ô\×`Ò`ÑbÔbØÔ4Ô;¸IÔFÔMÈiÔXÐY]Ô^×bÒbÑdÔdð	#�Kð (×.Ò.¨{Ñ;Ô;Ð;Ð;Ý*Ð+>Ñ?Ô?Ð?à˜)Ô$×(Ò(Ñ*Ô*Ð*r'   rV   c                 óX   •‡— g | ]%Šˆˆˆˆfd „‰                      ¦   «         D ¦   «         ‘Œ&S )c                 ó^   •— i | ])\  }}| ‰||‰‰‰                      d ¦  «        ¬¦  «        “Œ*S )rŽ   )rŽ   )r  )rG   ÚkrZ  r:   rÙ   rò   rp  s      €€€€r%   ú
<dictcomp>zJWhisperGenerationMixin._postprocess_outputs.<locals>.<listcomp>.<dictcomp>¡  sU   ø€ ð ð ð á�A�qð Ð'Ð'¨¨1¨a°ÈL×L\ÒL\Ð]kÑLlÔLlÐmÑmÔmðð ð r'   )Úitems)rG   r:   rÙ   rò   rp  s    @€€€r%   r`   z?WhisperGenerationMixin._postprocess_outputs.<locals>.<listcomp>   sh   øø€ ð 
ð 
ð 
ð
 ð	ð ð ð ð ð ð à(×.Ò.Ñ0Ô0ðñ ô ð
ð 
ð 
r'   r   rE   )	r   rF   rh   ri   r  rL   r½   r±   r1   )r¯   rò   rí   rw   rÀ   rÙ   rä   rè   Ú	start_idxr³   Úsequence_tokensrp  s   ``   `     @r%   r?  z+WhisperGenerationMixin._postprocess_outputsi  sN  øøøø€ ð &Ô+¨BÔ/ˆ	å�l¥E¤LÑ1Ô1ð 	=Ø    9 : : Ô.°Ð<Ð<à"ð 	¥wÐ/@ÐBSÑ'TÔ'Tð 	Ý Ð!2°LÑAÔAˆJØÐ%Ø'¨$Ñ.�
Ø'¨Ô6�
à/3×/MÒ/MØØ!Ô1Ø%Ø/Ô5°bÔ9ð	 0Nñ 0ô 0ˆLÐ+Ñ,ð	+ð 	+ð 	+ð 	+ð 	+ð 	+ð0 ' {Ô3°A°A°A°y°z°z°MÔBˆð
ð 
ð 
ð 
ð 
ð 
õ
 ˜?Ô0°Ô3Ñ4Ô4ð
ñ 
ô 
ˆð  Ð,Ð,r'   c           
      óÆ  ‡‡‡‡— i }‰d         D �]¬Š‰dv r9t          j        ˆfd„‰D ¦   «         d¬¦  «                             ‰¦  «        |‰<   Œ@‰dv rGt          ˆˆˆfd„t	          t          ‰d         ‰         ¦  «        ¦  «        D ¦   «         ¦  «        |‰<   Œ‹‰dk    r9t          j        ˆfd„‰D ¦   «         d¬¦  «                             ‰¦  «        |‰<   ŒÊ‰d	v rHt          ˆˆˆfd
„t	          t          ‰d         ‰         ¦  «        ¦  «        D ¦   «         ¦  «        |‰<   �Œ‰dk    r�‰d         ‰         �}g }t	          t          ‰d         ‰         ¦  «        ¦  «        D ]1Šˆˆˆˆfd„dD ¦   «         \  }}}	}
|                     |||	|
f¦  «         Œ2t          t          |¦  «        ¦  «        |‰<   �Œ§d |‰<   �Œ®|                     d¦  «        }|�t          } |di |¤ŽS )Nr   )rV   rŽ   rW   c                 ó    •— g | ]
}|‰         ‘ŒS r]   r]   ©rG   rZ  rI  s     €r%   r`   z?WhisperGenerationMixin._stack_split_outputs.<locals>.<listcomp>¯  ó   ø€ Ð+IÐ+IÐ+I°q¨A¨c¬FÐ+IÐ+IÐ+Ir'   rX   r\  c              3   ó‚   •‡K  — | ]8Št          j        ˆˆfd „‰D ¦   «         ¦  «                             ‰¦  «        V — Œ9dS )c                 ó,   •— g | ]}|‰         ‰         ‘ŒS r]   r]   )rG   rZ  r:   rI  s     €€r%   r`   zIWhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>.<listcomp>²  s!   ø€ Ð AÐ AÐ A¨q  3¤¨¤Ð AÐ AÐ Ar'   N)rh   rj   r  ©rG   r:   re   rI  rò   s    @€€€r%   rJ   z>WhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>±  se   øøè è € ð %ð %ØRS•E”KÐ AÐ AÐ AÐ AÐ A°LÐ AÑ AÔ AÑBÔB×EÒEÀfÑMÔMð%ð %ð %ð %ð %ð %r'   Úsequences_scoresc                 ó    •— g | ]
}|‰         ‘ŒS r]   r]   rz  s     €r%   r`   z?WhisperGenerationMixin._stack_split_outputs.<locals>.<listcomp>µ  r{  r'   r`  c           
   3   ó®   •‡K  — | ]NŠt          ˆˆˆˆfd „t          t          ‰d         ‰         d         ¦  «        ¦  «        D ¦   «         ¦  «        V — ŒOdS )c              3   óª   •‡K  — | ]LŠt          j        ˆˆˆfd „‰D ¦   «         ¦  «                             d¦  «                             ‰¦  «        V — ŒMdS )c                 ó8   •— g | ]}|‰         ‰         ‰         ‘ŒS r]   r]   )rG   rZ  r:   r9   rI  s     €€€r%   r`   zSWhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>.<genexpr>.<listcomp>¹  s%   ø€ Ð$HÐ$HÐ$H°a Q s¤V¨A¤Y¨q¤\Ð$HÐ$HÐ$Hr'   r   N©rh   rj   Úsqueezer  )rG   r9   re   r:   rI  rò   s    @€€€€r%   rJ   zHWhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>.<genexpr>¸  s{   øøè è € ð ð àõ œÐ$HÐ$HÐ$HÐ$HÐ$HÐ$H¸<Ð$HÑ$HÔ$HÑIÔI×QÒQÐRSÑTÔT×WÒWÐX^Ñ_Ô_ðð ð ð ð ð r'   r   N)r¢   r1   rk   r~  s    @€€€r%   rJ   z>WhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>·  s—   øøè è € ð %ð %ð
 õ	 ð ð ð ð ð ð ð å!&¥s¨<¸¬?¸3Ô+?ÀÔ+BÑ'CÔ'CÑ!DÔ!Dðñ ô ñ ô ð%ð %ð %ð %ð %ð %r'   rf  c              3   ó¸   •‡‡K  — | ]RŠd D ]MŠt          j        ˆˆˆˆfd„‰D ¦   «         ¦  «                             d¦  «                             ‰¦  «        V — ŒNŒSdS ))rj  rk  c                 ón   •— g | ]1}t          t          |‰         ‰¦  «        j        ‰         ‰¦  «        ‘Œ2S r]   )rL   ri  )rG   Ú
sub_outputrI  rn  Ú	sub_cacheÚsub_keys     €€€€r%   r`   zIWhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>.<listcomp>Ä  sK   ø€ ð !"ð !"ð !"à(2õ %,­G°J¸s´OÀYÑ,OÔ,OÔ,VÐW`Ô,aÐcjÑ$kÔ$kð!"ð !"ð !"r'   r   Nr„  )rG   r‰  rŠ  re   rI  rn  rò   s    @@€€€€r%   rJ   z>WhisperGenerationMixin._stack_split_outputs.<locals>.<genexpr>Â  s¶   øøøè è € ð dð dð !*Ø+=ðdð dð !(õ "œKð!"ð !"ð !"ð !"ð !"ð !"ð !"à6Bð!"ñ !"ô !"ñô ÷ %šW Q™ZœZßšR ™ZœZðdð dð dð dð dð dð dr'   )rh  rl  rW   r]   )
rh   rj   r  r¢   r1   rk   r2   r   r  Údict)r¯   rò   r*  re   r×   rü   rm  Úself_attention_kÚself_attention_vÚcross_attention_kÚcross_attention_vrW   rI  rn  s    ` `        @@r%   r$  z+WhisperGenerationMixin._stack_split_outputsª  s·  øøøø€ àˆØ ”?ð &	(ñ &	(ˆCØÐGÐGÐGÝ$œ{Ð+IÐ+IÐ+IÐ+I¸LÐ+IÑ+IÔ+IÈqÐQÑQÔQ×TÒTÐU[Ñ\Ô\�˜‘�ØÐ[Ð[Ð[Ý$ð %ð %ð %ð %ð %ð %ÝW\Õ]`ÐamÐnoÔapÐqtÔauÑ]vÔ]vÑWwÔWwð%ñ %ô %ñ  ô  �˜‘�ð Ð*Ò*Ð*Ý$œ{Ð+IÐ+IÐ+IÐ+I¸LÐ+IÑ+IÔ+IÈqÐQÑQÔQ×TÒTÐU[Ñ\Ô\�˜‘�ØÐ[Ð[Ð[Ý$ð %ð %ð %ð %ð %ð %õ
 #¥3 |°A¤°sÔ';Ñ#<Ô#<Ñ=Ô=ð%ñ %ô %ñ  ô  �˜‘‘ð Ð)Ò)Ð)Ø ”? 3Ô'Ð3Ø*,Ð'Ý%*­3¨|¸A¬¸sÔ/CÑ+DÔ+DÑ%EÔ%Eð ð ˜	ðdð dð dð dð dð dð dð ._ðdñ dô dÑ`Ð(Ð*:Ð<MÐO`ð ,×2Ò2Ø-Ð/?ÐARÐTeÐfñô ð ð õ $7µuÐ=PÑ7QÔ7QÑ#RÔ#R�G˜C‘L‘Là#'�G˜C‘Lùà"Ÿ;š;Ð'9Ñ:Ô:ÐØÐ'Ý $Ðà Ð Ð+Ð+ 7Ð+Ð+Ð+r'   c                 ó¤  — d}d}	|j         �#|                      ||¦  «        }
|
|j         k    rd}|j        �[t          |d         d¦  «        rd„ |D ¦   «         |         }n%||         d         }|                      |||¦  «        }||j        k     rd}|j        �6t          |t          d¦  «        }||j        k     r||         |j        k    rd}d}	||	fS )NFTr   r  c                 ó   — g | ]
}|d          ‘ŒS )r  r]   )rG   Úss     r%   r`   z9WhisperGenerationMixin._need_fallback.<locals>.<listcomp>ï  s   € ÐHÐHÐH°a˜AÐ0Ô1ÐHÐHÐHr'   rW  Úno_speech_prob)rÌ   Ú_retrieve_compression_ratiorÍ   r  Ú_retrieve_avg_logprobsrÎ   rP   r   )r¯   rñ   rò   r‘   rM   rÀ   rB  rË   rE  r)  Úcompression_ratioÚlogprobsrW  r“  s                 r%   rA  z%WhisperGenerationMixin._need_fallbackÛ  s  € ð ˆØˆØÔ8ÐDØ $× @Ò @ÀÐPZÑ [Ô [Ðà Ð#4Ô#PÒPÐPØ!%�àÔ.Ð:Ý�| A”Ð(:Ñ;Ô;ð ØHÐH¸<ÐHÑHÔHÈÔO��à% eÔ,¨XÔ6�Ø×6Ò6ØØ!Øñô �ð Ð+Ô=Ò=Ð=Ø!%�àÔ0Ð<Ý<Ø Õ":Ð<Lñô ˆNð
 Ð,Ô>Ò>Ð>Ø" 5Ô)Ð,=Ô,QÒQÐQà!&�Ø"�à˜{Ð*Ð*r'   c                 óR  ‡— |j         �Þ|j         dk    rÓt          t          ||j         z  ¦  «        ¦  «        }t          |¦  «        }	ˆfd„t          t          |¦  «        ¦  «        D ¦   «         }
|                     |j         d¬¦  «        }|                     |j         d¬¦  «        }|                     |j         d¬¦  «        }|                     |j         d¬¦  «        }d|_         n9|}	t          t          |	¦  «        ¦  «        }ˆfd„t          |	¦  «        D ¦   «         }
||	|||||
fS )Nr   c                 ó   •— g | ]}‰‘ŒS r]   r]   ©rG   r3  rÊ   s     €r%   r`   zKWhisperGenerationMixin._expand_variables_for_generation.<locals>.<listcomp>  s   ø€ Ð*gÐ*gÐ*gÈÐ+CÐ*gÐ*gÐ*gr'   r   rX   c                 ó   •— g | ]}‰‘ŒS r]   r]   rš  s     €r%   r`   zKWhisperGenerationMixin._expand_variables_for_generation.<locals>.<listcomp>  s   ø€ Ð*\Ð*\Ð*\ÈÐ+CÐ*\Ð*\Ð*\r'   )rû   r¡   r1   rk   Úrepeat_interleave)r¯   r¿   rä   rå   ræ   r·   rÊ   rÀ   rè   rç   rì   s         `    r%   r  z7WhisperGenerationMixin._expand_variables_for_generation	  sN  ø€ ð Ô1Ð=ÐBSÔBhÐklÒBlÐBlÝ ¥ zÐ4EÔ4ZÑ'ZÑ![Ô![Ñ\Ô\ˆMÝ˜-Ñ(Ô(ˆGØ*gÐ*gÐ*gÐ*gÍUÕSVÐWdÑSeÔSeÑMfÔMfÐ*gÑ*gÔ*gÐ'Ø+×=Ò=Ð>OÔ>dÐjkÐ=ÑlÔlˆNØ×)Ò)Ð*;Ô*PÐVWÐ)ÑXÔXˆDØ#×5Ò5Ð6GÔ6\ÐbcÐ5ÑdÔdˆJØ%×7Ò7Ð8IÔ8^ÐdeÐ7ÑfÔfˆKØ56ÐÔ2Ð2à ˆGÝ ¥ w¡¤Ñ0Ô0ˆMØ*\Ð*\Ð*\Ð*\ÍUÐSZÉ^Ì^Ð*\Ñ*\Ô*\Ð'ð ØØØØØØ'ð
ð 	
r'   c                 óŽ   — t          | t          d¦  «        }d„ |                     ¦   «         D ¦   «         } |||dœ|¥¦  «         d S )NÚ
set_inputsc                 óB   — i | ]\  }}t          j        |¦  «        ¯||“ŒS r]   )rh   Ú	is_tensor)rG   rs  rZ  s      r%   rt  zEWhisperGenerationMixin._setup_no_speech_detection.<locals>.<dictcomp>'  s-   € ÐNÐNÐN¡  A½5¼?È1Ñ;MÔ;MÐN˜˜1ÐNÐNÐNr'   )r   Ú	input_ids)rP   r   ru  )rM   rï   rí   r×   rž  Úextra_kwargss         r%   r<  z1WhisperGenerationMixin._setup_no_speech_detection$  sU   € å4Ð5EÕG_ÐamÑnÔnˆ
ØNÐN¨¯ª©¬ÐNÑNÔNˆØˆ
˜mÐ:KÐ\Ð\È|Ð\Ñ]Ô]Ð]Ð]Ð]r'   c                 óü   — | �| j         d         | j         d         fS d|v rNt          |d         t          ¦  «        r|d         d         j         n|d         j         }|d         |d         |z  fS t          d¦  «        ‚)Nr   r   rÞ   r   zPMake sure to provide either `input_features` or `encoder_outputs` to `generate`.)r   rF   r   r   )r¿   rÖ   r×   Úencoder_outputs_shapes       r%   r  z3WhisperGenerationMixin._retrieve_total_input_frames*  s˜   € àÐ%Ø!Ô'¨Ô*¨NÔ,@ÀÔ,DÐDÐDà Ð&Ð&õ ˜fÐ%6Ô7½ÑIÔIð5�Ð(Ô)¨!Ô,Ô2Ð2àÐ-Ô.Ô4ð "ð
 )¨Ô+Ð-BÀ1Ô-EÈÑ-TÐTÐTåÐkÑlÔlÐlr'   c                 ó¦  — d|› d�}| �0t                                |                     d| › �¦  «        ¦  «         |�0t                                |                     d|› �¦  «        ¦  «         |�0t                                |                     d|› �¦  «        ¦  «         |�2t                                |                     d|› �¦  «        ¦  «         d S d S )NzAudio input consists of only z@. Short-form transcription is activated.{}, but will be ignored.z#condition_on_prev_tokens is set to z&compression_ratio_threshold is set to zlogprob_threshold is set to zno_speech_threshold is set to )r%  ÚwarningÚformat)rÊ   rË   rÌ   rÍ   rÎ   rã   Úwarning_prefixs          r%   Ú_maybe_warn_unused_inputsz0WhisperGenerationMixin._maybe_warn_unused_inputs9  s÷   € ð'Ð,>ð 'ð 'ð 'ð 	ð
 $Ð/Ý�NŠN˜>×0Ò0Ð1qÐWoÐ1qÐ1qÑrÔrÑsÔsÐsà&Ð2Ý�NŠNØ×%Ò%Ð&lÐOjÐ&lÐ&lÑmÔmñô ð ð Ð(Ý�NŠN˜>×0Ò0Ð1cÐPaÐ1cÐ1cÑdÔdÑeÔeÐeàÐ*Ý�NŠN˜>×0Ò0Ð1gÐReÐ1gÐ1gÑhÔhÑiÔiÐiÐiÐið +Ð*r'   c                 ó„   — | €|j         } n| |_         ||_        |rd|_         d|_        d|_        |�d|_         d|_        | S )NT)rÓ   rw   Úoutput_attentionsÚoutput_scoresrØ   s       r%   r  z*WhisperGenerationMixin._set_return_outputsU  sg   € à"Ð*Ø&7Ô&OÐ#Ð#à8OÐÔ5à4KÐÔ1Ø"ð 	3Ø8<ÐÔ5Ø26ÐÔ/Ø.2ÐÔ+àÐ(Ø8<ÐÔ5Ø.2ÐÔ+à&Ð&r'   c                 ó>  — |€t          |d¦  «        r|j        }|s/|du rt          d¦  «        ‚t                               d¦  «         d}|rt          |d¦  «        st          d¦  «        ‚||_        t          |d¦  «        r|j        dz   }n| j        j        dz   }|S )	NrÄ   Fa  You have passed more than 3000 mel input features (> 30 seconds) which automatically enables long-form generation which requires the model to predict timestamp tokens. Please either pass `return_timestamps=True` or make sure to pass no more than 3000 mel input features.z:Setting `return_timestamps=True` for long-form generation.TÚno_timestamps_token_idad  You are trying to return timestamps, but the generation config is not properly set. Make sure to initialize the generation config with the correct attributes that are needed such as `no_timestamps_token_id`. For more details on how to generate the approtiate config, refer to https://github.com/huggingface/transformers/issues/21878#issuecomment-1451902363r   )r  rÄ   r   r%  Úinfor®  r™   rB  )r¯   rÄ   rÙ   rÀ   rz   s        r%   r  z-WhisperGenerationMixin._set_return_timestampsh  sá   € ØÐ$­Ð1BÐDWÑ)XÔ)XÐ$Ø 1Ô CÐàð 		%Ø  EÐ)Ð)Ý ðvñô ð õ �KŠKÐTÑUÔUÐUØ $Ðàð 	¥WÐ->Ð@XÑ%YÔ%Yð 	Ýðcñô ð ð /@ÐÔ+åÐ$Ð&>Ñ?Ô?ð 	9Ø/ÔFÈÑJˆOˆOð
 #œkÔ4°qÑ8ˆOàÐr'   c                 óN  — |�&t          |d¦  «        st          d¦  «        ‚||_        t          |d¦  «        r|j        s|€| �t          d¦  «        ‚| �&t          |d¦  «        st          d¦  «        ‚| |_        |�(t          |d¦  «        st          d¦  «        ‚||_        d S d S )NrÇ   züThe generation config is outdated and is thus not compatible with the `is_multilingual` argument to `generate`. Please update the generation config as per the instructions https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224zµCannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=True` to generate, or update the generation config.Ú
lang_to_idzõThe generation config is outdated and is thus not compatible with the `language` argument to `generate`. Please update the generation config as per the instructions https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224Ú
task_to_idzñThe generation config is outdated and is thus not compatible with the `task` argument to `generate`. Please update the generation config as per the instructions https://github.com/huggingface/transformers/issues/25084#issuecomment-1664398224)r  r   rÇ   rÆ   rÅ   rÚ   s       r%   r	  z-WhisperGenerationMixin._set_language_and_task‹  s
  € àÐ&ÝÐ,Ð.?Ñ@Ô@ð Ý ðgñô ð ð
 1@ÐÔ-åÐ$Ð&7Ñ8Ô8ð 	ÐARÔAbð 	ØÐ 8Ð#7Ý ðnñô ð ð
 ÐÝÐ,¨lÑ;Ô;ð Ý ðgñô ð ð
 *2ÐÔ&àÐÝÐ,¨lÑ;Ô;ð Ý ðgñô ð ð
 &*ÐÔ"Ð"Ð"ð Ðr'   c                 óv
  ‡‡‡‡— dt           t                   dt          dt          t                   fd„}dt          dt          fˆfd„Št	          ‰dd ¦  «        }t	          ‰dd ¦  «        }	‰j        gŠ|�€*|	�€'t	          ‰d	d ¦  «        }
|
€t	          |d	d ¦  «        �|j        }
|
�út                               d
¦  «         |
�(|
d         d         €t                               d¦  «         |
�´|
d         d         dk    r¢dŠt          |
¦  «        dk    rX|
d         d         ‰k    rF‰|
d         d         gz  Š|
dd …         }
‰dz  Št          |
¦  «        dk    r|
d         d         ‰k    °Ft          |
¦  «        dk    r"t          d|
› d|
d         d         › d�¦  «        ‚t          ‰¦  «        dk    pt          ‰¦  «        dk    o	‰d         d u }t          |	t           t          f¦  «        rat          d„ |	D ¦   «         ¦  «        rt          d¦  «        ‚t          |	¦  «        |k    r#t          d|› dt          |	¦  «        › d�¦  «        ‚|	}n|	€d g|z  }n|	g}ˆfd„|D ¦   «         Šd }|	�ˆfd„|D ¦   «         }nQt          ‰d¦  «        rA|r?|                      ||                     dd ¦  «        ‰|¬¦  «                             ¦   «         }|�kt'          t          ‰¦  «        ¦  «        D ]NŠt          ‰‰         ¦  «        dk    r|‰         ‰‰         d<   Œ-‰‰                              |‰         ¦  «         ŒO~t'          t          ‰¦  «        ¦  «        D �]«Š|�Œ|t*          v rh‰‰                              ‰j        ‰j                 ¦  «         ‰j        ‰j                 } |‰‰         |‰j                             ¦   «         ¦  «         n†t          d|› dt*          › d�¦  «        ‚|	�it          ‰d¦  «        rYt          ˆˆfd„‰j                             ¦   «         D ¦   «         ¦  «        s&‰‰                              ‰j        d          ¦  «         ‰j        sHt          ‰d!¦  «        r8‰‰         d"         ‰j        k    r!‰‰                              ‰j        ¦  «         nK‰j        rD‰‰         d"         ‰j        k    r-t                               d#¦  «         ‰‰         d d"…         ‰‰<   d$„ ‰‰         D ¦   «         ‰‰<   �Œ­t9          j        ‰t8          j        | j        ¬%¦  «                              |d"¦  «        S )&NÚlstÚnumÚitrc                 ó�   ‡ ‡‡— t          ˆ fd„‰D ¦   «         ¦  «        }|rˆˆfd„‰ D ¦   «         Š n‰                      ‰¦  «         ‰ S )z/short function to replace num with a itr in lstc              3   ó    •K  — | ]}|‰v V — Œ	d S rE   r]   )rG   r:   r´  s     €r%   rJ   zWWhisperGenerationMixin._retrieve_init_tokens.<locals>.replace_or_add.<locals>.<genexpr>²  s'   øè è € Ð.Ð. Q˜˜S˜Ð.Ð.Ð.Ð.Ð.Ð.r'   c                 ó    •— g | ]
}|‰v r‰n|‘ŒS r]   r]   )rG   r:   r¶  rµ  s     €€r%   r`   zXWhisperGenerationMixin._retrieve_init_tokens.<locals>.replace_or_add.<locals>.<listcomp>´  s%   ø€ Ð;Ð;Ð;°!˜a 3˜h˜h�s�s¨AÐ;Ð;Ð;r'   )r  r2   )r´  rµ  r¶  Úfounds   ``` r%   Úreplace_or_addzDWhisperGenerationMixin._retrieve_init_tokens.<locals>.replace_or_add°  sa   øøø€ åÐ.Ð.Ð.Ð.¨#Ð.Ñ.Ô.Ñ.Ô.ˆEØð  Ø;Ð;Ð;Ð;Ð;°sÐ;Ñ;Ô;��à—
’
˜3‘”�ØˆJr'   rÆ   r   c           	      óÔ  •— |                       ¦   «         } | ‰j        v r| }n | t          v rdt          |          › d�}n…| t          j        ¦   «         v rd| › d�}nit	          | ¦  «        dk    }t          d| › d|r t          t          j        ¦   «         ¦  «        nt          t          j        ¦   «         ¦  «        › d�¦  «        ‚|‰j        vrt          |› d�¦  «        ‚‰j        |         S )Nz<|z|>r   zUnsupported language: z. Language should be one of: ú.zŽ is not supported by this specific model as it is not in the `generation_config.lang_to_id`. (You should just add it to the generation config))Úlowerr±  r   rk  rk   r   r¡   rj  )rÆ   Úlanguage_tokenÚis_language_coderÀ   s      €r%   Úlanguage_to_idzDWhisperGenerationMixin._retrieve_init_tokens.<locals>.language_to_id¹  s6  ø€ Ø—~’~Ñ'Ô'ˆHØÐ,Ô7Ð7Ð7Ø!)��ØÕ-Ð-Ð-Ø!DÕ&6°xÔ&@Ð!DÐ!DÐ!D��ØÕ-Ô4Ñ6Ô6Ð6Ð6Ø!2 hÐ!2Ð!2Ð!2��å#& x¡=¤=°AÒ#5Ð Ý ðr¨Xð rð rØ;KÐn�Õ-Ô4Ñ6Ô6Ñ7Ô7Ð7ÕQUÕVfÔVkÑVmÔVmÑQnÔQnðrð rð rñô ð ð Ð%6Ô%AÐAÐAÝ Ø%ð hð hð hñô ð ð
 %Ô/°Ô?Ð?r'   rÅ   Úforced_decoder_idszŽUsing custom `forced_decoder_ids` from the (generation) config. This is deprecated in favor of the `task` and `language` flags/config options.r   r   al  Transcription using a multilingual Whisper will default to language detection followed by transcription instead of translation to English. This might be a breaking change for your use case. If you want to instead always translate your audio to English, make sure to pass `language='en'`. See https://github.com/huggingface/transformers/pull/28687 for more details.zƒYou are using token ids in `forced_decoder_ids` that do not seem to correctly follow the prompt pattern of Whisper. Make sure that z) has an entry for all indices >= 1 and < r½  c              3   ó   K  — | ]}|d u V — Œ	d S rE   r]   )rG   r‹   s     r%   rJ   z?WhisperGenerationMixin._retrieve_init_tokens.<locals>.<genexpr>ý  s&   è è € Ð/Ð/ �1˜�9Ð/Ð/Ð/Ð/Ð/Ð/r'   zÄExpected `language` to be `None`, a single string (e.g. `'en'`), or a list of strings with length equal to the batch size (e.g. `('en', 'fr')` for a batch size of 2). Got a list containing `None`.zgWhen passing a list of languages, the length of the list must match the batch size. Expected length of z
, but got z languages.c                 ó8   •— g | ]}t          j         ‰¦  «        ‘ŒS r]   )r;  )rG   r3  ræ   s     €r%   r`   z@WhisperGenerationMixin._retrieve_init_tokens.<locals>.<listcomp>  s#   ø€ ÐAÐAÐA°!•t”y Ñ-Ô-ÐAÐAÐAr'   c                 ó&   •— g | ]} ‰|¦  «        ‘ŒS r]   r]   )rG   r‹   rÁ  s     €r%   r`   z@WhisperGenerationMixin._retrieve_init_tokens.<locals>.<listcomp>  s#   ø€ Ð=Ð=Ð=¨a˜˜ qÑ)Ô)Ð=Ð=Ð=r'   r±  rÞ   )r¿   rÞ   rÀ   rÏ   zThe `z4` task is not supported. The task should be one of `ú`r²  c              3   ó,   •K  — | ]}|‰‰         v V — Œd S rE   r]   )rG   Útir:   ræ   s     €€r%   rJ   z?WhisperGenerationMixin._retrieve_init_tokens.<locals>.<genexpr>4  s,   øè è € Ð`Ð`°B˜2 ¨Q¤Ð/Ð`Ð`Ð`Ð`Ð`Ð`r'   Ú
transcriber®  r   zm<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `'True'`.c                 ó   — g | ]}|®|‘ŒS rE   r]   )rG   r?   s     r%   r`   z@WhisperGenerationMixin._retrieve_init_tokens.<locals>.<listcomp>F  s   € ÐIÐIÐI A¸1¸=˜a¸=¸=¸=r'   r•   )!r¡   r    r   ÚstrrL   Údecoder_start_token_idrÂ  r%  r&  rk   r   rF   r¢   r  Ú	TypeErrorr  Údetect_languager  Útolistr1   r2   r   r²  rÅ   rk  rÄ   r®  r¯  rh   Ú	as_tensorr�   re   Úexpand)r¯   r¿   r·   rÀ   r™   rÏ   r×   r»  rÅ   rÆ   rÂ  Úis_lang_id_undefinedÚ	languagesÚlang_idsÚtask_idr:   ræ   rÁ  s      `           @@@r%   r  z,WhisperGenerationMixin._retrieve_init_tokens¯  s  øøøø€ ð	¥¥S¤	ð 	µð 	½(Å3¼-ð 	ð 	ð 	ð 	ð	@¥Sð 	@­Sð 	@ð 	@ð 	@ð 	@ð 	@ð 	@õ, Ð(¨&°$Ñ7Ô7ˆÝÐ,¨j¸$Ñ?Ô?ˆØ(Ô?Ð@ˆð ‰<˜HÑ,Ý!(Ð):Ð<PÐRVÑ!WÔ!WÐà!Ð)­g°fÐ>RÐTXÑ.YÔ.YÐ.eØ%+Ô%>Ð"à!Ð-Ý×#Ò#ðFñô ð ð
 &Ð1Ð6HÈÔ6KÈAÔ6NÐ6VÝ×'Ò'ðxñô ð ð &Ð1Ð6HÈÔ6KÈAÔ6NÐRSÒ6SÐ6SØ�AÝÐ0Ñ1Ô1°AÒ5Ð5Ð:LÈQÔ:OÐPQÔ:RÐVWÒ:WÐ:WØ#Ð(:¸1Ô(=¸aÔ(@Ð'AÑA˜Ø-?ÀÀÀÔ-CÐ*Ø˜Q™˜õ Ð0Ñ1Ô1°AÒ5Ð5Ð:LÈQÔ:OÐPQÔ:RÐVWÒ:WÐ:Wõ
 Ð-Ñ.Ô.°Ò2Ð2Ý(ðNØM_ðNð Nà2DÀQÔ2GÈÔ2JðNð Nð Nñô ð õ  # ;Ñ/Ô/°1Ò4Ði½¸[Ñ9IÔ9IÈAÒ9MÐ9hÐR]Ð^_ÔR`ÐdhÐRhÐõ �h¥¥u Ñ.Ô.ð 	#ÝÐ/Ð/ hÐ/Ñ/Ô/Ñ/Ô/ð Ýð)ñô ð õ
 �8‰}Œ} 
Ò*Ð*Ý ð[Ø*4ð[ð [Ý@CÀHÁÄð[ð [ð [ñô ð ð !ˆIˆIØÐà˜ Ñ+ˆIˆIà!˜
ˆIð BÐAÐAÐA°yÐAÑAÔAˆð ˆØÐØ=Ð=Ð=Ð=°9Ð=Ñ=Ô=ˆHˆHÝÐ&¨Ñ5Ô5ð 	Ð:Nð 	à×+Ò+Ø-Ø &§
¢
Ð+<¸dÑ CÔ CØ"3Ø#5ð	 ,ñ ô ÷
 Šf‰hŒhð ð Ðå�3˜{Ñ+Ô+Ñ,Ô,ð 7ð 7�Ý�{ 1”~Ñ&Ô&¨Ò*Ð*Ø(0°¬�K ”N 1Ñ%Ð%à ”N×)Ò)¨(°1¬+Ñ6Ô6Ð6Ð6Øõ •s˜;Ñ'Ô'Ñ(Ô(ð 	Jñ 	JˆAØÐØ�8Ð#Ð#Ø ”N×)Ò)Ð*;Ô*FÐGXÔG]Ô*^Ñ_Ô_Ð_Ø/Ô:Ð;LÔ;QÔR�Gð #�N ;¨q¤>°7Ð<MÔ<X×<_Ò<_Ñ<aÔ<aÑbÔbÐbÐbå$Ð%r¨TÐ%rÐ%rÕgoÐ%rÐ%rÐ%rÑsÔsÐsØÐ%­'Ð2CÀ\Ñ*RÔ*RÐ%åÐ`Ð`Ð`Ð`Ð`Ð:KÔ:V×:]Ò:]Ñ:_Ô:_Ð`Ñ`Ô`Ñ`Ô`ð VØ ”N×)Ò)Ð*;Ô*FÀ|Ô*TÑUÔUÐUð &Ô7ð5åÐ-Ð/GÑHÔHð5ð   ”N 2Ô&Ð*;Ô*RÒRÐRà˜A”×%Ò%Ð&7Ô&NÑOÔOÐOÐOà!Ô3ð5Ø8CÀA¼ÀrÔ8JÐN_ÔNvÒ8vÐ8vå—’ð Dñô ð ð "-¨Q¤°°°Ô!4�˜A‘ð JÐI¨°Q¬ÐIÑIÔIˆK˜‰N‰NåŒ˜{µ%´*ÀTÄ[ÐQÑQÔQ×XÒXÐYcÐegÑhÔhÐhr'   é¸  rÞ   r   c                 óô  — |€|€t          d¦  «        ‚|�|�t          d¦  «        ‚|�!d|dd…dd…d|…f         i}|j        d         }n6|�4d|i}t          |t          ¦  «        r|d         j        d         n|d         }|p| j        }t          j        |df| j        t
          j        ¬¦  «        |j	        z  }t          j
        ¦   «         5   | di |¤|d	d
œ¤Žj        dd…df         }ddd¦  «         n# 1 swxY w Y   t          j        |d         t
          j        ¬¦  «        }	d	|	t          |j                             ¦   «         ¦  «        <   t"          j         |dd…|	f<   |                     d¦  «        }
|
S )a£  
        Detects language from log-mel input features or encoder_outputs

        Parameters:
            input_features (`torch.Tensor` of shape `(batch_size, feature_size, sequence_length)`, *optional*):
                Float values of log-mel features extracted from the raw speech waveform. The raw speech waveform can be obtained by
                loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a `numpy.ndarray` or a `torch.Tensor`, *e.g.* via
                the soundfile library (`pip install soundfile`). To prepare the array into `input_features`, the
                [`AutoFeatureExtractor`] should be used for extracting the mel features, padding and conversion into a
                tensor of type `torch.FloatTensor`. See [`~WhisperFeatureExtractor.__call__`] for details.
            encoder_outputs (`tuple(tuple(torch.FloatTensor)`, *optional*):
                Tuple consists of (`last_hidden_state`, *optional*: `hidden_states`, *optional*: `attentions`)
                `last_hidden_state` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) is a sequence of
                hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.
            generation_config (`~generation.GenerationConfig`, *optional*):
                The generation configuration to be used as base parametrization for the generation call. `**kwargs`
                passed to generate matching the attributes of `generation_config` will override them. If
                `generation_config` is not provided, the default will be used, which had the following loading
                priority: 1) from the `generation_config.json` model file, if it exists; 2) from the model
                configuration. Please note that unspecified parameters will inherit [`~generation.GenerationConfig`]'s
                default values, whose documentation should be checked to parameterize generation.
            num_segment_frames (`int`, *optional*, defaults to 3000):
                The number of log-mel frames the model expects

        Return:
            A `torch.LongTensor` representing the detected language ids.
        Nz@You have to specify either `input_features` or `encoder_outputs`zRMake sure to specify only one of `input_features` or `encoder_outputs` - not both!r¿   r   rÞ   r   r�   F)rí   Ú	use_cacher   r*   r]   )r   r   rF   r   rÀ   rh   r.   re   r�   rÌ  Úno_gradr]  rm   r®   r¡   r±  rk  r-   r0   Úargmax)r¯   r¿   rÞ   rÀ   rÏ   r   r·   rí   r]  Únon_lang_maskrÔ  s              r%   rÎ  z&WhisperGenerationMixin.detect_languageJ  s  € ðD Ð! oÐ&=ÝÐ_Ñ`Ô`Ð`ØÐ'¨OÐ,GÝÐqÑrÔrÐrØÐ'Ø&¨°q°q°q¸!¸!¸!Ð=PÐ>PÐ=PÐ7PÔ(QÐRˆFØ'Ô-¨aÔ0ˆJˆJØÐ(Ø'¨Ð9ˆFå/9¸/Í?Ñ/[Ô/[Ðs� Ô"Ô(¨Ô+Ð+ÐapÐqrÔasð ð .ÐG°Ô1GÐåŒJ˜
 A�¨t¬{Å%Ä*ÐMÑMÔMØÔ6ñ7ð 	õ
 Œ]‰_Œ_ð 	hð 	hØ�TÐYÐY˜FÐYÐ6GÐSXÐYÐYÐYÐYÔ`ÐabÐabÐabÐdfÐafÔgˆFð	hð 	hð 	hñ 	hô 	hð 	hð 	hð 	hð 	hð 	hð 	høøøð 	hð 	hð 	hð 	hõ œ¨¨q¬	½¼ÐDÑDÔDˆØEJˆ•dÐ,Ô7×>Ò>Ñ@Ô@ÑAÔAÑBå$&¤F 7ˆˆqˆqˆq�-ÐÑ à—=’= Ñ$Ô$ˆàˆs   ÃC5Ã5C9Ã<C9c                 óˆ   — |                       dd ¦  «        }|                       dd ¦  «        }|�|�t          d¦  «        ‚d S d S )Nrí   rà   zQPassing `decoder_input_ids` is deprecated. Consider passing `prompt_ids` instead.)r  r   )r×   rí   rà   s      r%   r  z/WhisperGenerationMixin._check_decoder_input_ids‹  sY   € à"ŸJšJÐ':¸DÑAÔAÐØ Ÿ*š*Ð%6¸Ñ=Ô=ˆØÐ(¨_Ð-HÝØcñô ð ð )Ð(Ð-HÐ-Hr'   c                 óL  — | r¡t          |dd ¦  «        dk    rt                               d¦  «         t          |d¦  «        st	          d¦  «        ‚|�.|                     d¦  «                             ¦   «         |_        d S t                               d¦  «         d |_        d S d S )NrÅ   Ú	translatez@Token-level timestamps may not be reliable for task 'translate'.r±   zÓModel generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.r   zâWhen setting `return_token_timestamps` to `True`, make sure to pass an `attention_mask` to get precise token-level timestamps. You can retrieve the `attention_mask` by doing `processor(audio, ..., return_attention_mask=True)` )	rL   r%  r¦  r  r   rœ   r¥   r³   r&  rÛ   s       r%   r
  z&WhisperGenerationMixin._set_num_frames”  sË   € à"ð 	4ÝÐ(¨&°$Ñ7Ô7¸;ÒFÐFÝ—’ÐaÑbÔbÐbÝÐ,Ð.?Ñ@Ô@ð Ý ðRñô ð ð Ð)Ø/=×/AÒ/AÀ"Ñ/EÔ/E×/IÒ/IÑ/KÔ/KÐ!Ô,Ð,Ð,å×#Ò#ð yñô ð ð 04Ð!Ô,Ð,Ð,ð	4ð 	4r'   c                 óÖ   — |�|nt          | dd ¦  «        | _        |�|nt          | dd ¦  «        | _        |�|nt          | dd ¦  «        | _        |�|nt          | dd ¦  «        | _        d S )NrÍ   rÌ   rÎ   rÊ   )rL   rÍ   rÌ   rÎ   rÊ   rÜ   s        r%   r  z4WhisperGenerationMixin._set_thresholds_and_condition¦  s¬   € ð !Ð,ð ÐåÐ*Ð,?ÀÑFÔFð 	Ô+ð +Ð6ð (Ð'åÐ*Ð,IÈ4ÑPÔPð 	Ô5ð #Ð.ð  ÐåÐ*Ð,AÀ4ÑHÔHð 	Ô-ð (Ð3ð %Ð$åÐ*Ð,FÈÑMÔMð 	Ô2Ð2Ð2r'   c                 óÄ   — ddg}|p|d         }||vr(t          d|› dd                     |¦  «        › �¦  «        ‚| j        dur|dk    rt          d¦  «        ‚|| _        d S )	Nrö   úall-segmentsr   z`prompt_condition_type=zD does not exist. Make sure to set `prompt_condition_type` to one of r,   TzeMake sure to set `condition_on_prev_tokens=True` when setting `prompt_condition_type='all-segments'`.)r   ÚjoinrÊ   rÉ   )rÀ   rÉ   Úallowed_cond_typess      r%   r  z1WhisperGenerationMixin._set_prompt_condition_typeÃ  sÌ   € à-¨~Ð>Ðð !6Ð NÐ9KÈAÔ9NÐà Ð(:Ð:Ð:Ýð eÐ*?ð  eð  eð  FJ÷  FOò  FOð  Pbñ  Fcô  Fcð  eð  eñô ð ð Ô5¸TÐAÐAÐF[Ð_mÒFmÐFmÝØwñô ð ð 3HÐÔ/Ð/Ð/r'   c                 ó>   — | �| nt          |dd¦  «        } | |_        d S )NrÊ   F)rL   rÊ   râ   s     r%   r  z4WhisperGenerationMixin._set_condition_on_prev_tokensÖ  s:   € ð (Ð3ð %Ð$åÐ*Ð,FÈÑNÔNð 	!ð
 6NÐÔ2Ð2Ð2r'   c                 ó¢  — | dk    r|s|€t          d¦  «        ‚| dk    rh|sf|                     d¦  «                             ¦   «                              t          j        ¦  «        }t	          j        | ft          j        ¬¦  «        }nEt	          j        | ft          j        ¬¦  «        |z  }t	          j        | ft          j        ¬¦  «        }||fS )Nr   z¼When doing batched long-form audio transcription, make sure to pass an `attention_mask`. You can retrieve the `attention_mask` by doing `processor(audio, ..., return_attention_mask=True)` r   r*   )r   rœ   r¥   r  rh   r�   rŸ   r.   )r·   rÐ   rã   rÙ   rå   rä   s         r%   r  z4WhisperGenerationMixin._retrieve_max_frames_and_seekß  sÅ   € à˜Š>ˆ> ,ˆ>°>Ð3IÝð Oñô ð ð ˜!Š^ˆ^ Lˆ^Ø'×+Ò+¨BÑ/Ô/×3Ò3Ñ5Ô5×8Ò8½¼ÑDÔDˆJÝ”; 
˜}µE´JÐ?Ñ?Ô?ˆDˆDåœ Z M½¼ÐDÑDÔDÐGYÑYˆJÝ”; 
˜}µE´JÐ?Ñ?Ô?ˆDà˜4ÐÐr'   c                 ó˜  — |j         du rt          ||¬¦  «        }|€|gn|g|z   }|j        �(t          |j        |¬¦  «        }|€|gn|g|z   }d |_        |j        �)t          |j        ||¬¦  «        }|€|gn|g|z   }d |_        |j        �>t          |j        dz
  ||dk    ¬¦  «        }	|€|	gn|	g|z   }|	 	                    | ¦  «         |S )NT)rá   rd   )rá   re   r   )Úno_speech_tokenrá   Úscores_is_logprobs)
rÄ   r   rë   r   r  r   rÎ   r   r®  Ú	set_model)
r¯   rÀ   rM   rá   rß   re   Útimestamp_processorÚsuppress_tokens_processorÚbegin_suppress_processorÚno_speech_detectors
             r%   r  z1WhisperGenerationMixin._retrieve_logit_processorsî  s`  € ØÔ.°$Ð6Ð6Ý"AÐBSÐalÐ"mÑ"mÔ"mÐà)9Ð)AÐ$Ð%Ð%ÐH[ÐG\Ð_oÑGoð ð Ô,Ð8Ý(EÐFWÔFgÐpvÐ(wÑ(wÔ(wÐ%ð $Ð+ð +Ð+Ð+à/Ð0Ð3CÑCð ð
 15ÐÔ-àÔ2Ð>Ý'KØ!Ô7À[ÐY_ð(ñ (ô (Ð$ð
 $Ð+ð *Ð*Ð*à.Ð/Ð2BÑBð ð
 7;ÐÔ3àÔ0Ð<Ý!9Ø 1Ô HÈ1Ñ LØ'Ø#,¨q¢=ð"ñ "ô "Ðð )9Ð(@Ð#Ð$Ð$ÐGYÐFZÐ]mÑFmð ð ×(Ò(¨Ñ.Ô.Ð.àÐr'   c                 ó  — |}g }t          |¦  «        D ]j}||         }||         ||         k    r9|||z
  z   }	|dz  }t          j        | d |	…         | |	dz   d …         gd¬¦  «        } ŒU|                     |¦  «         Œk| ||fS )Nr   r   rX   )r1   rh   rl   r2   )
r¿   rä   rå   rç   rè   Úprev_bszÚnew_batch_idx_mapr:   r+  Ú	cut_indexs
             r%   r  z*WhisperGenerationMixin._maybe_reduce_batch  s¶   € àˆØÐÝ�x‘”ð 	1ð 	1ˆAØ" 1Ô%ˆFØ�FŒ|˜z¨&Ô1Ò1Ð1Ø ¨8Ñ!3Ñ4�	Ø˜1‘�Ý!&¤¨N¸:¸I¸:Ô,FÈÐW`ÐcdÑWdÐWfÐWfÔHgÐ+hÐnoÐ!pÑ!pÔ!p��ð "×(Ò(¨Ñ0Ô0Ð0Ð0à˜wÐ(9Ð9Ð9r'   c                 ó\  — | €d S g }t          |¦  «        D ]}||         }| ||dz   …d d …||         ||         ||         z   …f         }	|	j        d         |k     r&t          j        |	d||	j        d         z
  f¬¦  «        }	|                     |	¦  «         Œ€t          j        |d¬¦  «        }|S )Nr   r   r   )r    rX   )r1   r   rp   r    r2   rh   rl   )
r¿   rä   rê   rÏ   rç   rè   rï   r:   r+  Úsegment_input_slices
             r%   r  z)WhisperGenerationMixin._get_input_segment&  sâ   € àÐ!Ø�4àˆÝ�w‘”ð 
	6ð 
	6ˆAØ" 1Ô%ˆFØ"0°°Q¸±U°¸A¸A¸A¸tÀF¼|ÈdÐSYÌlÐ]lÐmsÔ]tÑNtÐ?tÐ1tÔ"uÐà"Ô(¨Ô,Ð/AÒAÐAå&'¤eØ'¨aÐ1CÐFYÔF_Ð`bÔFcÑ1cÐ-dð'ñ 'ô 'Ð#ð × Ò Ð!4Ñ5Ô5Ð5Ð5åœ	 -°QÐ7Ñ7Ô7ˆàÐr'   c                 óL  ‡‡— d|v r|                      d¦  «        }||fS |j        dz  dz
  }||         }t          |dd ¦  «        }|€ |	�t          |	¦  «        dk    r	|	d         }nd }t	          ‰¦  «        r½t          ‰d         ¦  «        dk    r¤ˆˆfd„|D ¦   «         }|�|j        dk    r|}n2t          j        | df|t          j        ¬	¦  «        }|�||d         z  nd }|j	        d
k    rdnd}t          ||j        |d|||d|
¬¦	  «	        }t          j        ||gd¬¦  «        }||j        k    |d<   nn|�V|d                               |j        d         d¦  «        }t          j        ||gd¬¦  «        }|                      dd ¦  «         n|                      dd ¦  «         ||fS )Nrí   r   r   rR  ra   r   c                 ó4   •— g | ]}‰|         r‰|         nd ‘ŒS rE   r]   )rG   r:   rq   rì   s     €€r%   r`   zEWhisperGenerationMixin._prepare_decoder_input_ids.<locals>.<listcomp>]  s2   ø€ ÐvÐvÐvÐcdÐ6QÐRSÔ6TÐ^Ð/°Ô2Ð2ÐZ^ÐvÐvÐvr'   rá  r�   r9  rU   rR   rT   T)re   rs   rt   ru   rv   ry   rz   r   rX   r:  )ÚpopÚmax_target_positionsrL   rk   r  rÉ   rh   r.   r�   r=  rƒ   rr   rl   r¦   r   )rç   ræ   rq   rè   rì   rÈ   rÀ   r™   re   rë   rz   r×   rí   rv   Úprev_start_of_textÚactive_segmentsÚprev_idsÚ
one_tensorrt   Úprev_tokenss     ` `               r%   r  z1WhisperGenerationMixin._prepare_decoder_input_ids<  s(  øø€ ð  &Ð(Ð(Ø &§
¢
Ð+>Ñ ?Ô ?Ðà$ fÐ,Ð,àÔ4¸Ñ9¸AÑ=ˆà'¨Ô6Ðå$Ð%6Ð8KÈTÑRÔRÐØÐ%ØÐ*­s°?Ñ/CÔ/CÀqÒ/HÐ/HØ%4°RÔ%8Ð"Ð"à%)Ð"åÐ*Ñ+Ô+ð !	7µÐ4DÀQÔ4GÑ0HÔ0HÈ1Ò0LÐ0LàvÐvÐvÐvÐvÐhuÐvÑvÔvˆOàÐ%Ð*;Ô*QÐUcÒ*cÐ*cØ%��å"œZ¨°!¨¸VÍ5Ì:ÐVÑVÔV�
ØASÐA_Ð-°
¸1´Ñ=Ð=Ðei�à&7Ô&LÐPXÒ&XÐ&X�l�lÐ^gˆGå,ØØ!Ô.ØØ#ØØ!)Ø-Ø.2Ø /ð
ñ 
ô 
ˆKõ !&¤	¨;Ð8IÐ*JÐPRÐ SÑ SÔ SÐà/@ÐDUÔDbÒ/bˆFÐ+Ñ,Ð,ØÐ#Ø$ TÔ*×1Ò1Ð2CÔ2IÈ!Ô2LÈaÑPÔPˆKÝ %¤	¨;Ð8IÐ*JÐPRÐ SÑ SÔ SÐà�JŠJÐ/°Ñ6Ô6Ð6Ð6ð �JŠJÐ/°Ñ6Ô6Ð6à  &Ð(Ð(r'   c                 ó|  — |j         �|j         nd}||j        d         z   | j        j        k    rLt	          d|j        d         › d|› d||j        d         z   › d| j        j        › d| j        j        › d�¦  «        ‚t          |j        d	z  d
z
  |j        d         d
z
  ¦  «        }|j        �L|j         €Et          |j        |z   |j        ¦  «        }t                               d|j        › d|› d�¦  «         d S |j         �<|j         |j        d         z   |j        k    r |j        |j        d         z
  }||_         d S d S d S )Nr   r   zjThe length of `decoder_input_ids`, including special start tokens, prompt tokens, and previous tokens, is z,  and `max_new_tokens` is zL. Thus, the combined length of `decoder_input_ids` and `max_new_tokens` is: z@. This exceeds the `max_target_positions` of the Whisper model: zŠ. You should either reduce the length of your prompt, or reduce the value of `max_new_tokens`, so that their combined length is less than r½  r   r   zIncrease max_length from z to z0 since input is conditioned on previous segment.)	Úmax_new_tokensr   r™   r÷  r   ÚminrU   r%  r¯  )r¯   r™   rí   rÀ   rþ  Únum_initial_tokensrU   s          r%   r   z5WhisperGenerationMixin._set_max_new_tokens_and_length€  sä  € Ø=NÔ=]Ð=iÐ*Ô9Ð9ÐopˆØÐ-Ô3°BÔ7Ñ7¸$¼+Ô:ZÒZÐZÝðbð  ~Oô  ~Uð  VXô  ~Yð bð bØ,:ðbð bà@NÐQbÔQhÐikÔQlÑ@lðbð bð AEÄÔ@`ðbð bð
 ?C¼kÔ>^ðbð bð bñô ð õ ! Ô!<ÀÑ!AÀAÑ!EÐGXÔG^Ð_aÔGbÐefÑGfÑgÔgÐð Ô'Ð3Ð8IÔ8XÐ8`ÝÐ.Ô9Ð<NÑNÐPVÔPkÑlÔlˆJÝ�KŠKð KÐ,=Ô,Hð  Kð  KÈjð  Kð  Kð  Kñô ð ð ð ð Ô,Ð8Ø!Ô0Ð3DÔ3JÈ2Ô3NÑNÐQWÔQlÒlÐlà#Ô8Ð;LÔ;RÐSUÔ;VÑVˆNØ/=ÐÔ,Ð,Ð,ð	 9Ð8ØlÐlr'   c                 ó  ‡— t          t          j        |¦  «        dz  ¦  «        dz   Šd                     ˆfd„|                      ¦   «         D ¦   «         ¦  «        }t          |¦  «        t          t          j        |¦  «        ¦  «        z  }|S )zUCompute byte length of zlib compressed token bytes vs. byte length of raw token bytesé   r   r'   c                 ó<   •— g | ]}|                      ‰d ¦  «        ‘ŒS )Úlittle)Úto_bytes)rG   r?   Úlengths     €r%   r`   zFWhisperGenerationMixin._retrieve_compression_ratio.<locals>.<listcomp>Ÿ  s'   ø€ ÐVÐVÐVÀ §
¢
¨6°8Ñ <Ô <ÐVÐVÐVr'   )r    ÚmathÚlog2râ  rÏ  rk   ÚzlibÚcompress)r\   rB  Útoken_bytesr–  r  s       @r%   r”  z2WhisperGenerationMixin._retrieve_compression_ratio›  s   ø€ õ •T”Y˜zÑ*Ô*¨QÑ.Ñ/Ô/°!Ñ3ˆØ—h’hÐVÐVÐVÐVÀfÇmÂmÁoÄoÐVÑVÔVÑWÔWˆÝ Ñ,Ô,­sµ4´=ÀÑ3MÔ3MÑ/NÔ/NÑNÐà Ð r'   c                 ó  ‡‡— |dk    r|nd}t          j        | ¦  «                             ‰j        ¦  «        } | j        d         ‰j        d         k    r| d ‰j        d         …         } n‰| j        d          d …         Št          j        | |z                       ¦   «         d¬¦  «                             | j        ¦  «        Št          ˆˆfd„t          ‰j        d         ¦  «        D ¦   «         ¦  «        }|t          ‰¦  «        z  }|S )Nrf   r   r   r   rX   c              3   ó@   •K  — | ]}‰|         ‰|                  V — Œd S rE   r]   )rG   r:   r—  r\   s     €€r%   rJ   z@WhisperGenerationMixin._retrieve_avg_logprobs.<locals>.<genexpr>²  s0   øè è € ÐTÐT°a˜8 Aœ; v¨a¤yÔ1ÐTÐTÐTÐTÐTÐTr'   )rh   rj   r  re   r   rp   Úlog_softmaxÚfloatr+   rœ   r1   rk   )rW  r\   rË   Úrescale_temperatureÚsum_logprobsÚavg_logprobsr—  s    `    @r%   r•  z-WhisperGenerationMixin._retrieve_avg_logprobs¤  s  øø€ à-8¸3Ò->Ð->˜k˜kÀAÐÝ”˜VÑ$Ô$×'Ò'¨¬Ñ6Ô6ˆàŒ<˜Œ?˜Vœ\¨!œ_Ò,Ð,ØÐ-˜fœl¨1œoÐ-Ô.ˆFˆFà˜Vœ\¨!œ_Ð,Ð.Ð.Ô/ˆFå”= &Ð+>Ñ">×!EÒ!EÑ!GÔ!GÈRÐPÑPÔP×SÒSÐTZÔT`ÑaÔaˆõ ÐTÐTÐTÐTÐT½5ÀÄÐPQÔARÑ;SÔ;SÐTÑTÔTÑTÔTˆà#¥c¨&¡k¤kÑ1ˆØÐr'   c           	      óÞ  — |                       |¦  «        }|dd …                              ¦   «         ddgk    }t          j        |d d…         |dd …         z  ¦  «        d         }|                     d¦  «         |
r||	         d         ng }|j        d         }| j        }t          |¦  «        dk    �r¤|                     ¦   «         }g }|r#|                     t          | ¦  «        ¦  «         n|dxx         dz  cc<   d}t          |¦  «        D �]\  }}|t          |¦  «        dz
  k    }| ||…         }|d         |z
  }|r|rdnd}||         |z
  }|                     ||         | 
                    |j        dk    rt          j        nt          j        ¦  «        |z  z   ||         | 
                    |j        dk    rt          j        nt          j        ¦  «        |z  z   |||z   ||z   f||	         d	œ¦  «         |
r"|||z   ||z   …         ||         z   |d         d<   |}�Œ|r
||         }�n:| |d
z
                                ¦   «         |z
  }||z  }�n| |                     ¦   «                              ¦   «                  }t#          ||         |z  |z  ¦  «        }|                     ¦   «         dk    rK|d         |k    r?|d         |z
   
                    |j        dk    rt          j        nt          j        ¦  «        }||         ||         ||z  z   | ||t          | ¦  «        z   f||	         d	œg}|
r,|||t          | ¦  «        z   …         ||         z   |d         d<   ||         }||fS )Nra   FTr   r   r   rW   ré   )ÚstartÚendr\   rc   r$   r   )ÚgerÏ  rh   ÚwhereÚadd_r   re   rk   r2   r"  r  r  r/   r  ÚitemÚnonzeroÚflattenr    Únumel)rñ   rò   ró   rz   rê   r²   rÑ   rÖ   rô   rõ   rw   rí   Útimestamp_tokensÚsingle_timestamp_endingÚtimestamp_segment_indicesrW   Ú
idx_offsetre   Úslicesr   Ú
last_slicer:   Úcurrent_sliceÚis_last_sliceÚsliced_tokensÚstart_timestamp_posÚidx_sliced_tokensÚend_timestamp_posr,  Úlast_timestamp_posr¸   s                                  r%   r#  z(WhisperGenerationMixin._retrieve_segment·  s  € ð" *7×)9Ò)9¸/Ñ)JÔ)JÐØ"2°2°3°3Ô"7×">Ò">Ñ"@Ô"@ÀUÈDÀMÒ"QÐÝ$)¤KÐ0@ÀÀ"ÀÔ0EÐHXÐYZÐY[ÐY[ÔH\Ñ0\Ñ$]Ô$]Ð^_Ô$`Ð!Ø!×&Ò& qÑ)Ô)Ð)ØD[Ðc˜<¨Ô,Ð-?Ô@Ð@ÐacÐØ&Ô,¨RÔ0ˆ
ØÔ%ˆõ Ð(Ñ)Ô)¨AÒ-Ñ-à.×5Ò5Ñ7Ô7ˆFØˆHØ&ð  Ø—’�c -Ñ0Ô0Ñ1Ô1Ð1Ð1ð �r�
�
”
˜a‘�
�
‘
àˆJå$-¨fÑ$5Ô$5ð +ñ +Ñ ��=Ø !¥S¨¡[¤[°1¡_Ò 4�Ø -¨j¸Ð.FÔ G�Ø&3°AÔ&6¸Ñ&HÐ#Ø.;Ð$^Ð?VÐ$^ B BÐ\^Ð!Ø$1Ð2CÔ$DÀÑ$VÐ!Ø—’à!,¨XÔ!6Ø-×0Ò0À&Ä+ÐQVÒBVÐBVµ´°Õ\aÔ\iÑjÔjØ(ñ)ñ")ð  +¨8Ô4Ø+×.Ò.ÀÄÈuÒ@TÐ@T­u¬}¨}ÕZ_ÔZgÑhÔhØ(ñ)ñ )ð #0Ø!+¨jÑ!8¸*À}Ñ:TÐ UØ".¨sÔ"3ð
ð 
ñô ð ð +ð à(¨°jÑ)@À:ÐP]ÑC]Ð)]Ô^ÐalÐmuÔavÑvð ˜R”LÐ!3Ñ4ð +�
‘
à&ð Cà!0°Ô!:�‘ð
 &3°:À±>Ô%B×%GÒ%GÑ%IÔ%IÈOÑ%[Ð"Ø!3°lÑ!B�‘ð 'Ð'7×'?Ò'?Ñ'AÔ'A×'IÒ'IÑ'KÔ'KÔLˆJÝ!$ _°XÔ%>ÐAXÑ%XÐ[iÑ%iÑ!jÔ!jÐØ×ÒÑ!Ô! AÒ%Ð%¨*°R¬.¸OÒ*KÐ*Kà&0°¤n°Ñ&F×%JÒ%JØ%+¤[°EÒ%9Ð%9•E”M�M½u¼}ñ&ô &Ð"ð
 )¨Ô2Ø& xÔ0Ð3EÈÑ3VÑVØ+Ø'¨µc¸-Ñ6HÔ6HÑ)HÐIØ*¨3Ô/ðð ðˆHð 'ð à$ Z°*½sÀ=Ñ?QÔ?QÑ2QÐ%QÔRÐU`ÐaiÔUjÑjð ˜”Ð/Ñ0ð -¨XÔ6ˆNà˜Ð'Ð'r'   )r†   NN)NNNNNFNNNNNNNNNNNNNr†   r¾   NFNNN)NNNrÖ  )1Ú__name__Ú
__module__Ú__qualname__r½   rh   ri   r   r
   r   r   r    r¡   r®   rË  r  r¢   r/  r!  Ústaticmethodr  r?  r$  rA  r  r<  r  r©  r  r  r	  r  ÚFloatTensorr   rÎ  r  r
  r  r  r  r  r  r  r  r  r   r”  r•  r#  Ú__classcell__)rP  s   @r%   r…   r…   ð   s„  ø€ € € € € àeiðLð Lð Lð Lð` /3Ø59Ø7;Ø9=ØTXØ!Ø)-ØØ+/Ø'+Ø*.Ø,0Ø04Ø8<Ø48Ø*.Ø,0Ø)-Ø.2Ø $Ø)-Ø/3Ø %Ø/3Ø26ØBFð7I	ð I	àœ tÑ+ðI	ð ,¨dÑ2ðI	ð .°Ñ4ð	I	ð
 0°$Ñ6ðI	ð #+¨C°´Ð+>ÀÀSÄ	Ð+IÔ"JÈTÑ"QðI	ð ðI	ð   $™;ðI	ð �D‰jðI	ð ˜˜Sœ	‘/ DÑ(ðI	ð  ™ðI	ð ”L 4Ñ'ðI	ð  # T™zðI	ð #'¨¡+ðI	ð ˜U 5¨# :Ô.Ñ.°Ñ5ðI	ð  &+¨T¡\ð!I	ð" ! 4™<ð#I	ð$ # T™\ð%I	ð&   $™Jð'I	ð( œ tÑ+ð)I	ð* ð+I	ð, "'ð-I	ð. "&¨¡ð/I	ð0 ð1I	ð2 "&¨¡ð3I	ð4 %)¨4¡Kð5I	ð6 # E¤L >°4Ð#7Ô8¸4Ñ?ð7I	ð I	ð I	ð I	ðVRið Rið Rið Rið Riðh ð ð  ñ „\ð ð?-ð ?-ð ?-ðB/,ð /,ð /,ðb,+ð ,+ð ,+ð\
ð 
ð 
ð6 ð^ð ^ñ „\ð^ð
 ðmð mñ „\ðmð ðjð jñ „\ðjð6 ð'ð 'ñ „\ð'ð$!ð !ð !ðF ð!*ð !*ñ „\ð!*ðFYið Yið Yiðz 48ØFJØ59Ø"&ð?ð ?àÔ)¨DÑ0ð?ð Ô*¨_Ñ<¸tÑCð?ð ,¨dÑ2ð	?ð
  ð?ð 
Œð?ð ?ð ?ð ?ðB ðð ñ „\ðð ð4ð 4ñ „\ð4ð" ð
ð 
ñ „\ð
ð8 ðHð Hñ „\ðHð$ ðNð Nñ „\ðNð ð ð  ñ „\ð ð& ð & ð & ðP ð:ð :ñ „\ð:ð ðð ñ „\ðð* ðA)ð A)ñ „\ðA)ðF>ð >ð >ð6 ð!ð !ñ „\ð!ð ðð ñ „\ðð$ ða(ð a(ñ „\ða(ð a(ð a(ð a(ð a(r'   r…   )rQ   rR   NNFFFN),r;  r  r	  Úcollections.abcr   r   r«   r-   rh   Útorch.nn.functionalr   r   rp   Útransformers.cache_utilsr   Ú
generationr   r	   Úgeneration.logits_processr
   r   r   r   r   Úgeneration.stopping_criteriar   Úmodeling_outputsr   Úutilsr   Útokenization_whisperr   r   Ú
get_loggerr*  r%  ri   r    r&   r£   rB   rP   rƒ   r…   r]   r'   r%   ú<module>r:     s  ðð €€€Ø €€€Ø €€€Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ø €€€Ø Ð Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à 8Ð 8Ð 8Ð 8Ð 8Ð 8à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ðð ð ð ð ð ð ð ð ð ð ð ð ð ð AÐ @Ð @Ð @Ð @Ð @Ø /Ð /Ð /Ð /Ð /Ð /Ø Ð Ð Ð Ð Ð Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <ð 
ˆÔ	˜HÑ	%Ô	%€ð˜5œ<ð °sð ¸u¼|ð ð ð ð ð*3& "¤*ð 3&ð 3&ð 3&ð 3&ðlð ð ð ØØØØ!Ø$Ø"'Øðoð oð oð oðdi(ð i(ð i(ð i(ð i(˜_ñ i(ô i(ð i(ð i(ð i(r'   