Ë
    T^(h}K ã                  óÈ  — d Z ddlmZ ddlZddlZddlmZmZmZm	Z	m
Z
 ddlZddlZddlmZ ddlmZ ddlmZ dd	lmZmZmZmZ dd
lmZmZmZmZmZm Z  ddl!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.  e(j^                  e0«      Z1dZ2dZ3ejh                  fd/d„Z5d0d„Z6d1d2d„Z7d3d4d„Z8 G d„ dejr                  jt                  «      Z; G d„ dejr                  jt                  «      Z< G d„ dejr                  jt                  «      Z= G d„ dejr                  jt                  «      Z> G d„ de«      Z?d Z@d!ZAe G d"„ d#ejr                  jt                  «      «       ZBe G d$„ d%ejr                  jt                  «      «       ZC e&d&e@«      e G d'„ d(ejr                  jt                  «      «       «       ZD e&d&e@«       G d)„ d*e?«      «       ZE e&d+e@«       G d,„ d-e?e«      «       ZFg d.¢ZGy)5zTensorFlow Whisper model.é    )ÚannotationsN)ÚDictÚListÚOptionalÚTupleÚUnioné   )Úget_tf_activation)ÚGenerationConfig)ÚTFLogitsProcessorList)ÚTFBaseModelOutputÚ+TFBaseModelOutputWithPastAndCrossAttentionsÚTFSeq2SeqLMOutputÚTFSeq2SeqModelOutput)ÚTFCausalLanguageModelingLossÚTFModelInputTypeÚTFPreTrainedModelÚkerasÚkeras_serializableÚunpack_inputs)Úcheck_embeddings_within_boundsÚ
shape_listÚstable_softmax)Úadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚloggingÚreplace_return_docstringsé   )ÚWhisperConfig)ÚTASK_IDSÚTO_LANGUAGE_CODEr   g    „×—Ác                ó:  — | \  }}|dz  dk7  rt        d|› d�«      ‚t        j                  d«      |dz  dz
  z  }t        j                  | t        j
                  |dz  t        j                  ¬«      z  «      }t        j                  t        j
                  |t        j                  ¬«      d«      t        j                  |d	«      z  }t        j                  t        j                  t        j                  |«      t        j                  |«      gd¬
«      |«      S )z*Returns sinusoids for positional embeddingé   r   zVNumber of channels has to be divisible by 2 for sinusoidal positional embeddings, got z
 channels.i'  r   ©Údtype)éÿÿÿÿr   )r   r&   ©Úaxis)Ú
ValueErrorÚmathÚlogÚtfÚexpÚrangeÚfloat32ÚreshapeÚcastÚconcatÚsinÚcos)Úshaper%   ÚlengthÚchannelsÚlog_timescale_incrementÚinv_timescalesÚscaled_times          úm/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/whisper/modeling_tf_whisper.pyÚsinusoidal_embedding_initr<   9   sä   € àÑ€FˆHØ�!�|�qÒÜØdÐemÐdnÐnxÐyó
ð 	
ô #Ÿh™h u›o°¸Q±ÀÑ1BÑCÐÜ—V‘VÐ4Ð4´r·x±xÀÈAÁÔUW×U_ÑU_Ô7`Ñ`Óa€NÜ—*‘*œRŸX™X f´B·J±JÔ?ÀÓIÌBÏJÉJÐWeÐgnÓLoÑo€KÜ�7‰7”2—9‘9œbŸf™f [Ó1´2·6±6¸+Ó3FÐGÈaÔPÐRWÓXÐXó    c           
     óö  — t        j                  || j                  «      }t        j                  || j                  «      }t        j                  t	        | «      d   dft        j
                  || j                  «      «      }t        j                  || d d …d d…f   gd«      }t        j                  |dk(  t        j                  t	        |«      t        j
                  || j                  «      «      |«      }t         j                  j                  |t        j                  d| j                  ¬«      «      }t        j                  |g«      5  t        j                  |«      }d d d «       |S # 1 sw Y   |S xY w)Nr   r   r&   iœÿÿÿr$   )r,   r1   r%   Úfillr   Úconvert_to_tensorr2   ÚwhereÚ	debuggingÚassert_greater_equalÚconstantÚcontrol_dependenciesÚidentity)Ú	input_idsÚpad_token_idÚdecoder_start_token_idÚstart_tokensÚshifted_input_idsÚassert_gte0s         r;   Úshift_tokens_rightrM   G   s8  € Ü—7‘7˜<¨¯©Ó9€LÜŸW™WÐ%;¸Y¿_¹_ÓMÐÜ—7‘7Ü	�IÓ	˜qÑ	! 1Ð%¤r×';Ñ';Ð<RÐT]×TcÑTcÓ'dó€Lô Ÿ	™	 <°º1¸c¸r¸c¸6Ñ1BÐ"CÀRÓHÐäŸ™Ø˜TÑ!Ü
�‰”
Ð,Ó-¬r×/CÑ/CÀLÐR[×RaÑRaÓ/bÓcØóÐô —,‘,×3Ñ3Ð4EÄrÇ{Á{ÐSTÐ\e×\kÑ\kÔGlÓm€Kô 
×	 Ñ	  + Ó	/ñ ;ÜŸK™KÐ(9Ó:Ð÷;ð Ð÷;ð Ðús   ÅE.Å.E8c           	     óÂ  — | d   }| d   }t        j                  ||f«      t        z  }t        j                  t	        |«      d   «      }t        j
                  |t        j                  |dz   t	        |«      d   df«      k  d|«      }|dkD  r.t        j                  t        j                  ||f«      |gd¬«      }t        j                  |dddd…dd…f   |dddf«      S )zB
    Make causal mask used for bi-directional self-attention.
    r   r   r&   ç        r'   N)
r,   ÚonesÚLARGE_NEGATIVEr.   r   rA   r0   r2   ÚzerosÚtile)Úinput_ids_shapeÚpast_key_values_lengthÚbszÚtgt_lenÚmaskÚ	mask_conds         r;   Ú_make_causal_maskrZ   `   sÔ   € ð ˜!Ñ
€CØ˜aÑ €GÜ�7‰7�G˜WÐ%Ó&¬Ñ7€DÜ—‘œ DÓ)¨"Ñ-Ó.€Iä�8‰8�I¤§
¡
¨9°q©=¼:ÀdÓ;KÈBÑ;OÐQRÐ:SÓ TÑTÐVYÐ[_Ó`€Dà Ò!Ü�y‰yœ"Ÿ(™( GÐ-CÐ#DÓEÀtÐLÐSUÔVˆä�7‰7�4˜˜d¢A¢qÐ(Ñ)¨C°°A°q¨>Ó:Ð:r=   c                óø   — t        | «      d   }|�|n|}t        j                  d«      }t        j                  | |j                  ¬«      } t        j
                  | dd…dddd…f   dd|df«      }||z
  t        z  S )z_
    Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
    r   Nç      ð?r$   )r   r,   rD   r1   r%   rS   rQ   )rX   rW   Úsrc_lenÚone_cstÚexpanded_masks        r;   Ú_expand_maskr`   r   sx   € ô ˜Ó˜qÑ!€GØ Ð,‰g°'€GÜ�k‰k˜#Ó€GÜ�7‰7�4˜wŸ}™}Ô-€DÜ—G‘G˜D¢ D¨$²Ð!1Ñ2°Q¸¸7ÀAÐ4FÓG€Mà�mÑ#¤~Ñ5Ð5r=   c                  óB   ‡ — e Zd Z	 	 d	 	 	 	 	 dˆ fd„Zˆ fd„Zdd„Zˆ xZS )ÚTFWhisperPositionalEmbeddingc                ó–   •— t        ‰| �  di |¤Ž || _        || _        || _        t
        j                  j                  |«      | _        y )N© )	ÚsuperÚ__init__Únum_positionsÚembedding_dimÚpadding_idxr   ÚinitializersÚgetÚembedding_initializer)Úselfrg   rh   ri   rl   ÚkwargsÚ	__class__s         €r;   rf   z%TFWhisperPositionalEmbedding.__init__€   sG   ø€ ô 	‰ÑÑ"˜6Ò"Ø*ˆÔØ*ˆÔØ&ˆÔÜ%*×%7Ñ%7×%;Ñ%;Ð<QÓ%RˆÕ"r=   c                ó˜   •— | j                  d| j                  | j                  g| j                  d¬«      | _        t
        ‰| �  |«       y )NÚweightT)Únamer5   ÚinitializerÚ	trainable)Ú
add_weightrg   rh   rl   rq   re   Úbuild)rm   Úinput_shapero   s     €r;   rv   z"TFWhisperPositionalEmbedding.buildŽ   sI   ø€ Ø—o‘oØØ×%Ñ% t×'9Ñ'9Ð:Ø×2Ñ2Øð	 &ó 
ˆŒô 	‰‰�kÕ"r=   c                óê   — t        j                  |t         j                  «      }t        j                  t        j                  |«      d   d¬«      |z   }t        j
                  | j                  |«      S )Nr   )Údelta)r,   r1   Úint32r.   r5   Úgatherrq   )rm   rG   rU   Úgather_indicess       r;   Úcallz!TFWhisperPositionalEmbedding.call—   sQ   € Ü!#§¡Ð)?ÄÇÁÓ!JÐÜŸ™¤"§(¡(¨9Ó"5°aÑ"8ÀÔBÐE[Ñ[ˆÜ�y‰y˜Ÿ™ nÓ5Ð5r=   ©NN)rg   Úintrh   r   ri   úOptional[int]©r   )Ú__name__Ú
__module__Ú__qualname__rf   rv   r}   Ú__classcell__©ro   s   @r;   rb   rb      s:   ø„ ð
 &*Ø"ðSàðSð ðSð #õ	Sô#÷6r=   rb   c                  ó|   ‡ — e Zd ZdZ	 	 	 d	 	 	 	 	 	 	 	 	 dˆ fd„Zdd„Z	 	 	 	 	 d		 	 	 	 	 	 	 	 	 	 	 	 	 d
d„Zdd„Zˆ xZS )ÚTFWhisperAttentionz=Multi-headed attention from 'Attention Is All You Need' paperc                óz  •— t        ‰| �  di |¤Ž || _        || _        t        j
                  j                  |«      | _        ||z  | _        | j                  |z  | j                  k7  rt        d| j                  › d|› d�«      ‚| j                  dz  | _
        || _        t        j
                  j                  |dd¬«      | _        t        j
                  j                  ||d¬«      | _        t        j
                  j                  ||d	¬«      | _        t        j
                  j                  ||d
¬«      | _        y )Nz;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).g      à¿FÚk_proj)Úuse_biasrr   Úv_projÚq_projÚout_projrd   )re   rf   Ú	embed_dimÚ	num_headsr   ÚlayersÚDropoutÚdropoutÚhead_dimr)   ÚscalingÚ
is_decoderÚDenserŠ   rŒ   r�   rŽ   )rm   r�   r�   r“   r–   Úbiasrn   ro   s          €r;   rf   zTFWhisperAttention.__init__    s  ø€ ô 	‰ÑÑ"˜6Ò"Ø"ˆŒØ"ˆŒÜ—|‘|×+Ñ+¨GÓ4ˆŒØ! YÑ.ˆŒà�M‰M˜IÑ%¨$¯.©.Ò8ÜØMÈdÏnÉnÐM]Ø$ Y K¨rð3óð ð —}‘} dÑ*ˆŒØ$ˆŒä—l‘l×(Ñ(¨¸UÈÐ(ÓRˆŒÜ—l‘l×(Ñ(¨¸TÈÐ(ÓQˆŒÜ—l‘l×(Ñ(¨¸TÈÐ(ÓQˆŒÜŸ™×*Ñ*¨9¸tÈ*Ð*ÓUˆ�r=   c           	     ó†   — t        j                  t        j                  |||| j                  | j                  f«      d«      S )N©r   r#   r   r	   )r,   Ú	transposer0   r�   r”   )rm   ÚtensorÚseq_lenrV   s       r;   Ú_shapezTFWhisperAttention._shape½   s0   € Ü�|‰|œBŸJ™J v°°W¸d¿n¹nÈdÏmÉmÐ/\Ó]Ð_kÓlÐlr=   c           
     óÌ	  — |du}t        |«      \  }}	}
| j                  |«      | j                  z  }|r|�|d   }|d   }�n
|rE| j                  | j	                  |«      d|«      }| j                  | j                  |«      d|«      }nÃ|�}| j                  | j	                  |«      d|«      }| j                  | j                  |«      d|«      }t        j                  |d   |gd¬«      }t        j                  |d   |gd¬«      }nD| j                  | j	                  |«      d|«      }| j                  | j                  |«      d|«      }| j                  r||f}|| j                  z  d| j                  f}t        j                  | j                  ||	|«      |«      }t        j                  ||«      }t        j                  ||«      }t        |«      d   }t        j                  ||d¬«      }t        j                  j                  t        |«      || j                  z  |	|gd	|| j                  z  |	|f› d
t        |«      › �¬«       |�°t        j                  j                  t        |«      |d|	|gd|d|	|f› d
t        |«      › �¬«       t        j                  ||j                   ¬«      }t        j                  ||| j                  |	|f«      |z   }t        j                  ||| j                  z  |	|f«      }t#        |d¬«      }|�°t        j                  j                  t        |«      | j                  gd| j                  › d
t        |«      › �¬«       t        j                  |d«      t        j                  ||| j                  |	|f«      z  }t        j                  ||| j                  z  |	|f«      }| j%                  ||¬«      }t        j                  ||«      }t        j                  j                  t        |«      || j                  z  |	| j                  gd|| j                  |	| j                  f› d
t        |«      › �¬«       t        j&                  t        j                  ||| j                  |	| j                  f«      d«      }t        j                  |||	|
f«      }| j)                  |«      }t        j                  ||| j                  |	|f«      }|||fS )z#Input shape: Batch x Time x ChannelNr   r   r&   r#   r'   T©Útranspose_bz$Attention weights should be of size z	, but is ©Úmessagez!Attention mask should be of size r$   z/Head mask for a single layer should be of size )r   r&   r   r   ©Útrainingz `attn_output` should be of size rš   )r   r�   r•   rž   rŠ   rŒ   r,   r2   r–   r�   r”   r0   ÚmatmulrB   Úassert_equalr1   r%   r   r“   r›   rŽ   )rm   Úhidden_statesÚkey_value_statesÚpast_key_valueÚattention_maskÚlayer_head_maskr¥   Úis_cross_attentionrV   rW   r�   Úquery_statesÚ
key_statesÚvalue_statesÚ
proj_shaper]   Úattn_weightsÚ
attn_probsÚattn_outputs                      r;   r}   zTFWhisperAttention.callÁ   sž  € ð .°TÐ9ÐÜ",¨]Ó";ÑˆˆW�ið —{‘{ =Ó1°D·L±LÑ@ˆá .Ð"<à'¨Ñ*ˆJØ)¨!Ñ,ŠLÙàŸ™ T§[¡[Ð1AÓ%BÀBÈÓLˆJØŸ;™; t§{¡{Ð3CÓ'DÀbÈ#ÓN‰LØÐ'àŸ™ T§[¡[°Ó%?ÀÀSÓIˆJØŸ;™; t§{¡{°=Ó'AÀ2ÀsÓKˆLÜŸ™ N°1Ñ$5°zÐ#BÈÔKˆJÜŸ9™9 n°QÑ&7¸Ð%FÈQÔO‰Lð Ÿ™ T§[¡[°Ó%?ÀÀSÓIˆJØŸ;™; t§{¡{°=Ó'AÀ2ÀsÓKˆLà�?Š?ð )¨,Ð7ˆNà˜DŸN™NÑ*¨B°·±Ð>ˆ
Ü—z‘z $§+¡+¨l¸GÀSÓ"IÈ:ÓVˆÜ—Z‘Z 
¨JÓ7ˆ
Ü—z‘z ,°
Ó;ˆä˜ZÓ(¨Ñ+ˆÜ—y‘y ¨zÀtÔLˆä
�‰×!Ñ!Ü�|Ó$Ø�4—>‘>Ñ! 7¨GÐ4à6¸¸d¿n¹nÑ8LÈgÐW^Ð7_Ð6`ð aÜ˜|Ó,Ð-ð/ð	 	"ô 	
ð Ð%Ü�L‰L×%Ñ%Ü˜>Ó*Ø�a˜ 'Ð*à7¸¸aÀÈ'Ð8RÐ7Sð TÜ" >Ó2Ð3ð5ð	 &ô ô  ŸW™W ^¸<×;MÑ;MÔNˆNÜŸ:™: l°S¸$¿.¹.È'ÐSZÐ4[Ó\Ð_mÑmˆLÜŸ:™: l°S¸4¿>¹>Ñ5IÈ7ÐT[Ð4\Ó]ˆLä% l¸Ô<ˆàÐ&Ü�L‰L×%Ñ%Ü˜?Ó+Ø—‘Ð àEÀtÇ~Á~ÐEWð XÜ" ?Ó3Ð4ð6ð	 &ô ô Ÿ:™: o°}ÓEÌÏ
É
Ø˜s D§N¡N°G¸WÐEóIñ ˆLô Ÿ:™: l°S¸4¿>¹>Ñ5IÈ7ÐT[Ð4\Ó]ˆLà—\‘\ ,¸�\ÓBˆ
Ü—i‘i 
¨LÓ9ˆä
�‰×!Ñ!Ü�{Ó#Ø�4—>‘>Ñ! 7¨D¯M©MÐ:à2°C¸¿¹ÈÐRV×R_ÑR_Ð3`Ð2að bÜ˜{Ó+Ð,ð.ð	 	"ô 	
ô —l‘lÜ�J‰J�{ S¨$¯.©.¸'À4Ç=Á=Ð$QÓRÐT`ó
ˆô —j‘j ¨s°G¸YÐ.GÓHˆà—m‘m KÓ0ˆÜ"$§*¡*¨\¸CÀÇÁÐQXÐZaÐ;bÓ"cˆà˜L¨.Ð8Ð8r=   c                óÈ  — | j                   ry d| _         t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �[t        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       y y # 1 sw Y   �ŒAxY w# 1 sw Y   ŒæxY w# 1 sw Y   Œ‹xY w# 1 sw Y   y xY w)NTrŠ   rŒ   r�   rŽ   )ÚbuiltÚgetattrr,   Ú
name_scoperŠ   rr   rv   r�   rŒ   r�   rŽ   ©rm   rw   s     r;   rv   zTFWhisperAttention.build7  sŠ  € Ø�:Š:ØØˆŒ
Ü�4˜ 4Ó(Ð4Ü—‘˜tŸ{™{×/Ñ/Ó0ñ @Ø—‘×!Ñ! 4¨¨t¯~©~Ð">Ô?÷@ä�4˜ 4Ó(Ð4Ü—‘˜tŸ{™{×/Ñ/Ó0ñ @Ø—‘×!Ñ! 4¨¨t¯~©~Ð">Ô?÷@ä�4˜ 4Ó(Ð4Ü—‘˜tŸ{™{×/Ñ/Ó0ñ @Ø—‘×!Ñ! 4¨¨t¯~©~Ð">Ô?÷@ä�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ BØ—‘×#Ñ# T¨4°·±Ð$@ÔA÷Bð Bð 7÷@ñ @ú÷@ð @ú÷@ð @ú÷Bð Bús0   Á)F3Â2)G Ä)GÆ )GÆ3F=Ç G	ÇGÇG!)rO   FT)
r�   r   r�   r   r“   Úfloatr–   Úboolr˜   r»   )rœ   ú	tf.Tensorr�   r   rV   r   )NNNNF)r¨   r¼   r©   útf.Tensor | Nonerª   zTuple[Tuple[tf.Tensor]] | Noner«   r½   r¬   r½   r¥   úOptional[bool]Úreturnz"Tuple[tf.Tensor, tf.Tensor | None]©N)	r‚   rƒ   r„   Ú__doc__rf   rž   r}   rv   r…   r†   s   @r;   rˆ   rˆ   �   s»   ø„ ÙGð Ø ØðVàðVð ðVð ð	Vð
 ðVð õVó:mð .2Ø9=Ø+/Ø,0Ø#(ðt9à ðt9ð +ðt9ð 7ð	t9ð
 )ðt9ð *ðt9ð !ðt9ð 
,ót9÷lBr=   rˆ   c                  óB   ‡ — e Zd Zdˆ fd„Z	 d	 	 	 	 	 	 	 dd„Zdd„Zˆ xZS )ÚTFWhisperEncoderLayerc                óü  •— t        ‰| �  d
i |¤Ž |j                  | _        t	        | j                  |j
                  |j                  d¬«      | _        t        j                  j                  dd¬«      | _        t        j                  j                  |j                  «      | _        t        |j                  «      | _        t        j                  j                  |j"                  «      | _        t        j                  j%                  |j&                  d¬«      | _        t        j                  j%                  | j                  d¬«      | _        t        j                  j                  dd	¬«      | _        || _        y )NÚ	self_attn)r“   rr   çñhãˆµøä>Úself_attn_layer_norm©Úepsilonrr   Úfc1©rr   Úfc2Úfinal_layer_normrd   )re   rf   Úd_modelr�   rˆ   Úencoder_attention_headsÚattention_dropoutrÅ   r   r‘   ÚLayerNormalizationrÇ   r’   r“   r
   Úactivation_functionÚactivation_fnÚactivation_dropoutr—   Úencoder_ffn_dimrÊ   rÌ   rÍ   Úconfig©rm   rÖ   rn   ro   s      €r;   rf   zTFWhisperEncoderLayer.__init__K  s  ø€ Ü‰ÑÑ"˜6Ò"ØŸ™ˆŒÜ+Ø�N‰N˜F×:Ñ:ÀF×D\ÑD\Ðcnô
ˆŒô %*§L¡L×$CÑ$CÈDÐWmÐ$CÓ$nˆÔ!Ü—|‘|×+Ñ+¨F¯N©NÓ;ˆŒÜ.¨v×/IÑ/IÓJˆÔÜ"'§,¡,×"6Ñ"6°v×7PÑ7PÓ"QˆÔÜ—<‘<×%Ñ% f×&<Ñ&<À5Ð%ÓIˆŒÜ—<‘<×%Ñ% d§n¡n¸5Ð%ÓAˆŒÜ %§¡× ?Ñ ?ÈÐSeÐ ?Ó fˆÔØˆ�r=   c           
     ó  — |}| j                  |«      }| j                  ||||¬«      \  }}}t        j                  j	                  t        |«      t        |«      dt        |«      › dt        |«      › �¬«       | j                  ||¬«      }||z   }|}| j                  |«      }| j                  | j                  |«      «      }| j                  ||¬«      }| j                  |«      }| j                  ||¬«      }||z   }||fS )a¸  
        Args:
            hidden_states (`tf.Tensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
            attention_mask (`tf.Tensor`): attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            layer_head_mask (`tf.Tensor`): mask for attention heads in a given layer of size
                `(encoder_attention_heads,)`
        )r¨   r«   r¬   r¥   z&Self attn modified the shape of query z to r¢   r¤   )rÇ   rÅ   r,   rB   r§   r   r“   rÍ   rÓ   rÊ   rÔ   rÌ   )rm   r¨   r«   r¬   r¥   ÚresidualÚself_attn_weightsÚ_s           r;   r}   zTFWhisperEncoderLayer.callZ  s  € ð !ˆØ×1Ñ1°-Ó@ˆØ.2¯n©nØ'Ø)Ø+Øð	 /=ó /
Ñ+ˆÐ(¨!ô 	�‰×!Ñ!Ü�}Ó%Ü�xÓ Ø<¼ZÈÓ=QÐ<RÐRVÔWaÐboÓWpÐVqÐrð 	"ô 	
ð Ÿ™ ]¸X˜ÓFˆØ  =Ñ0ˆà ˆØ×-Ñ-¨mÓ<ˆØ×*Ñ*¨4¯8©8°MÓ+BÓCˆØ×/Ñ/°ÈÐ/ÓQˆØŸ™ Ó/ˆØŸ™ ]¸X˜ÓFˆØ  =Ñ0ˆàÐ/Ð/Ð/r=   c                óª  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �[t        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       y y # 1 sw Y   �Œ²xY w# 1 sw Y   �ŒXxY w# 1 sw Y   ŒýxY w# 1 sw Y   Œ˜xY w# 1 sw Y   y xY w)NTrÅ   rÇ   rÊ   rÌ   rÍ   )r¶   r·   r,   r¸   rÅ   rr   rv   rÇ   r�   rÊ   rÌ   rÖ   rÕ   rÍ   r¹   s     r;   rv   zTFWhisperEncoderLayer.build�  sÚ  € Ø�:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ +Ø—‘×$Ñ$ TÔ*÷+ä�4Ð/°Ó6ÐBÜ—‘˜t×8Ñ8×=Ñ=Ó>ñ NØ×)Ñ)×/Ñ/°°t¸T¿^¹^Ð0LÔM÷Nä�4˜ Ó%Ð1Ü—‘˜tŸx™xŸ}™}Ó-ñ =Ø—‘—‘  d¨D¯N©NÐ;Ô<÷=ä�4˜ Ó%Ð1Ü—‘˜tŸx™xŸ}™}Ó-ñ JØ—‘—‘  d¨D¯K©K×,GÑ,GÐHÔI÷Jä�4Ð+¨TÓ2Ð>Ü—‘˜t×4Ñ4×9Ñ9Ó:ñ JØ×%Ñ%×+Ñ+¨T°4¸¿¹Ð,HÔI÷Jð Jð ?÷+ñ +ú÷Nñ Nú÷=ð =ú÷Jð Jú÷Jð Jús<   ÁHÂ%)H$Ä)H1Å33H=Ç$)I	ÈH!È$H.È1H:È=IÉ	I©rÖ   r   )F)r¨   r¼   r«   r¼   r¬   r¼   r¥   r»   rÀ   ©r‚   rƒ   r„   rf   r}   rv   r…   r†   s   @r;   rÃ   rÃ   J  s;   ø„ õð  qvð%0Ø&ð%0Ø8Að%0ØT]ð%0Øimó%0÷NJr=   rÃ   c                  óZ   ‡ — e Zd Zdˆ fd„Z	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zˆ xZS )ÚTFWhisperDecoderLayerc                ó°  •— t        ‰| �  di |¤Ž |j                  | _        t	        | j                  |j
                  |j                  dd¬«      | _        t        j                  j                  |j                  «      | _        t        |j                  «      | _        t        j                  j                  |j                  «      | _        t        j                  j!                  dd¬«      | _        t	        | j                  |j
                  |j                  dd¬«      | _        t        j                  j!                  dd	¬«      | _        t        j                  j)                  |j*                  d
¬«      | _        t        j                  j)                  | j                  d¬«      | _        t        j                  j!                  dd¬«      | _        || _        y )NrÅ   T)r�   r�   r“   rr   r–   rÆ   rÇ   rÈ   Úencoder_attn)r“   rr   r–   Úencoder_attn_layer_normrÊ   rË   rÌ   rÍ   rd   )re   rf   rÎ   r�   rˆ   Údecoder_attention_headsrÐ   rÅ   r   r‘   r’   r“   r
   rÒ   rÓ   rÔ   rÑ   rÇ   râ   rã   r—   Údecoder_ffn_dimrÊ   rÌ   rÍ   rÖ   r×   s      €r;   rf   zTFWhisperDecoderLayer.__init__˜  sa  ø€ Ü‰ÑÑ"˜6Ò"ØŸ™ˆŒä+Ø—n‘nØ×4Ñ4Ø×,Ñ,ØØô
ˆŒô —|‘|×+Ñ+¨F¯N©NÓ;ˆŒÜ.¨v×/IÑ/IÓJˆÔÜ"'§,¡,×"6Ñ"6°v×7PÑ7PÓ"QˆÔä$)§L¡L×$CÑ$CÈDÐWmÐ$CÓ$nˆÔ!Ü.Ø�N‰NØ×*Ñ*Ø×,Ñ,ØØô
ˆÔô (-§|¡|×'FÑ'FÈtÐZsÐ'FÓ'tˆÔ$Ü—<‘<×%Ñ% f×&<Ñ&<À5Ð%ÓIˆŒÜ—<‘<×%Ñ% d§n¡n¸5Ð%ÓAˆŒÜ %§¡× ?Ñ ?ÈÐSeÐ ?Ó fˆÔØˆ�r=   c	                ó<  — |}	| j                  |«      }|�|dd nd}
| j                  ||
|||¬«      \  }}}| j                  ||¬«      }|	|z   }d}d}|�T|}	| j                  |«      }|�|dd nd}| j	                  ||||||¬«      \  }}}| j                  ||¬«      }|	|z   }||z   }|}	| j                  |«      }| j                  | j                  |«      «      }| j                  ||¬«      }| j                  |«      }| j                  ||¬«      }|	|z   }||||fS )aõ  
        Args:
            hidden_states (`tf.Tensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
            attention_mask (`tf.Tensor`): attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            encoder_hidden_states (`tf.Tensor`):
                cross attention input to the layer of shape `(batch, seq_len, embed_dim)`
            encoder_attention_mask (`tf.Tensor`): encoder attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            layer_head_mask (`tf.Tensor`): mask for attention heads in a given layer of size
                `(decoder_attention_heads,)`
            cross_attn_layer_head_mask (`tf.Tensor`): mask for heads of the cross-attention module.
                `(decoder_attention_heads,)`
            past_key_value (`Tuple(tf.Tensor)`): cached past key and value projection states
        Nr#   )r¨   rª   r«   r¬   r¥   r¤   éþÿÿÿ)r¨   r©   r«   r¬   rª   r¥   )
rÇ   rÅ   r“   rã   râ   rÍ   rÓ   rÊ   rÔ   rÌ   )rm   r¨   r«   Úencoder_hidden_statesÚencoder_attention_maskr¬   Úcross_attn_layer_head_maskrª   r¥   rÙ   Úself_attn_past_key_valuerÚ   Úpresent_key_valueÚcross_attn_present_key_valueÚcross_attn_weightsÚcross_attn_past_key_values                   r;   r}   zTFWhisperDecoderLayer.callµ  s£  € ð4 !ˆØ×1Ñ1°-Ó@ˆð :HÐ9S >°"°1Ñ#5ÐY]Ð à>B¿n¹nØ'Ø3Ø)Ø+Øð ?Mó ?
Ñ;ˆÐ(Ð*;ð Ÿ™ ]¸X˜ÓFˆØ  =Ñ0ˆð (,Ð$Ø!ÐØ Ð,Ø$ˆHØ ×8Ñ8¸ÓGˆMð @NÐ?Y¨°r°sÑ(;Ð_cÐ%ØNR×N_ÑN_Ø+Ø!6Ø5Ø :Ø8Ø!ð O`ó OÑKˆMÐ-Ð/Kð !ŸL™L¨À˜LÓJˆMØ$ }Ñ4ˆMð !2Ð4PÑ PÐð !ˆØ×-Ñ-¨mÓ<ˆØ×*Ñ*¨4¯8©8°MÓ+BÓCˆØ×/Ñ/°ÈÐ/ÓQˆØŸ™ Ó/ˆØŸ™ ]¸X˜ÓFˆØ  =Ñ0ˆð ØØØð	
ð 	
r=   c                ób  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �[t        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       y y # 1 sw Y   �ŒsxY w# 1 sw Y   �ŒxY w# 1 sw Y   �ŒÌxY w# 1 sw Y   �ŒrxY w# 1 sw Y   �ŒxY w# 1 sw Y   Œ³xY w# 1 sw Y   y xY w)	NTrÅ   rÇ   râ   rã   rÊ   rÌ   rÍ   )r¶   r·   r,   r¸   rÅ   rr   rv   rÇ   r�   râ   rã   rÊ   rÌ   rÖ   rå   rÍ   r¹   s     r;   rv   zTFWhisperDecoderLayer.build  sŠ  € Ø�:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ +Ø—‘×$Ñ$ TÔ*÷+ä�4Ð/°Ó6ÐBÜ—‘˜t×8Ñ8×=Ñ=Ó>ñ NØ×)Ñ)×/Ñ/°°t¸T¿^¹^Ð0LÔM÷Nä�4˜¨Ó.Ð:Ü—‘˜t×0Ñ0×5Ñ5Ó6ñ .Ø×!Ñ!×'Ñ'¨Ô-÷.ä�4Ð2°DÓ9ÐEÜ—‘˜t×;Ñ;×@Ñ@ÓAñ QØ×,Ñ,×2Ñ2°D¸$ÀÇÁÐ3OÔP÷Qä�4˜ Ó%Ð1Ü—‘˜tŸx™xŸ}™}Ó-ñ =Ø—‘—‘  d¨D¯N©NÐ;Ô<÷=ä�4˜ Ó%Ð1Ü—‘˜tŸx™xŸ}™}Ó-ñ JØ—‘—‘  d¨D¯K©K×,GÑ,GÐHÔI÷Jä�4Ð+¨TÓ2Ð>Ü—‘˜t×4Ñ4×9Ñ9Ó:ñ JØ×%Ñ%×+Ñ+¨T°4¸¿¹Ð,HÔI÷Jð Jð ?÷#+ñ +ú÷Nñ Nú÷.ñ .ú÷Qñ Qú÷=ñ =ú÷Jð Jú÷Jð JúsT   ÁKÂ%)K%ÄK2Å&)K?Ç)LÈ43LÊ%)L%ËK"Ë%K/Ë2K<Ë?L	ÌLÌL"Ì%L.rÝ   )NNNNNNF)r«   r½   rè   r½   ré   r½   r¬   r½   rê   r½   rª   zTuple[tf.Tensor] | Noner¿   z4Tuple[tf.Tensor, tf.Tensor, Tuple[Tuple[tf.Tensor]]]rÀ   rÞ   r†   s   @r;   rà   rà   —  sz   ø„ õð@ ,0Ø26Ø37Ø,0Ø7;Ø26ØðP
ð )ðP
ð  0ð	P
ð
 !1ðP
ð *ðP
ð %5ðP
ð 0ðP
ð 
>óP
÷dJr=   rà   c                  óB   — e Zd ZeZdZdZdd„Zedd„«       Z	ed„ «       Z
y)	ÚTFWhisperPreTrainedModelÚmodelÚinput_featuresc                ó   — |dz
  dz  dz   }|S )zH
        Computes the output length of the convolutional layers
        r   r#   rd   )rm   Úinput_lengthss     r;   Ú _get_feat_extract_output_lengthsz9TFWhisperPreTrainedModel._get_feat_extract_output_lengths'  s   € ð '¨Ñ*¨qÑ0°1Ñ4ˆàÐr=   c                ó*  — | j                   t        j                  j                  d| j                  j
                  | j                  j                  dz  dz
  gt        j                  ¬«      dt        j                  ddggt        j                  ¬«      iS )z|
        Dummy inputs to build the network.

        Returns:
            `Dict[str, tf.Tensor]`: The dummy inputs.
        r   r#   r$   Údecoder_input_idsr	   )
Úmain_input_namer,   ÚrandomÚuniformrÖ   Únum_mel_binsÚmax_source_positionsr/   rD   rz   ©rm   s    r;   Údummy_inputsz%TFWhisperPreTrainedModel.dummy_inputs/  s|   € ð × Ñ ¤"§)¡)×"3Ñ"3Ø�D—K‘K×,Ñ,¨d¯k©k×.NÑ.NÐQRÑ.RÐUVÑ.VÐWÔ_a×_iÑ_ið #4ó #ð  ¤§¡¨q°!¨f¨X¼R¿X¹XÔ!Fð	
ð 	
r=   c                ó  — t        j                  d | j                  j                  d ft         j                  d¬«      t        j                  dt         j
                  d¬«      t        j                  dt         j
                  d¬«      dœS )Nrô   rË   r~   rù   Údecoder_attention_mask)rô   rù   r  )r,   Ú
TensorSpecrÖ   rý   r/   rz   rÿ   s    r;   Úinput_signaturez(TFWhisperPreTrainedModel.input_signature>  sa   € ô !Ÿm™m¨T°4·;±;×3KÑ3KÈTÐ,RÔTV×T^ÑT^ÐeuÔvÜ!#§¡¨|¼R¿X¹XÐL_Ô!`Ü&(§m¡m°LÄ"Ç(Á(ÐQiÔ&jñ
ð 	
r=   N)rö   r¼   r¿   r   )r¿   zDict[str, tf.Tensor])r‚   rƒ   r„   r   Úconfig_classÚbase_model_prefixrú   r÷   Úpropertyr   r  rd   r=   r;   rò   rò   "  s?   „ Ø €LØÐØ&€Oóð ò
ó ð
ð ñ
ó ñ
r=   rò   aI  
    This model inherits from [`TFPreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a [keras.Model](https://www.tensorflow.org/api_docs/python/tf/keras/Model) subclass. Use it
    as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`WhisperConfig`]):
            Model configuration class with all the parameters of the model. Initializing with a config file does not
            load the weights associated with the model, only the configuration. Check out the
            [`~TFPreTrainedModel.from_pretrained`] method to load the model weights.
ap  
    Args:
        input_features (`tf.Tensor` of shape `(batch_size, feature_size, sequence_length)`):
            Float values of fbank features extracted from the raw speech waveform. Raw speech waveform can be obtained
            by loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.ndarray`, *e.g.*
            via the soundfile library (`pip install soundfile`). To prepare the array into `input_features`, the
            [`AutoFeatureExtractor`] should be used for extracting the fbank features, padding and conversion into a
            tensor of type `tf.Tensor`. See [`~WhisperFeatureExtractor.__call__`]
        decoder_input_ids (`tf.Tensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Indices of decoder input sequence tokens in the vocabulary.

            Indices can be obtained using [`SpeechToTextTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are decoder input IDs?](../glossary#decoder-input-ids)

            SpeechToText uses the `eos_token_id` as the starting token for `decoder_input_ids` generation. If
            `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
            `past_key_values`).
        decoder_attention_mask (`tf.Tensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
            be used by default.

            If you want to change padding behavior, you should read
            [`modeling_whisper._prepare_decoder_attention_mask`] and modify to your needs. See diagram 1 in [the
            paper](https://arxiv.org/abs/1910.13461) for more information on the default strategy.
        head_mask (`tf.Tensor` of shape `(encoder_layers, encoder_attention_heads)`, *optional*):
            Mask to nullify selected heads of the attention modules in the encoder. Mask values selected in `[0, 1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        decoder_head_mask (`tf.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
            Mask to nullify selected heads of the attention modules in the decoder. Mask values selected in `[0, 1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        cross_attn_head_mask (`tf.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
            Mask to nullify selected heads of the cross-attention modules. Mask values selected in `[0, 1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        encoder_outputs (`tuple(tuple(tf.Tensor)`, *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.
        past_key_values (`tuple(tuple(tf.Tensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
            Tuple of `tuple(tf.Tensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
            `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
            `(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.

            Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
            blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.

            If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
            don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
            `decoder_input_ids` of shape `(batch_size, sequence_length)`.
        decoder_inputs_embeds (`tf.Tensor` of shape `(batch_size, target_sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `decoder_input_ids` you can choose to directly pass an embedded
            representation. If `past_key_values` is used, optionally only the last `decoder_inputs_embeds` have to be
            input (see `past_key_values`). This is useful if you want more control over how to convert
            `decoder_input_ids` indices into associated vectors than the model's internal embedding lookup matrix.
        use_cache (`bool`, *optional*):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`).
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
c                  óL   ‡ — e Zd ZeZ	 dˆ fd„Ze	 	 	 	 	 	 dd„«       Zdd„Zˆ xZ	S )ÚTFWhisperEncoderc                ó¤  •— t        ‰| �  di |¤Ž || _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _	        |j                  | _
        |j                  rt        j                  | j                  «      nd| _        t        j                   j#                  | j                  dddd¬«      | _        t        j                   j#                  | j                  dddd¬«      | _        t)        | j                  | j                  t*        d	¬
«      | _        d| j,                  _        t1        |j2                  «      D �cg c]  }t5        |d|› �¬«      ‘Œ c}| _        t        j                   j7                  dd¬«      | _        t        j                   j;                  |j<                  «      | _        y c c}w )Nr\   r	   r   ÚvalidÚconv1)Úkernel_sizeÚstridesÚpaddingrr   r#   Úconv2Úembed_positions)rg   rh   rl   rr   Fúlayers.rË   rÆ   Ú
layer_normrÈ   rd   )re   rf   rÖ   Úencoder_layerdropÚ	layerdroprÎ   r�   rý   rH   ri   rþ   Úscale_embeddingr*   ÚsqrtÚembed_scaler   r‘   ÚConv1Dr  r  rb   r<   r  rt   r.   Úencoder_layersrÃ   rÑ   r  r’   r“   ©rm   rÖ   rn   Úiro   s       €r;   rf   zTFWhisperEncoder.__init__±  sj  ø€ Ü‰ÑÑ"˜6Ò"ØˆŒØ×1Ñ1ˆŒàŸ™ˆŒØ"×/Ñ/ˆÔØ!×.Ñ.ˆÔØ$*×$?Ñ$?ˆÔ!Ø8>×8NÒ8Nœ4Ÿ9™9 T§^¡^Ô4ÐTWˆÔô —\‘\×(Ñ(¨¯©ÀQÐPQÐ[bÐipÐ(ÓqˆŒ
Ü—\‘\×(Ñ(¨¯©ÀQÐPQÐ[bÐipÐ(ÓqˆŒ
ä;Ø×3Ñ3ØŸ.™.Ü";Ø"ô	 
ˆÔð */ˆ×ÑÔ&äZ_Ð`f×`uÑ`uÓZvÖwÐUVÔ4°VÀGÈAÈ3À-ÖPÒwˆÔÜŸ,™,×9Ñ9À$È\Ð9ÓZˆŒä—|‘|×+Ñ+¨F¯N©NÓ;ˆ�ùò xs   ÅGc           
     ó  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }t	        j
                  |d¬«      }t	        j                  |ddgddgddgg«      }t        j                  j                  | j                  |«      «      }t	        j                  |ddgddgddgg«      }t        j                  j                  | j                  |«      «      }t	        j
                  |d¬«      }| j                  t	        j                  d| j                  ft        j                  ¬«      ¬«      }||z   }	| j!                  |	|¬	«      }	|rd
nd}
|rd
nd}|�gt        j"                  j%                  t'        |«      d   t)        | j*                  «      dt)        | j*                  «      › dt'        |«      d   › d�¬«       t-        | j*                  «      D ]T  \  }}|r|
|	fz   }
t/        j0                  dd«      }|r|| j2                  k  rŒ6 ||	d|�||   nd|¬«      \  }	}|sŒO||fz  }ŒV | j5                  |	«      }	|r|
|	fz   }
|st7        d„ |	|
|fD «       «      S t9        |	|
|¬«      S )a"  
        Args:
            input_features (`tf.Tensor` of shape `(batch_size, feature_size, sequence_length)`):
                Float values of fbank features extracted from the raw speech waveform. Raw speech waveform can be
                obtained by loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a
                `numpy.ndarray`, *e.g.* via the soundfile library (`pip install soundfile`). To prepare the array into
                `input_features`, the [`AutoFeatureExtractor`] should be used for extracting the fbank features,
                padding and conversion into a tensor of type `tf.Tensor`. See [`~WhisperFeatureExtractor.__call__`]
            head_mask (`tf.Tensor` of shape `(encoder_layers, encoder_attention_heads)`, *optional*):
                Mask to nullify selected heads of the attention modules. Mask values selected in `[0, 1]`:

                - 1 indicates the head is **not masked**,
                - 0 indicates the head is **masked**.

            output_attentions (`bool`, *optional*):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
            output_hidden_states (`bool`, *optional*):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more detail.
            return_dict (`bool`, *optional*):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        N)r   r#   r   )Úpermr   r   )r   r   r#   r$   )rG   r¤   rd   z&The head_mask should be specified for ú layers, but it is for ú.r¢   )r¬   r¥   c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wrÀ   rd   ©Ú.0Úvs     r;   ú	<genexpr>z(TFWhisperEncoder.call.<locals>.<genexpr>'  s   è ø€ Òe˜qÐWXÑWdœÑeùs   ‚Š©Úlast_hidden_stater¨   Ú
attentions)rÖ   Úoutput_attentionsÚoutput_hidden_statesÚuse_return_dictr,   r›   Úpadr   ÚactivationsÚgelur  r  r  rR   rþ   rz   r“   rB   r§   r   Úlenr  Ú	enumeraterû   rü   r  r  Útupler   )rm   rô   Ú	head_maskr)  r*  Úreturn_dictr¥   Úinputs_embedsÚ	embed_posr¨   Úencoder_statesÚall_attentionsÚidxÚencoder_layerÚdropout_probabilityÚattns                   r;   r}   zTFWhisperEncoder.callÍ  sœ  € ðD 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆô Ÿ™ n¸9ÔEˆÜŸ™ °!°Q°¸!¸Q¸À!ÀQÀÐ0HÓIˆÜ×)Ñ)×.Ñ.¨t¯z©z¸.Ó/IÓJˆÜŸ™˜}°°1¨v¸¸1°vÀÀ1¸vÐ.FÓGˆÜ×)Ñ)×.Ñ.¨t¯z©z¸-Ó/HÓIˆÜŸ™ ]¸ÔCˆà×(Ñ(´2·8±8¸QÀ×@YÑ@YÐ<ZÔbd×bjÑbjÔ3kÐ(Ólˆ	à%¨	Ñ1ˆØŸ™ ]¸X˜ÓFˆá3™¸ˆÙ0™°dˆð Ð Ü�L‰L×%Ñ%Ü˜9Ó% aÑ(Ü�D×'Ñ'Ó(à<¼SÀ×ATÑATÓ=UÐ<Vð WÜ" 9Ó-¨aÑ0Ð1°ð4ð	 &ô ô #,¨D×,?Ñ,?Ó"@ò 	*ÑˆC�Ù#Ø!/°=Ð2BÑ!B�ä"(§.¡.°°AÓ"6ÐÙÐ0°4·>±>ÒAØá"/ØØØ3<Ð3H ¨3¢ÈdØ!ô	#ÑˆM˜4ò !Ø 4 'Ñ)‘ð!	*ð$ Ÿ™¨Ó6ˆÙØ+¨}Ð.>Ñ>ˆNáÜÑe ]°NÀNÐ$SÔeÓeÐeÜ Ø+¸>ÐVdô
ð 	
r=   c                óŠ  — | j                   ry d| _         t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �K| j                  D ];  }t        j                  |j
                  «      5  |j                  d «       d d d «       Œ= y y # 1 sw Y   �Œ•xY w# 1 sw Y   �Œ;xY w# 1 sw Y   ŒíxY w# 1 sw Y   ŒˆxY w# 1 sw Y   Œ{xY w)NTr  r  r  r  r  )r¶   r·   r,   r¸   r  rr   rv   rý   r  r�   r  r  rÖ   rÎ   r  ©rm   rw   Úlayers      r;   rv   zTFWhisperEncoder.build,  sÕ  € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ BØ—
‘
× Ñ  $¨¨d×.?Ñ.?Ð!@ÔA÷Bä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ ?Ø—
‘
× Ñ  $¨¨d¯n©nÐ!=Ô>÷?ä�4Ð*¨DÓ1Ð=Ü—‘˜t×3Ñ3×8Ñ8Ó9ñ 1Ø×$Ñ$×*Ñ*¨4Ô0÷1ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ IØ—‘×%Ñ% t¨T°4·;±;×3FÑ3FÐ&GÔH÷Iä�4Ð)¨4Ó0Ð<Ø×,Ñ,ò &�Ü—]‘] 5§:¡:Ó.ñ &Ø—K‘K Ô%÷&ð &ñ&ð =÷Bñ Bú÷?ñ ?ú÷1ð 1ú÷Ið Iú÷&ð &ús<   Á)HÂ2)HÄH!Å33H-Ç)H9ÈHÈHÈ!H*È-H6È9I	rÝ   )NNNNNFrÀ   )
r‚   rƒ   r„   r   r  rf   r   r}   rv   r…   r†   s   @r;   r	  r	  ¥  sB   ø„ à €Lðõ<ð8 ð ØØØ!ØØò\
ó ð\
÷|&r=   r	  c                  ól   ‡ — e Zd ZeZ	 dˆ fd„Zd„ Zd„ Zd„ Ze		 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Z
d	d„Zˆ xZS )
ÚTFWhisperDecoderc                óf  •— t        ‰| �  di |¤Ž || _        t        j                  j                  |j                  «      | _        |j                  | _        |j                  | _
        |j                  | _        |j                  | _        |j                  rt        j                  |j                   «      nd| _        t        j                  j%                  |j&                  |j                   t        j(                  j+                  | j                  j,                  ¬«      d¬«      | _        t1        | j                  |j                   d¬«      | _        t5        |j6                  «      D �cg c]  }t9        |d|› �¬«      ‘Œ c}| _        t        j                  j;                  dd	¬
«      | _        y c c}w )Nr\   )ÚstddevÚembed_tokens)Ú	input_dimÚ
output_dimÚembeddings_initializerrr   r  rË   r  rÆ   r  rÈ   rd   )re   rf   rÖ   r   r‘   r’   r“   Údecoder_layerdropr  rH   ri   Úmax_target_positionsrþ   r  r*   r  rÎ   r  Ú	EmbeddingÚ
vocab_sizerj   ÚTruncatedNormalÚinit_stdrC  rb   r  r.   Údecoder_layersrà   rÑ   r  r  s       €r;   rf   zTFWhisperDecoder.__init__L  sO  ø€ Ü‰ÑÑ"˜6Ò"ØˆŒÜ—|‘|×+Ñ+¨F¯N©NÓ;ˆŒØ×1Ñ1ˆŒØ!×.Ñ.ˆÔØ$*×$?Ñ$?ˆÔ!Ø$*×$?Ñ$?ˆÔ!Ø8>×8NÒ8Nœ4Ÿ9™9 V§^¡^Ô4ÐTWˆÔä!ŸL™L×2Ñ2Ø×'Ñ'Ø—~‘~Ü#(×#5Ñ#5×#EÑ#EÈTÏ[É[×MaÑMaÐ#EÓ#bØð	 3ó 
ˆÔô  <Ø×%Ñ% v§~¡~Ð<Mô 
ˆÔô [`Ð`f×`uÑ`uÓZvÖwÐUVÔ4°VÀGÈAÈ3À-ÖPÒwˆÔäŸ,™,×9Ñ9À$È\Ð9ÓZˆ�ùò xs   Å(F.c                ó   — | j                   S rÀ   ©rC  rÿ   s    r;   Úget_input_embeddingsz%TFWhisperDecoder.get_input_embeddingsd  s   € Ø× Ñ Ð r=   c                ó   — || _         y rÀ   rO  ©rm   Úvalues     r;   Úset_input_embeddingsz%TFWhisperDecoder.set_input_embeddingsg  s
   € Ø!ˆÕr=   c                óÖ   ‡‡‡‡— ‰d   ‰d   cŠŠt        j                  t         j                  j                  ‰d«      ˆˆfd„ˆˆˆfd„«      }|�t	        |‰d   ¬«      }|€|n||z   }|S )Nr   r   c                 ó   •— t        ‰ ‰¬«      S )N©rU   )rZ   )rw   rU   s   €€r;   ú<lambda>zBTFWhisperDecoder._prepare_decoder_attention_mask.<locals>.<lambda>q  s   ø€ Ô% kÐJ`Ôa€ r=   c                 óN   •— t        t        j                  ‰ ‰‰z   f«      ‰¬«      S )N©rW   )r`   r,   rP   )Ú
batch_sizerU   r�   s   €€€r;   rX  zBTFWhisperDecoder._prepare_decoder_attention_mask.<locals>.<lambda>r  s#   ø€ ”L¤§¡¨*°gÐ@VÑ6VÐ)WÓ!XÐbiÔj€ r=   r&   rZ  )r,   Úcondr*   Úgreaterr`   )rm   r«   rw   rU   Úcombined_attention_maskÚexpanded_attn_maskr[  r�   s     ``  @@r;   Ú_prepare_decoder_attention_maskz0TFWhisperDecoder._prepare_decoder_attention_maskj  sy   û€ ð *¨!™n¨k¸!©nÐˆ
�Gä"$§'¡'Ü�G‰G�O‰O˜G QÓ'ÜaÝjó#
Ðð Ð%ä!-¨nÀkÐRTÁoÔ!VÐà&=Ð&EÑ"ÐK]Ð`wÑKwð $ð 'Ð&r=   c                óÎ  — |
�|
n| j                   j                  }
|�|n| j                   j                  }|	�|	n| j                   j                  }	|�|n| j                   j                  }|�|�t        d«      ‚|�1t        j                  |«      }t        j                  |d|d   f«      }n&|�t        j                  |«      dd }nt        d«      ‚|�t        j                  |d   d   «      d   nd}|€1t        || j                  j                  «       | j                  |«      }| j                  |||«      }|€|n|d   }| j                  ||¬«      }||z   }| j                  ||¬	«      }|rd
nd}|
rd
nd}|
r|�d
nd}|	rd
nd}d|fd|ffD ]r  \  }}|€Œ	t        j                  j!                  t#        |«      d   t%        | j&                  «      d|› dt%        | j&                  «      › dt#        |«      d   › d�¬«       Œt t)        | j&                  «      D ]ƒ  \  }}|r||fz  }t+        j,                  dd«      }|r|| j.                  k  rŒ6|�||   nd} |||||�||   nd|�||   nd||¬«      }|d   }|	r	||d   fz  }|
sŒo||d   fz  }|€Œ{||d   fz  }Œ… | j1                  |«      }|r||fz  }|	r|nd}|st3        d„ |||||fD «       «      S t5        |||||¬«      S )a"  
        Args:
            input_ids (`tf.Tensor` of shape `(batch_size, sequence_length)`):
                Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
                provide it.

                Indices can be obtained using [`WhisperTokenizer`]. See [`PreTrainedTokenizer.encode`] and
                [`PreTrainedTokenizer.__call__`] for details.

                [What are input IDs?](../glossary#input-ids)
            attention_mask (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
                Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

                - 1 for tokens that are **not masked**,
                - 0 for tokens that are **masked**.

                [What are attention masks?](../glossary#attention-mask)
            position_ids (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
                Indices of positions of each decoder input sequence tokens in the position embeddings. Selected in the
                range `[0, config.max_position_embeddings - 1]`.
            encoder_hidden_states (`tf.Tensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
                Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention
                of the decoder.
            head_mask (`tf.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
                Mask to nullify selected heads of the attention modules. Mask values selected in `[0, 1]`:

                - 1 indicates the head is **not masked**,
                - 0 indicates the head is **masked**.

            cross_attn_head_mask (`tf.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
                Mask to nullify selected heads of the attention modules in encoder to avoid performing cross-attention
                on hidden heads. Mask values selected in `[0, 1]`:

                - 1 indicates the head is **not masked**,
                - 0 indicates the head is **masked**.

            past_key_values (`tuple(tuple(tf.Tensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
                Tuple of `tuple(tf.Tensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
                `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
                `(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.

                Contains pre-computed hidden-states (key and values in the self-attention blocks and in the
                cross-attention blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.

                If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those
                that don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of
                all `decoder_input_ids` of shape `(batch_size, sequence_length)`.
            inputs_embeds (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
                Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation.
                This is useful if you want more control over how to convert `input_ids` indices into associated vectors
                than the model's internal embedding lookup matrix.
            output_attentions (`bool`, *optional*):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
            output_hidden_states (`bool`, *optional*):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more detail.
            return_dict (`bool`, *optional*):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        NzTYou cannot specify both decoder_input_ids and decoder_inputs_embeds at the same timer&   zEYou have to specify either decoder_input_ids or decoder_inputs_embedsr   r#   )r   r&   rW  r¤   rd   r2  Úcross_attn_head_maskzThe z should be specified for r  r   r¢   r   )r«   rè   r¬   rê   rª   r¥   r	   c              3  ó$   K  — | ]  }|�|–— Œ
 y ­wrÀ   rd   r"  s     r;   r%  z(TFWhisperDecoder.call.<locals>.<genexpr>#  s   è ø€ ò àØ�=ô ñùs   ‚)r'  Úpast_key_valuesr¨   r(  Úcross_attentions)rÖ   r)  r*  Ú	use_cacher+  r)   r,   r5   r0   r   rC  rD  r`  r  r“   rB   r§   r   r/  rM  r0  rû   rü   r  r  r1  r   )rm   rG   r«   Úposition_idsrè   r2  rb  rd  r4  rf  r)  r*  r3  r¥   rw   rU   Úfilled_past_positionsÚ	positionsr¨   Úall_hidden_statesÚall_self_attnsÚall_cross_attentionsÚnext_decoder_cacheÚattn_mask_nameÚ	attn_maskr8  Údecoder_layerr:  rª   Úlayer_outputsÚ
next_caches                                  r;   r}   zTFWhisperDecoder.call}  s¶  € ðZ 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð "+Ð!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø%0Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð Ð  ]Ð%>ÜÐsÓtÐtØÐ"ÜŸ(™( 9Ó-ˆKÜŸ
™
 9¨r°;¸r±?Ð.CÓD‰IØÐ&ÜŸ(™( =Ó1°#°2Ð6‰KäÐdÓeÐeð HWÐGb¤§¡¨/¸!Ñ*<¸QÑ*?Ó!@ÀÒ!CÐhiÐàÐ Ü*¨9°d×6GÑ6G×6QÑ6QÔRØ ×-Ñ-¨iÓ8ˆMà×=Ñ=¸nÈkÐ[qÓrˆð ;GÐ:NÑ 6ÐT`ÐafÑTgÐØ×(Ñ(¨ÐK`Ð(Óaˆ	à%¨	Ñ1ˆØŸ™ ]¸X˜ÓFˆñ #7™B¸DÐÙ0™°dˆÙ&7Ð<QÐ<]™rÐdhÐÙ#,™R°$Ðð ,7¸	Ð*BÐE[Ð]qÐDrÐ)sò 		Ñ%ˆN˜IØÑ$Ü—‘×)Ñ)Ü˜yÓ)¨!Ñ,Ü˜×+Ñ+Ó,à˜~Ð.Ð.GÌÈD×L_ÑL_ÓH`ÐGað b Ü *¨9Ó 5°aÑ 8Ð9¸ð<ð	 *õ ð		ô #,¨D×,?Ñ,?Ó"@ò 	@ÑˆC�á#Ø! mÐ%5Ñ5Ð!Ü"(§.¡.°°AÓ"6ÐÙÐ0°4·>±>ÒAØà5DÐ5P˜_¨SÒ1ÐVZˆNá)ØØ-Ø&;Ø3<Ð3H ¨3¢ÈdØI]ÐIiÐ,@ÀÒ,EÐosØ-Ø!ôˆMð *¨!Ñ,ˆMáØ" }°QÑ'7Ð&9Ñ9Ð"â Ø =°Ñ#3Ð"5Ñ5�à(Ñ4Ø(¨]¸1Ñ-=Ð,?Ñ?Ñ(ð9	@ð< Ÿ™¨Ó6ˆáØ -Ð!1Ñ1Ðá+4Ñ'¸$ˆ
ÙÜñ à'¨Ð5FÈÐXlÐmôó ð ô
 ;Ø+Ø&Ø+Ø%Ø1ô
ð 	
r=   c                óˆ  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �K| j                  D ];  }t        j                  |j
                  «      5  |j                  d «       d d d «       Œ= y y # 1 sw Y   �Œ.xY w# 1 sw Y   ŒàxY w# 1 sw Y   Œ{xY w# 1 sw Y   ŒnxY w)NTrC  r  r  rM  )r¶   r·   r,   r¸   rC  rr   rv   r  r  rÖ   rÎ   rM  r=  s      r;   rv   zTFWhisperDecoder.build0  su  € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó.Ð:Ü—‘˜t×0Ñ0×5Ñ5Ó6ñ .Ø×!Ñ!×'Ñ'¨Ô-÷.ä�4Ð*¨DÓ1Ð=Ü—‘˜t×3Ñ3×8Ñ8Ó9ñ 1Ø×$Ñ$×*Ñ*¨4Ô0÷1ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ IØ—‘×%Ñ% t¨T°4·;±;×3FÑ3FÐ&GÔH÷Iä�4Ð)¨4Ó0Ð<Ø×,Ñ,ò &�Ü—]‘] 5§:¡:Ó.ñ &Ø—K‘K Ô%÷&ð &ñ&ð =÷.ñ .ú÷1ð 1ú÷Ið Iú÷&ð &ús0   ÁFÂ%F Ã?3F,Å5F8ÆFÆ F)Æ,F5Æ8G	rÝ   )NNNNNNNNNNNNFrÀ   )r‚   rƒ   r„   r   r  rf   rP  rT  r`  r   r}   rv   r…   r†   s   @r;   r@  r@  B  sg   ø„ à €Lðõ[ò0!ò"ò'ð& ð ØØØ"ØØ!ØØØØØ!ØØòp
ó ðp
÷d&r=   r@  zUThe bare Whisper Model outputting raw hidden-states without any specific head on top.c                  ó¤   ‡ — e Zd ZeZd	ˆ fd„Zd„ Zd„ Zd„ Zd„ Z	 e
e«       eee¬«      e	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
d„«       «       «       Zdd„Zˆ xZS )ÚTFWhisperMainLayerc                óz   •— t        ‰| �  di |¤Ž || _        t        |d¬«      | _        t        |d¬«      | _        y )NÚencoderrË   Údecoderrd   )re   rf   rÖ   r	  rw  r@  rx  r×   s      €r;   rf   zTFWhisperMainLayer.__init__K  s6   ø€ Ü‰ÑÑ"˜6Ò"ØˆŒÜ'¨°YÔ?ˆŒÜ'¨°YÔ?ˆ�r=   c                ó.   — | j                   j                  S rÀ   ©rx  rC  rÿ   s    r;   rP  z'TFWhisperMainLayer.get_input_embeddingsQ  s   € Ø�|‰|×(Ñ(Ð(r=   c                ó&   — || j                   _        y rÀ   rz  rR  s     r;   rT  z'TFWhisperMainLayer.set_input_embeddingsT  s   € Ø$)ˆ�‰Õ!r=   c                ó   — | j                   S rÀ   )rw  rÿ   s    r;   Úget_encoderzTFWhisperMainLayer.get_encoderW  ó   € Ø�|‰|Ðr=   c                ó   — | j                   S rÀ   )rx  rÿ   s    r;   Úget_decoderzTFWhisperMainLayer.get_decoderZ  r~  r=   ©Úoutput_typer  c                ó®  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|€| j                  ||||||¬«      }nI|rGt        |t        «      s7t        |d   t        |«      dkD  r|d   ndt        |«      dkD  r|d   nd¬«      }| j                  ||||d   |||	|
|||||¬«      }|s||z   S t        |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  ¬«      S )	á“  
        Returns:

        Example:

         ```python
         >>> import tensorflow as tf
         >>> from transformers import TFWhisperModel, AutoFeatureExtractor
         >>> from datasets import load_dataset

         >>> model = TFWhisperModel.from_pretrained("openai/whisper-base")
         >>> feature_extractor = AutoFeatureExtractor.from_pretrained("openai/whisper-base")
         >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
         >>> inputs = feature_extractor(ds[0]["audio"]["array"], return_tensors="tf")
         >>> input_features = inputs.input_features
         >>> decoder_input_ids = tf.convert_to_tensor([[1, 1]]) * model.config.decoder_start_token_id
         >>> last_hidden_state = model(input_features, decoder_input_ids=decoder_input_ids).last_hidden_state
         >>> list(last_hidden_state.shape)
         [1, 2, 512]
         ```N)r2  r)  r*  r3  r¥   r   r   r#   r&  )rG   r«   rg  rè   r2  rb  rd  r4  rf  r)  r*  r3  r¥   ©r'  rd  Údecoder_hidden_statesÚdecoder_attentionsre  Úencoder_last_hidden_staterè   Úencoder_attentions)rÖ   r)  r*  rf  r+  rw  Ú
isinstancer   r/  rx  r   r'  rd  r¨   r(  re  )rm   rô   rù   r  Údecoder_position_idsr2  Údecoder_head_maskrb  Úencoder_outputsrd  Údecoder_inputs_embedsrf  r)  r*  r3  r¥   Údecoder_outputss                    r;   r}   zTFWhisperMainLayer.call]  sˆ  € ðR 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð "+Ð!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø%0Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆàÐ"Ø"Ÿl™lØØ#Ø"3Ø%9Ø'Ø!ð +ó ‰Oñ ¤¨OÔ=NÔ!OÜ/Ø"1°!Ñ"4Ü47¸Ó4HÈ1Ò4L˜o¨aÒ0ÐRVÜ14°_Ó1EÈÒ1I˜?¨1Ò-ÈtôˆOð Ÿ,™,Ø'Ø1Ø-Ø"1°!Ñ"4Ø'Ø!5Ø+Ø/ØØ/Ø!5Ø#Øð 'ó 
ˆñ  Ø" _Ñ4Ð4ä#Ø-×?Ñ?Ø+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô	
ð 		
r=   c                óÆ  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �Nt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       y y # 1 sw Y   ŒexY w# 1 sw Y   y xY w)NTrw  rx  )r¶   r·   r,   r¸   rw  rr   rv   rx  r¹   s     r;   rv   zTFWhisperMainLayer.build½  sµ   € Ø�:Š:ØØˆŒ
Ü�4˜ DÓ)Ð5Ü—‘˜tŸ|™|×0Ñ0Ó1ñ )Ø—‘×"Ñ" 4Ô(÷)ä�4˜ DÓ)Ð5Ü—‘˜tŸ|™|×0Ñ0Ó1ñ )Ø—‘×"Ñ" 4Ô(÷)ð )ð 6÷)ð )ú÷)ð )ús   ÁCÂ%CÃCÃC rÝ   ©NNNNNNNNNNNNNNFrÀ   )r‚   rƒ   r„   r   r  rf   rP  rT  r}  r€  r   ÚWHISPER_INPUTS_DOCSTRINGr   r   Ú_CONFIG_FOR_DOCr   r}   rv   r…   r†   s   @r;   ru  ru  C  s�   ø„ ð !€Lõ@ò)ò*òòñ +Ð+CÓDÙÐ+<È?Ô[Øð ØØ#Ø!ØØØ!ØØØ"ØØØ!ØØò![
ó ó \ó Eð[
÷z	)r=   ru  c                  óò   ‡ — e Zd Zdˆ fd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	 e
e«       eee¬«      e	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	„«       «       «       Zd
„ Zdd„Zˆ xZS )ÚTFWhisperModelc                óJ   •— t        ‰| �  |fi |¤Ž t        |d¬«      | _        y ©Nró   rË   ©re   rf   ru  ró   r×   s      €r;   rf   zTFWhisperModel.__init__Î  s#   ø€ Ü‰Ñ˜Ñ* 6Ò*ä'¨°WÔ=ˆ�
r=   c                óB   — | j                   j                  j                  S rÀ   ©ró   rx  rC  rÿ   s    r;   rP  z#TFWhisperModel.get_input_embeddingsÓ  s   € Ø�z‰z×!Ñ!×.Ñ.Ð.r=   c                ó:   — || j                   j                  _        y rÀ   rš  rR  s     r;   rT  z#TFWhisperModel.set_input_embeddingsÖ  s   € Ø*/ˆ�
‰
×ÑÕ'r=   c                ó.   — | j                   j                  S rÀ   ©ró   rw  rÿ   s    r;   r}  zTFWhisperModel.get_encoderÙ  ó   € Ø�z‰z×!Ñ!Ð!r=   c                ó.   — | j                   j                  S rÀ   ©ró   rx  rÿ   s    r;   r€  zTFWhisperModel.get_decoderÜ  rž  r=   c                ó.   — | j                   j                  S rÀ   r   rÿ   s    r;   rx  zTFWhisperModel.decoderß  rž  r=   c                ó.   — | j                   j                  S rÀ   r�  rÿ   s    r;   rw  zTFWhisperModel.encoderâ  rž  r=   r�  c                óF   — | j                  |||||||||	|
|||||¬«      }|S )r„  )rô   rù   r  r‹  r2  rŒ  rb  r�  rd  rŽ  rf  r)  r*  r3  r¥   )ró   )rm   rô   rù   r  r‹  r2  rŒ  rb  r�  rd  rŽ  rf  r)  r*  r3  r¥   Úoutputss                    r;   r}   zTFWhisperModel.callå  sL   € ðR —*‘*Ø)Ø/Ø#9Ø!5ØØ/Ø!5Ø+Ø+Ø"7ØØ/Ø!5Ø#Øð ó 
ˆð" ˆr=   c           
     óê  — | j                   j                  r"t        j                  |j                  «      d   nd }| j                   j
                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }| j                   j
                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }t        |j                  |||||j                  ||¬«      S )Nr   r…  )rÖ   rf  r,   r1  rd  r*  r@   r†  r)  r‡  re  rè   r‰  r   r'  rˆ  ©rm   ÚoutputÚpkvÚdec_hsÚ	dec_attnsÚcross_attnsÚenc_hsÚ	enc_attnss           r;   Úserving_outputzTFWhisperModel.serving_output!  s  € Ø59·[±[×5JÒ5JŒb�h‰h�v×-Ñ-Ó.¨qÒ1ÐPTˆØGKÇ{Á{×GgÒGg”×%Ñ% f×&BÑ&BÔCÐmqˆØGKÇ{Á{×GdÒGd”B×(Ñ(¨×)BÑ)BÔCÐjnˆ	ØGKÇ{Á{×GdÒGd”b×*Ñ*¨6×+BÑ+BÔCÐjnˆØGKÇ{Á{×GgÒGg”×%Ñ% f×&BÑ&BÔCÐmqˆØGKÇ{Á{×GdÒGd”B×(Ñ(¨×)BÑ)BÔCÐjnˆ	ä#Ø$×6Ñ6ØØ"(Ø(Ø(Ø&,×&FÑ&FØ"(Ø(ô	
ð 		
r=   c                óú   — | j                   ry d| _         t        | dd «      �Nt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       y y # 1 sw Y   y xY w©NTró   ©r¶   r·   r,   r¸   ró   rr   rv   r¹   s     r;   rv   zTFWhisperModel.build4  óg   € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ 'Ø—
‘
× Ñ  Ô&÷'ð 'ð 4÷'ð 'úó   ÁA1Á1A:rÝ   r‘  ) rô   úTFModelInputType | Nonerù   únp.ndarray | tf.Tensor | Noner  rµ  r‹  rµ  r2  rµ  rŒ  rµ  rb  rµ  r�  ú4Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]]rd  r¶  rŽ  ú-Optional[Tuple[Union[np.ndarray, tf.Tensor]]]rf  r¾   r)  r¾   r*  r¾   r3  r¾   r¥   r»   r¿   z-Union[Tuple[tf.Tensor], TFSeq2SeqModelOutput]rÀ   )r‚   rƒ   r„   rf   rP  rT  r}  r€  rx  rw  r   r’  r   r   r“  r   r}   r®  rv   r…   r†   s   @r;   r•  r•  É  s5  ø„ õ
>ò
/ò0ò"ò"ò"ò"ñ +Ð+CÓDÙÐ+?ÈoÔ^Øð 37Ø;?Ø@DØ>BØ37Ø;?Ø>BØPTØPTØOSØ$(Ø,0Ø/3Ø&*Øð!7à/ð7ð 9ð7ð !>ð	7ð
 <ð7ð 1ð7ð 9ð7ð <ð7ð Nð7ð Nð7ð  Mð7ð "ð7ð *ð7ð -ð7ð $ð7ð  ð!7ð" 
7ò#7ó ó _ó Eð7òr
÷&'r=   r•  z^The Whisper Model with a language modeling head. Can be used for automatic speech recognition.c                  ó`  ‡ — e Zd ZdZg d¢ZdgZdˆ fd„Zd„ Zd„ Zd„ Z	d„ Z
dˆ fd	„Z ee«       eee¬
«      e	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Z	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„Zd„ Z	 	 	 	 	 dd„Zdd„Zˆ xZS )Ú!TFWhisperForConditionalGenerationró   )zencoder.versionzdecoder.versionúproj_out.weightrº  c                óJ   •— t        ‰| �  |fi |¤Ž t        |d¬«      | _        y r—  r˜  r×   s      €r;   rf   z*TFWhisperForConditionalGeneration.__init__L  s#   ø€ Ü‰Ñ˜Ñ* 6Ò*Ü'¨°WÔ=ˆ�
r=   c                ó6   — | j                   j                  «       S rÀ   )ró   r}  rÿ   s    r;   r}  z-TFWhisperForConditionalGeneration.get_encoderP  ó   € Ø�z‰z×%Ñ%Ó'Ð'r=   c                ó6   — | j                   j                  «       S rÀ   )ró   r€  rÿ   s    r;   r€  z-TFWhisperForConditionalGeneration.get_decoderS  r½  r=   c                ó"   — | j                  «       S rÀ   )rP  rÿ   s    r;   Úget_output_embeddingsz7TFWhisperForConditionalGeneration.get_output_embeddingsV  s   € Ø×(Ñ(Ó*Ð*r=   c                ó&   — | j                  |«       y rÀ   )rT  rR  s     r;   Úset_output_embeddingsz7TFWhisperForConditionalGeneration.set_output_embeddingsY  s   € Ø×!Ñ! %Õ(r=   c                ó&   •— t         ‰| �  |«      }|S rÀ   )re   Úresize_token_embeddings)rm   Únew_num_tokensÚnew_embeddingsro   s      €r;   rÄ  z9TFWhisperForConditionalGeneration.resize_token_embeddings\  s   ø€ Ü™Ñ8¸ÓHˆØÐr=   r�  c                ó`  — |�|n| j                   j                  }|�9|€7|
€5t        || j                   j                  | j                   j                  «      }| j                  |||||||||	|
|||||¬«      }|d   }t        j                  || j                  «       j                  d¬«      }|€dn| j                  ||«      }|s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  |j                  |j                  |j                   |j"                  |j$                  ¬«	      S )aE  
        labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the language modeling loss. Indices should either be in `[0, ..., config.vocab_size]`
            or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored (masked), the loss is
            only computed for the tokens with labels in `[0, ..., config.vocab_size]`.

        Returns:

        Example:

        ```python
        >>> import tensorflow as tf
        >>> from transformers import AutoProcessor, TFWhisperForConditionalGeneration
        >>> from datasets import load_dataset

        >>> processor = AutoProcessor.from_pretrained("openai/whisper-tiny.en")
        >>> model = TFWhisperForConditionalGeneration.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="tf")
        >>> input_features = inputs.input_features

        >>> generated_ids = model.generate(input_features=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.'
        ```N)rù   r�  r  r‹  r2  rŒ  rb  rd  rŽ  rf  r)  r*  r3  r¥   r   Tr    r   )	ÚlossÚlogitsrd  r†  r‡  re  rˆ  rè   r‰  )rÖ   r+  rM   rH   rI   ró   r,   r¦   rÀ  ÚweightsÚhf_compute_lossr   rd  r†  r‡  re  rˆ  rè   r‰  )rm   rô   rù   r  r‹  r2  rŒ  rb  r�  rd  rŽ  Úlabelsrf  r)  r*  r3  r¥   r¤  Údecoder_last_hidden_stateÚ	lm_logitsrÈ  r§  s                         r;   r}   z&TFWhisperForConditionalGeneration.call`  sZ  € ðf &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆàÐØ Ð(Ð-BÐ-JÜ$6Ø˜DŸK™K×4Ñ4°d·k±k×6XÑ6Xó%Ð!ð —*‘*ØØ/Ø+Ø#9Ø!5ØØ/Ø!5Ø+Ø"7ØØ/Ø!5Ø#Øð ó 
ˆð" %,¨A¡JÐ!ä—I‘IÐ7¸×9SÑ9SÓ9U×9]Ñ9]ÐkoÔpˆ	à�~‰t¨4×+?Ñ+?ÀÈ	Ó+RˆáØ�\ G¨A¨B KÑ/ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä ØØØ#×3Ñ3Ø")×"?Ñ"?Ø&×9Ñ9Ø$×5Ñ5Ø&-×&GÑ&GØ")×"?Ñ"?Ø&×9Ñ9ô

ð 
	
r=   c           	     ó<
  •— |€| j                   }|�t        |d«      st        d«      ‚||_        nd|_        |�|j	                  «       }||_        |�||_        d}t        | j                  d«      r-| j                  j                  �| j                  j                  }nUt        | j                   d«      r-| j                   j                  �| j                   j                  }n|j                  dd«      }|€|€|�€C|	��@g }t        |d«      �rG|j
                  |j                  j                  «       v r|j
                  }n×|j
                  t        j                  «       v rdt        |j
                     › d�}nŸ|j
                  t        j                  «       v rd|j
                  › d�}nnt        |j
                  «      d	k(  }t        d
|j
                  › d|rt        t        j                  «       «      nt        t        j                  «       «      › d�«      ‚||j                  vrt        |› d�«      ‚|j!                  d|j                  |   f«       n|j!                  d«       t        |d«      r]|j                  t"        v r+|j!                  d	|j$                  |j                     f«       nLt        d|j                  › dt"        › d�«      ‚t        |d«      r |j!                  d	|j$                  d   f«       t        |d«      r8|j                  s,|r|d   d   dz   nd}|j!                  ||j&                  f«       |�||_        |	��(|j                  d«      �t        d«      ‚|	j)                  «       }	|	^}}|| j                  j*                   d	z  dz
  d }|j-                  d|i«       |j/                  dd«      xs |j/                  dd«      }|j0                  xs |j*                  }|xs |}|t        |«      z   |d<   |j/                  dd«      xs |j                  }g |¢|j2                  ‘|D ��cg c]  \  }}|‘Œ	 c}}¢}t5        |«      D ��cg c]  \  }}|dz   |f‘Œ }}}||_        |j                  rt        d«      ‚|
rFd|d<   d|d<   t7        |dd«      d k(  rt8        j;                  d!«       t        |d"«      st        d#«      ‚t=        ‰| �|  |||fi |¤Ž}|
r+t        |d"«      r| jA                  ||jB                  «      |d$<   |S c c}}w c c}}w )%aº  
        Generates sequences of token ids for models with a language modeling head.

        <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:
            inputs (`tf.Tensor` of varying shape depending on the modality, *optional*):
                The sequence used as a prompt for the generation or as model inputs to the encoder. If unset the method
                initializes it with `bos_token_id` and a batch size of 1. For decoder-only models `inputs` should of in
                the format of `input_ids`. For encoder-decoder models *inputs* can represent any of `input_ids`,
                `input_values`, `input_features`, or `pixel_values`.
            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.
            seed (`List[int]`, *optional*):
                Random seed to control sampling, containing two integers, used when `do_sample` is `True`. See the
                `seed` argument from stateless functions in `tf.random`.
            return_timestamps (`bool`, *optional*):
                Whether to return the timestamps with the text. This enables the `TFWhisperTimestampsLogitsProcessor`.
            task (`str`, *optional*):
                Task to use for generation, either "translate" or "transcribe". The `model.config.forced_decoder_ids`
                will be updated accordingly.
            language (`str`, *optional*):
                Language token to use for generation, can be either in the form of `<|en|>`, `en` or `english`. 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 (`tf.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.
            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.
            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 `tf.Tensor`: A [`~utils.ModelOutput`] (if `return_dict_in_generate=True` or when
            `config.return_dict_in_generate=True`) or a `tf.Tensor`.

                If the model is *not* an encoder-decoder model (`model.config.is_encoder_decoder=False`), the possible
                [`~utils.ModelOutput`] types are:

                    - [`~generation.TFGreedySearchDecoderOnlyOutput`],
                    - [`~generation.TFSampleDecoderOnlyOutput`],
                    - [`~generation.TFBeamSearchDecoderOnlyOutput`],
                    - [`~generation.TFBeamSampleDecoderOnlyOutput`]

                If the model is an encoder-decoder model (`model.config.is_encoder_decoder=True`), the possible
                [`~utils.ModelOutput`] types are:

                    - [`~generation.TFGreedySearchEncoderDecoderOutput`],
                    - [`~generation.TFSampleEncoderDecoderOutput`],
                    - [`~generation.TFBeamSearchEncoderDecoderOutput`],
                    - [`~generation.TFBeamSampleEncoderDecoderOutput`]

        NÚ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-1451902363FÚforced_decoder_idsÚlanguagez<|z|>r#   zUnsupported language: z. Language should be one of: r   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)r   )r   NÚtaskzThe `z3`task is not supported. The task should be one of `ú`Ú
task_to_idÚ
transcriber&   r   rI   zfWhen specifying `prompt_ids`, you cannot also specify `decoder_start_token_id` as it gets overwritten.Úmax_new_tokensÚ
max_lengthzQ`TFWhisperForConditionalGeneration` doesn't support returning the timestamps yet.Tr)  Úreturn_dict_in_generateÚ	translatez@Token-level timestamps may not be reliable for task 'translate'.Úalignment_headszÓ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.Útoken_timestamps)"Úgeneration_configÚhasattrr)   Úreturn_timestampsÚlowerrÒ  rÓ  rÖ   rÑ  rk   Ú
lang_to_idÚkeysr!   Úvaluesr/  ÚlistÚappendr    rÕ  rÐ  ÚtolistrØ  ÚupdateÚpopr×  rI   r0  r·   ÚloggerÚwarningre   ÚgenerateÚ_extract_token_timestampsrÛ  )rm   ÚinputsrÝ  Úlogits_processorÚseedrß  rÓ  rÒ  Úis_multilingualÚ
prompt_idsÚreturn_token_timestampsrn   rÑ  Úlanguage_tokenÚis_language_coder8  rI   Útext_prompt_idsÚspecified_max_lengthÚdefault_max_lengthÚnon_prompt_max_lengthÚnon_prompt_forced_decoder_idsÚ_rankÚtokenÚrankr¤  ro   s                             €r;   rë  z*TFWhisperForConditionalGeneration.generateÂ  s›  ø€ ðz Ð$Ø $× 6Ñ 6ÐàÐ(ÜÐ,Ð.FÔGÜ ðkóð ð 3DÐÕ/à27ÐÔ/àÐØ—~‘~Ó'ˆHØ)1ÐÔ&ØÐØ%)ÐÔ"à!Ðô �4—;‘;Ð 4Ô5¸$¿+¹+×:XÑ:XÐ:dØ!%§¡×!?Ñ!?Ñä�D×*Ñ*Ð,@ÔAØ×&Ñ&×9Ñ9ÐEà!%×!7Ñ!7×!JÑ!JÑà!'§¡Ð,@À$Ó!GÐàÐ˜xÐ3Ð8JÑ8RÐWaÑWmØ!#ÐÜÐ(¨*Õ5Ø$×-Ñ-Ð1B×1MÑ1M×1RÑ1RÓ1TÑTØ%6×%?Ñ%?‘NØ&×/Ñ/Ô3C×3HÑ3HÓ3JÑJØ')Ô*:Ð;L×;UÑ;UÑ*VÐ)WÐWYÐ%Z‘NØ&×/Ñ/Ô3C×3JÑ3JÓ3LÑLØ')Ð*;×*DÑ*DÐ)EÀRÐ%H‘Nä'*Ð+<×+EÑ+EÓ'FÈ!Ñ'KÐ$Ü$Ø0Ð1B×1KÑ1KÐ0Lð MÙ?OœDÔ!1×!8Ñ!8Ó!:Ô;ÔUYÔZj×ZoÑZoÓZqÓUrÐsÐstðvóð ð "Ð):×)EÑ)EÑEÜ$Ø)Ð*ð +Lð Lóð ð #×)Ñ)¨1Ð.?×.JÑ.JÈ>Ñ.ZÐ*[Õ\à"×)Ñ)¨)Ô4äÐ(¨&Ô1Ø$×)Ñ)¬XÑ5Ø&×-Ñ-¨qÐ2C×2NÑ2NÐO`×OeÑOeÑ2fÐ.gÕhä$ØÐ 1× 6Ñ 6Ð7Ð7jÔksÐjtÐtuÐvóð ô Ð*¨LÔ9Ø"×)Ñ)¨1Ð.?×.JÑ.JÈ<Ñ.XÐ*YÔZÜÐ(Ð*BÔCÐL]×LoÒLoÙ7IÐ(¨Ñ,¨QÑ/°!Ò3Èq�Ø"×)Ñ)¨3Ð0A×0XÑ0XÐ*YÔZàÐ)Ø3EÐÔ0àÑ!Ø�z‰zÐ2Ó3Ð?Ü Ø|óð ð $×*Ñ*Ó,ˆJØ7AÐ4Ð" _ð .¨t¯{©{×/EÑ/EÐ.EÈÑ.JÈQÑ.NÐ.PÐQˆOà�M‰MÐ3Ð5KÐLÔMð $*§:¡:Ð.>ÀÓ#EÒ#gÈÏÉÐT`ÐbfÓIgÐ Ø!2×!AÑ!AÒ!aÐEV×EaÑEaÐØ$8Ò$NÐ<NÐ!Ø'<¼sÀ?Ó?SÑ'SˆFÐ#Ñ$ð —
‘
Ð/°Ó6Ò^Ð:K×:^Ñ:^ð *ð"Ø ð"à!×8Ñ8ð"ð -J×J™L˜E 5’%ÓJð"Ðô
 HQÐQcÓGd×!e¹¸¸e 4¨!¡8¨UÒ"3Ð!eÐÑ!eØ3EÐÔ0ð ×.Ò.äÐpÓqÐqá"Ø*.ˆFÐ&Ñ'Ø04ˆFÐ,Ñ-äÐ(¨&°$Ó7¸;ÒFÜ—‘ÐaÔbÜÐ,Ð.?Ô@Ü ðRóð ô
 ‘'Ñ"ØØØñ
ð ñ	
ˆñ #¤wÐ/@ÐBSÔ'TØ*.×*HÑ*HÈÐRc×RsÑRsÓ*tˆGÐ&Ñ'àˆùóA Kùã!es   Ð8TÑTc           
     óê  — | j                   j                  r"t        j                  |j                  «      d   nd }| j                   j
                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }| j                   j
                  rt        j                  |j                  «      nd }| j                   j                  rt        j                  |j                  «      nd }t        |j                  |||||j                  ||¬«      S )Nr   )rÉ  rd  r†  r‡  re  rˆ  rè   r‰  )rÖ   rf  r,   r1  rd  r*  r@   r†  r)  r‡  re  rè   r‰  r   rÉ  rˆ  r¦  s           r;   r®  z0TFWhisperForConditionalGeneration.serving_output¥  s  € Ø59·[±[×5JÒ5JŒb�h‰h�v×-Ñ-Ó.¨qÒ1ÐPTˆØGKÇ{Á{×GgÒGg”×%Ñ% f×&BÑ&BÔCÐmqˆØGKÇ{Á{×GdÒGd”B×(Ñ(¨×)BÑ)BÔCÐjnˆ	ØGKÇ{Á{×GdÒGd”b×*Ñ*¨6×+BÑ+BÔCÐjnˆØGKÇ{Á{×GgÒGg”×%Ñ% f×&BÑ&BÔCÐmqˆØGKÇ{Á{×GdÒGd”B×(Ñ(¨×)BÑ)BÔCÐjnˆ	ä Ø—=‘=ØØ"(Ø(Ø(Ø&,×&FÑ&FØ"(Ø(ô	
ð 		
r=   c                ó@  — |�|d d …dd …f   }|�,t         j                  j                  |dd¬«      d d …dd …f   }n:|�|d   d   j                  d   }n"t        j                  |j                  d   «      }t        j
                  ||j                  «      }d ||||||dœS )Nr&   T)r(   Ú	exclusiver   r#   r   )rô   r�  rd  rù   rf  r  r‹  )r,   r*   Úcumsumr5   r.   Úbroadcast_to)	rm   rù   rd  rf  r�  r«   r  rn   r‹  s	            r;   Úprepare_inputs_for_generationz?TFWhisperForConditionalGeneration.prepare_inputs_for_generation¸  sÁ   € ð Ð&Ø 1²!°R±S°&Ñ 9Ðà!Ð-Ü#%§7¡7§>¡>Ð2HÈrÐ]a >Ó#bÒcdÐfhÑfiÐciÑ#jÑ ØÐ(Ø#2°1Ñ#5°aÑ#8×#>Ñ#>¸qÑ#AÑ ä#%§8¡8Ð,=×,CÑ,CÀAÑ,FÓ#GÐ Ü!Ÿ™Ð/CÐEV×E\ÑE\Ó]Ðð #Ø.Ø.Ø!2Ø"Ø&<Ø$8ñ
ð 	
r=   c                óú   — | j                   ry d| _         t        | dd «      �Nt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       y y # 1 sw Y   y xY wr°  r±  r¹   s     r;   rv   z'TFWhisperForConditionalGeneration.buildØ  r²  r³  rÝ   )rÅ  r   r¿   zkeras.layers.Embedding)NNNNNNNNNNNNNNNF)"rô   r´  rù   rµ  r  rµ  r‹  rµ  r2  rµ  rŒ  rµ  rb  rµ  r�  r¶  rd  r¶  rŽ  r·  rÌ  rµ  rf  r¾   r)  r¾   r*  r¾   r3  r¾   r¥   r»   r¿   z*Union[Tuple[tf.Tensor], TFSeq2SeqLMOutput])
NNNNNNNNNN)rí  úOptional[tf.Tensor]rÝ  zOptional[GenerationConfig]rî  zOptional[TFLogitsProcessorList]rï  zOptional[List[int]]rß  r¾   rÓ  úOptional[str]rÒ  r  rð  r¾   rñ  r  )NNNNNrÀ   )r‚   rƒ   r„   r  Ú_keys_to_ignore_on_load_missingÚ_keys_to_ignore_on_saverf   r}  r€  rÀ  rÂ  rÄ  r   r’  r   r   r“  r   r}   rë  r®  r  rv   r…   r†   s   @r;   r¹  r¹  =  s  ø„ ð
  Ðò'Ð#ð 	ðÐõ>ò(ò(ò+ò)õñ +Ð+CÓDÙÐ+<È?Ô[Øð 37Ø;?Ø@DØ>BØ37Ø;?Ø>BØPTØPTØOSØ04Ø$(Ø,0Ø/3Ø&*Øð#]
à/ð]
ð 9ð]
ð !>ð	]
ð
 <ð]
ð 1ð]
ð 9ð]
ð <ð]
ð Nð]
ð Nð]
ð  Mð]
ð .ð]
ð "ð]
ð *ð]
ð -ð]
ð  $ð!]
ð" ð#]
ð$ 
4ò%]
ó ó \ó Eð]
ðB '+Ø8<Ø<@Ø$(Ø,0Ø"Ø"&Ø*.Ø*.Ø $ðaà#ðað 6ðað :ð	að
 "ðað *ðað ðað  ðað (ðað (õaòF
ð, ØØØØ#ó
÷@'r=   r¹  )r¹  r•  rò   )r¿   r¼   )rG   r¼   rH   r   rI   r   r�   )rT   ztf.TensorShaperU   r   rÀ   )rX   r¼   rW   r€   )HrÁ   Ú
__future__r   r*   rû   Útypingr   r   r   r   r   ÚnumpyÚnpÚ
tensorflowr,   Úactivations_tfr
   Úgeneration.configuration_utilsr   Úgeneration.tf_logits_processr   Úmodeling_tf_outputsr   r   r   r   Úmodeling_tf_utilsr   r   r   r   r   r   Útf_utilsr   r   r   Úutilsr   r   r   r   Úconfiguration_whisperr   Útokenization_whisperr    r!   Ú
get_loggerr‚   ré  r“  rQ   r/   r<   rM   rZ   r`   r‘   ÚLayerrb   rˆ   rÃ   rà   rò   ÚWHISPER_START_DOCSTRINGr’  r	  r@  ru  r•  r¹  Ú__all__rd   r=   r;   ú<module>r     s  ðñ  å "ã Û ß 5Õ 5ã Û å /Ý >Ý A÷ó ÷÷ ÷ SÑ Rß tÓ tÝ 0ß <ð 
ˆ×	Ñ	˜HÓ	%€à!€ð €ð ,.¯:©:ô 
Yóô2;ô$
6ô6 5§<¡<×#5Ñ#5ô 6ô<iB˜Ÿ™×+Ñ+ô iBôZIJ˜EŸL™L×.Ñ.ô IJôZHJ˜EŸL™L×.Ñ.ô HJôV"
Ð0ô "
ðJÐ ð KÐ ð\ ôY&�u—|‘|×)Ñ)ó Y&ó ðY&ðx ô}&�u—|‘|×)Ñ)ó }&ó ð}&ñ@ Ø[Øóð ô~)˜Ÿ™×+Ñ+ó ~)ó ó	ð
~)ñB Ø[Øóôm'Ð-ó m'ó	ðm'ñ` ØdØóô]'Ð(@ÐB^ó ]'ó	ð]'ò@ ^�r=   