Ë
    S^(hóð  ã                  ó²  — d Z ddlmZ ddlmZmZmZ ddlZddl	Z
ddl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mZmZmZ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+  e)jX                  e-«      Z.dZ/dZ0 G d„ dejb                  jd                  «      Z3 G d„ dejb                  jd                  «      Z4 G d„ dejb                  jd                  «      Z5 G d„ dejb                  jd                  «      Z6 G d„ dejb                  jd                  «      Z7 G d„ dejb                  jd                  «      Z8 G d„ dejb                  jd                  «      Z9 G d„ dejb                  jd                  «      Z: G d„ d ejb                  jd                  «      Z; G d!„ d"ejb                  jd                  «      Z<e G d#„ d$ejb                  jd                  «      «       Z= G d%„ d&e«      Z>d'Z?d(Z@ e'd)e?«       G d*„ d+e>«      «       ZA G d,„ d-ejb                  jd                  «      ZB G d.„ d/ejb                  jd                  «      ZC e'd0e?«       G d1„ d2e>e«      «       ZD G d3„ d4ejb                  jd                  «      ZE e'd5e?«       G d6„ d7e>e«      «       ZF e'd8e?«       G d9„ d:e>e«      «       ZG e'd;e?«       G d<„ d=e>e«      «       ZH e'd>e?«       G d?„ d@e>e«      «       ZIg dA¢ZJy)BzTF 2.0 ConvBERT model.é    )Úannotations)ÚOptionalÚTupleÚUnionNé   )Úget_tf_activation)ÚTFBaseModelOutputÚTFMaskedLMOutputÚTFMultipleChoiceModelOutputÚTFQuestionAnsweringModelOutputÚTFSequenceClassifierOutputÚTFTokenClassifierOutput)ÚTFMaskedLanguageModelingLossÚTFModelInputTypeÚTFMultipleChoiceLossÚTFPreTrainedModelÚTFQuestionAnsweringLossÚTFSequenceClassificationLossÚTFSequenceSummaryÚTFTokenClassificationLossÚget_initializerÚkerasÚkeras_serializableÚunpack_inputs)Úcheck_embeddings_within_boundsÚ
shape_listÚstable_softmax)Úadd_code_sample_docstringsÚadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚloggingé   )ÚConvBertConfigzYituTech/conv-bert-baser#   c                  óX   ‡ — e Zd ZdZdˆ fd„Zdd„Z	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Zˆ xZS )	ÚTFConvBertEmbeddingszGConstruct the embeddings from word, position and token_type embeddings.c                óV  •— t        ‰| �  di |¤Ž || _        |j                  | _        |j                  | _        |j
                  | _        t        j                  j                  |j                  d¬«      | _
        t        j                  j                  |j                  ¬«      | _        y )NÚ	LayerNorm©ÚepsilonÚname)Úrate© )ÚsuperÚ__init__ÚconfigÚembedding_sizeÚmax_position_embeddingsÚinitializer_ranger   ÚlayersÚLayerNormalizationÚlayer_norm_epsr'   ÚDropoutÚhidden_dropout_probÚdropout©Úselfr/   ÚkwargsÚ	__class__s      €úo/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/convbert/modeling_tf_convbert.pyr.   zTFConvBertEmbeddings.__init__C   s…   ø€ Ü‰ÑÑ"˜6Ò"àˆŒØ$×3Ñ3ˆÔØ'-×'EÑ'EˆÔ$Ø!'×!9Ñ!9ˆÔÜŸ™×8Ñ8À×AVÑAVÐ]hÐ8ÓiˆŒÜ—|‘|×+Ñ+°×1KÑ1KÐ+ÓLˆ�ó    c                óÚ  — t        j                  d«      5  | j                  d| j                  j                  | j
                  gt        | j                  «      ¬«      | _        d d d «       t        j                  d«      5  | j                  d| j                  j                  | j
                  gt        | j                  «      ¬«      | _
        d d d «       t        j                  d«      5  | j                  d| j                  | j
                  gt        | j                  «      ¬«      | _        d d d «       | j                  ry d| _        t        | dd «      �et        j                  | j                  j                   «      5  | j                  j#                  d d | j                  j
                  g«       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   y xY w)	NÚword_embeddingsÚweight)r*   ÚshapeÚinitializerÚtoken_type_embeddingsÚ
embeddingsÚposition_embeddingsTr'   )ÚtfÚ
name_scopeÚ
add_weightr/   Ú
vocab_sizer0   r   r2   rA   Útype_vocab_sizerD   r1   rF   ÚbuiltÚgetattrr'   r*   Úbuild©r:   Úinput_shapes     r=   rN   zTFConvBertEmbeddings.buildM   s£  € Ü�]‰]Ð,Ó-ñ 	ØŸ/™/ØØ—{‘{×-Ñ-¨t×/BÑ/BÐCÜ+¨D×,BÑ,BÓCð *ó ˆDŒK÷	ô �]‰]Ð2Ó3ñ 	Ø)-¯©Ø!Ø—{‘{×2Ñ2°D×4GÑ4GÐHÜ+¨D×,BÑ,BÓCð *9ó *ˆDÔ&÷	ô �]‰]Ð0Ó1ñ 	Ø'+§¡Ø!Ø×3Ñ3°T×5HÑ5HÐIÜ+¨D×,BÑ,BÓCð (7ó (ˆDÔ$÷	ð �:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ OØ—‘×$Ñ$ d¨D°$·+±+×2LÑ2LÐ%MÔN÷Oð Oð 8÷1	ñ 	ú÷	ð 	ú÷	ð 	ú÷Oð Oús2   –AF<Â AG	Ã*AGÅ?3G!Æ<GÇ	GÇGÇ!G*c                ó>  — |€|€t        d«      ‚|�At        || j                  j                  «       t	        j
                  | j                  |¬«      }t        |«      dd }|€t	        j                  |d¬«      }|€2t	        j                  t	        j                  ||d   |z   ¬«      d¬	«      }t	        j
                  | j                  |¬«      }t	        j
                  | j                  |¬«      }	||z   |	z   }
| j                  |
¬
«      }
| j                  |
|¬«      }
|
S )z’
        Applies embedding based on inputs tensor.

        Returns:
            final_embeddings (`tf.Tensor`): output embedding tensor.
        Nz5Need to provide either `input_ids` or `input_embeds`.)ÚparamsÚindiceséÿÿÿÿr   )ÚdimsÚvaluer"   )ÚstartÚlimit©Úaxis)Úinputs)r[   Útraining)Ú
ValueErrorr   r/   rJ   rG   ÚgatherrA   r   ÚfillÚexpand_dimsÚrangerF   rD   r'   r8   )r:   Ú	input_idsÚposition_idsÚtoken_type_idsÚinputs_embedsÚpast_key_values_lengthr\   rP   Úposition_embedsÚtoken_type_embedsÚfinal_embeddingss              r=   ÚcallzTFConvBertEmbeddings.callk   s  € ð Ð Ð!6ÜÐTÓUÐUàÐ Ü*¨9°d·k±k×6LÑ6LÔMÜŸI™I¨T¯[©[À)ÔLˆMä  Ó/°°Ð4ˆàÐ!ÜŸW™W¨+¸QÔ?ˆNàÐÜŸ>™>Ü—‘Ð5¸[È¹^ÐNdÑ=dÔeÐlmôˆLô Ÿ)™)¨4×+CÑ+CÈ\ÔZˆÜŸI™I¨T×-GÑ-GÐQ_Ô`ÐØ(¨?Ñ:Ð=NÑNÐØŸ>™>Ð1A˜>ÓBÐØŸ<™<Ð/?È(˜<ÓSÐàÐr>   )r/   r#   ©N)NNNNr   F)rb   úOptional[tf.Tensor]rc   rl   rd   rl   re   rl   r\   ÚboolÚreturnz	tf.Tensor)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r.   rN   rj   Ú__classcell__©r<   s   @r=   r%   r%   @   sf   ø„ ÙQõMóOð@ *.Ø,0Ø.2Ø-1Ø Øð& à&ð& ð *ð& ð ,ð	& ð
 +ð& ð ð& ð 
÷& r>   r%   c                  ó4   ‡ — e Zd Zˆ fd„Zd„ Zdd„Zdd„Zˆ xZS )ÚTFConvBertSelfAttentionc           
     ó:  •— t        ‰| �  di |¤Ž |j                  |j                  z  dk7  r&t	        d|j                  › d|j                  › d�«      ‚t        |j                  |j                  z  «      }|dk  r|j                  | _        d}n|}|j                  | _        || _        |j                  | _        |j                  | j                  z  dk7  rt	        d«      ‚|j                  |j                  z  | _        | j                  | j                  z  | _	        t        j                  j                  | j                  t        |j                  «      d¬«      | _        t        j                  j                  | j                  t        |j                  «      d	¬«      | _        t        j                  j                  | j                  t        |j                  «      d
¬«      | _        t        j                  j%                  | j                  | j                  dd t        d| j                  z  «      t        |j                  «      d¬«      | _        t        j                  j                  | j                  | j                  z  d dt        |j                  «      ¬«      | _        t        j                  j                  | j                  d dt        |j                  «      ¬«      | _        t        j                  j-                  |j.                  «      | _        || _        y )Nr   zThe hidden size (z6) is not a multiple of the number of attention heads (ú)r"   z6hidden_size should be divisible by num_attention_headsÚquery©Úkernel_initializerr*   ÚkeyrV   ÚsameÚkey_conv_attn_layer)ÚpaddingÚ
activationÚdepthwise_initializerÚpointwise_initializerr*   Úconv_kernel_layer)r€   r*   r{   Úconv_out_layerr,   )r-   r.   Úhidden_sizeÚnum_attention_headsr]   ÚintÚ
head_ratioÚconv_kernel_sizeÚattention_head_sizeÚall_head_sizer   r3   ÚDenser   r2   ry   r|   rV   ÚSeparableConv1Dr~   rƒ   r„   r6   Úattention_probs_dropout_probr8   r/   )r:   r/   r;   Únew_num_attention_headsr†   r<   s        €r=   r.   z TFConvBertSelfAttention.__init__•   s¹  ø€ Ü‰ÑÑ"˜6Ò"à×Ñ × :Ñ :Ñ:¸aÒ?ÜØ# F×$6Ñ$6Ð#7ð 8Ø ×4Ñ4Ð5°Qð8óð ô
 #& f×&@Ñ&@À6×CTÑCTÑ&TÓ"UÐØ" QÒ&Ø$×8Ñ8ˆDŒOØ"#Ñà"9ÐØ$×/Ñ/ˆDŒOà#6ˆÔ Ø &× 7Ñ 7ˆÔà×Ñ × 8Ñ 8Ñ8¸AÒ=ÜÐUÓVÐVà#)×#5Ñ#5¸×9SÑ9SÑ#SˆÔ Ø!×5Ñ5¸×8PÑ8PÑPˆÔÜ—\‘\×'Ñ'Ø×Ñ´?À6×C[ÑC[Ó3\Ðcjð (ó 
ˆŒ
ô —<‘<×%Ñ%Ø×Ñ´?À6×C[ÑC[Ó3\Ðchð &ó 
ˆŒô —\‘\×'Ñ'Ø×Ñ´?À6×C[ÑC[Ó3\Ðcjð (ó 
ˆŒ
ô $)§<¡<×#?Ñ#?Ø×ÑØ×!Ñ!ØØÜ"1°!°d×6KÑ6KÑ2KÓ"LÜ"1°&×2JÑ2JÓ"KØ&ð $@ó $
ˆÔ ô "'§¡×!3Ñ!3Ø×$Ñ$ t×'<Ñ'<Ñ<ØØ$Ü.¨v×/GÑ/GÓHð	 "4ó "
ˆÔô $Ÿl™l×0Ñ0Ø×ÑØØ!Ü.¨v×/GÑ/GÓHð	 1ó 
ˆÔô —|‘|×+Ñ+¨F×,OÑ,OÓPˆŒØˆ�r>   c                ó�   — t        j                  ||d| j                  | j                  f«      }t        j                  |g d¢¬«      S )NrT   ©r   é   r"   r   ©Úperm)rG   Úreshaper†   rŠ   Ú	transpose)r:   ÚxÚ
batch_sizes      r=   Útranspose_for_scoresz,TFConvBertSelfAttention.transpose_for_scoresÓ   s8   € ä�J‰J�q˜: r¨4×+CÑ+CÀT×E]ÑE]Ð^Ó_ˆÜ�|‰|˜A¢LÔ1Ð1r>   c                ó�  — t        |«      d   }| j                  |«      }| j                  |«      }| j                  |«      }	| j	                  |«      }
| j                  ||«      }| j                  ||«      }t        j                  |
|«      }| j                  |«      }t        j                  |d| j                  dg«      }t        |d¬«      }t        j                  ddgt        | j                  dz
  dz  «      t        | j                  dz
  dz  «      gddgg«      }| j                  |«      }t        j                  ||d| j                  g«      }t        j                   ||d«      }t        j"                  t%        | j                  «      D �cg c]5  }t        j&                  |d|dg|t        |«      d   | j                  g«      ‘Œ7 c}d¬«      }t        j                  |d| j(                  | j                  g«      }t        j*                  ||«      }t        j                  |d| j                  g«      }t        j*                  ||d¬«      }t        j,                  t        |«      d   |j.                  «      }|t        j0                  j3                  |«      z  }|�||z   }t        |d¬«      }| j5                  ||¬	«      }|�||z  }t        j                  |	|d| j6                  | j(                  g«      }t        j8                  |g d
¢«      }t        j*                  ||«      }t        j8                  |g d
¢¬«      }t        j                  ||d| j6                  | j(                  g«      }t        j:                  ||gd«      }t        j                  ||d| j<                  | j                  z  f«      }|r||f}|S |f}|S c c}w )Nr   rT   r"   rY   r’   ÚCONSTANTT)Útranspose_b©r\   r‘   r“   )r   ry   r|   rV   r~   r™   rG   Úmultiplyrƒ   r•   r‰   r   Úconstantr‡   r„   r‹   ÚpadÚstackra   ÚslicerŠ   ÚmatmulÚcastÚdtypeÚmathÚsqrtr8   r†   r–   Úconcatrˆ   )r:   Úhidden_statesÚattention_maskÚ	head_maskÚoutput_attentionsr\   r˜   Úmixed_query_layerÚmixed_key_layerÚmixed_value_layerÚmixed_key_conv_attn_layerÚquery_layerÚ	key_layerÚconv_attn_layerrƒ   Úpaddingsr„   ÚiÚunfold_conv_out_layerÚattention_scoresÚdkÚattention_probsÚvalue_layerÚcontext_layerÚconv_outÚoutputss                             r=   rj   zTFConvBertSelfAttention.callØ   s›  € Ü Ó.¨qÑ1ˆ
Ø ŸJ™J }Ó5ÐØŸ(™( =Ó1ˆØ ŸJ™J }Ó5Ðà$(×$<Ñ$<¸]Ó$KÐ!à×/Ñ/Ð0AÀ:ÓNˆØ×-Ñ-¨o¸zÓJˆ	ÜŸ+™+Ð&?ÐARÓSˆà ×2Ñ2°?ÓCÐÜŸJ™JÐ'8¸2¸t×?TÑ?TÐVWÐ:XÓYÐÜ*Ð+<À1ÔEÐä—;‘;ð Øðô �d×+Ñ+¨aÑ/°1Ñ4Ó5´s¸D×<QÑ<QÐTUÑ<UÐYZÑ;ZÓ7[Ð\Ø�A�ðó	
ˆð ×,Ñ,¨]Ó;ˆÜŸ™ N°ZÀÀT×EWÑEWÐ4XÓYˆÜŸ™ °¸*ÓEˆä "§¡ô ˜t×4Ñ4Ó5öàô —‘˜¨!¨Q°¨°ZÄÐL]ÓA^Ð_`ÑAaÐcg×cuÑcuÐ4vÕwòð ô!
Ðô Ÿ™Ð$9¸BÀ×@XÑ@XÐZ^×ZoÑZoÐ;pÓqˆäŸ™ >Ð3DÓEˆÜŸ™ N°R¸×9KÑ9KÐ4LÓMˆô Ÿ9™9Ø˜°ô
Ðô �W‰W”Z 	Ó*¨2Ñ.Ð0@×0FÑ0FÓGˆØ+¬b¯g©g¯l©l¸2Ó.>Ñ>ÐàÐ%à/°.Ñ@Ðô )Ð)9ÀÔCˆð Ÿ,™, À˜,ÓJˆð Ð Ø-°	Ñ9ˆOä—j‘jØ 
¨B°×0HÑ0HÈ$×JbÑJbÐcó
ˆô —l‘l ;²Ó=ˆäŸ	™	 /°;Ó?ˆÜŸ™ ]ºÔFˆä—:‘:˜n¨z¸2¸t×?WÑ?WÐY]×YqÑYqÐ.rÓsˆÜŸ	™	 =°(Ð";¸QÓ?ˆÜŸ
™
Ø˜J¨¨D¯O©O¸d×>PÑ>PÑ,PÐQó
ˆñ 7H�= /Ð2ˆàˆð O\ÐM]ˆàˆùòcs   Æ:Oc                óþ  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  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 «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  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 «      �Zt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   �Œ7xY w# 1 sw Y   �ŒÓxY w# 1 sw Y   �ŒoxY w# 1 sw Y   �ŒxY w# 1 sw Y   Œ°xY w# 1 sw Y   y xY w)NTry   r|   rV   r~   rƒ   r„   )rL   rM   rG   rH   ry   r*   rN   r/   r…   r|   rV   r~   rƒ   r‹   r„   rO   s     r=   rN   zTFConvBertSelfAttention.build+  sg  € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hä�4˜ Ó%Ð1Ü—‘˜tŸx™xŸ}™}Ó-ñ FØ—‘—‘  d¨D¯K©K×,CÑ,CÐDÔE÷Fä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hä�4Ð.°Ó5ÐAÜ—‘˜t×7Ñ7×<Ñ<Ó=ñ VØ×(Ñ(×.Ñ.°°d¸D¿K¹K×<SÑ<SÐ/TÔU÷Vä�4Ð,¨dÓ3Ð?Ü—‘˜t×5Ñ5×:Ñ:Ó;ñ OØ×&Ñ&×,Ñ,¨d°D¸$×:LÑ:LÐ-MÔN÷Oä�4Ð)¨4Ó0Ð<Ü—‘˜t×2Ñ2×7Ñ7Ó8ñ QØ×#Ñ#×)Ñ)¨4°°t·{±{×7NÑ7NÐ*OÔP÷Qð Qð =÷Hñ Hú÷Fñ Fú÷Hñ Hú÷Vñ Vú÷Oð Oú÷Qð QúsH   Á3J3Â<3K Ä-3KÆ3KÈ)K'É63K3Ê3J=Ë K
ËKËK$Ë'K0Ë3K<©Frk   )ro   rp   rq   r.   r™   rj   rN   rs   rt   s   @r=   rv   rv   ”   s   ø„ ô<ò|2ó
Q÷fQr>   rv   c                  ó.   ‡ — e Zd Zˆ fd„Zdd„Zdd„Zˆ xZS )ÚTFConvBertSelfOutputc                óv  •— t        ‰| �  di |¤Ž t        j                  j	                  |j
                  t        |j                  «      d¬«      | _        t        j                  j                  |j                  d¬«      | _        t        j                  j                  |j                  «      | _        || _        y ©NÚdenserz   r'   r(   r,   )r-   r.   r   r3   rŒ   r…   r   r2   rÄ   r4   r5   r'   r6   r7   r8   r/   r9   s      €r=   r.   zTFConvBertSelfOutput.__init__D  sŽ   ø€ Ü‰ÑÑ"˜6Ò"ä—\‘\×'Ñ'Ø×Ñ´?À6×C[ÑC[Ó3\Ðcjð (ó 
ˆŒ
ô Ÿ™×8Ñ8À×AVÑAVÐ]hÐ8ÓiˆŒÜ—|‘|×+Ñ+¨F×,FÑ,FÓGˆŒØˆ�r>   c                óv   — | j                  |«      }| j                  ||¬«      }| j                  ||z   «      }|S ©Nr�   ©rÄ   r8   r'   ©r:   r©   Úinput_tensorr\   s       r=   rj   zTFConvBertSelfOutput.callN  ó;   € ØŸ
™
 =Ó1ˆØŸ™ ]¸X˜ÓFˆØŸ™ }°|Ñ'CÓDˆàÐr>   c                ó"  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY w©NTrÄ   r'   ©
rL   rM   rG   rH   rÄ   r*   rN   r/   r…   r'   rO   s     r=   rN   zTFConvBertSelfOutput.buildU  óÞ   € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hä�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ LØ—‘×$Ñ$ d¨D°$·+±+×2IÑ2IÐ%JÔK÷Lð Lð 8÷Hð Hú÷Lð Lúó   Á3C9Â<3DÃ9DÄDr¿   rk   ©ro   rp   rq   r.   rj   rN   rs   rt   s   @r=   rÁ   rÁ   C  s   ø„ ôó÷	Lr>   rÁ   c                  ó4   ‡ — e Zd Zˆ fd„Zd„ Zdd„Zdd„Zˆ xZS )ÚTFConvBertAttentionc                ól   •— t        ‰| �  di |¤Ž t        |d¬«      | _        t	        |d¬«      | _        y )Nr:   ©r*   Úoutputr,   )r-   r.   rv   Úself_attentionrÁ   Údense_outputr9   s      €r=   r.   zTFConvBertAttention.__init__b  s1   ø€ Ü‰ÑÑ"˜6Ò"ä5°fÀ6ÔJˆÔÜ0°¸hÔGˆÕr>   c                ó   — t         ‚rk   ©ÚNotImplementedError)r:   Úheadss     r=   Úprune_headszTFConvBertAttention.prune_headsh  s   € Ü!Ð!r>   c                ór   — | j                  |||||¬«      }| j                  |d   ||¬«      }|f|dd  z   }|S ©Nr�   r   r"   )rÖ   r×   )	r:   rÉ   rª   r«   r¬   r\   Úself_outputsÚattention_outputr½   s	            r=   rj   zTFConvBertAttention.callk  s\   € Ø×*Ñ*Ø˜.¨)Ð5FÐQYð +ó 
ˆð  ×,Ñ,¨\¸!©_¸lÐU]Ð,Ó^ÐØ#Ð%¨°Q°RÐ(8Ñ8ˆàˆ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)NTrÖ   r×   )rL   rM   rG   rH   rÖ   r*   rN   r×   rO   s     r=   rN   zTFConvBertAttention.buildt  s¾   € Ø�:Š:ØØˆŒ
Ü�4Ð)¨4Ó0Ð<Ü—‘˜t×2Ñ2×7Ñ7Ó8ñ 0Ø×#Ñ#×)Ñ)¨$Ô/÷0ä�4˜¨Ó.Ð:Ü—‘˜t×0Ñ0×5Ñ5Ó6ñ .Ø×!Ñ!×'Ñ'¨Ô-÷.ð .ð ;÷0ð 0ú÷.ð .úó   ÁCÂ%CÃCÃC r¿   rk   )ro   rp   rq   r.   rÜ   rj   rN   rs   rt   s   @r=   rÒ   rÒ   a  s   ø„ ôHò"ó÷	.r>   rÒ   c                  ó0   ‡ — e Zd Zˆ fd„Zdˆ fd„	Zd„ Zˆ xZS )ÚGroupedLinearLayerc                óÔ   •— t        ‰| �  di |¤Ž || _        || _        || _        || _        | j                  | j                  z  | _        | j                  | j                  z  | _        y ©Nr,   )r-   r.   Ú
input_sizeÚoutput_sizeÚ
num_groupsr{   Úgroup_in_dimÚgroup_out_dim)r:   rç   rè   ré   r{   r;   r<   s         €r=   r.   zGroupedLinearLayer.__init__�  s]   ø€ Ü‰ÑÑ"˜6Ò"Ø$ˆŒØ&ˆÔØ$ˆŒØ"4ˆÔØ ŸO™O¨t¯©Ñ>ˆÔØ!×-Ñ-°·±Ñ@ˆÕr>   c                ó"  •— | j                  d| j                  | j                  | j                  g| j                  d¬«      | _        | j                  d| j                  g| j                  | j                  d¬«      | _        t        ‰| �)  |«       y )NÚkernelT)rB   rC   Ú	trainableÚbias)rB   rC   r¥   rî   )rI   rë   rê   ré   r{   rí   rè   r¥   rï   r-   rN   ©r:   rP   r<   s     €r=   rN   zGroupedLinearLayer.buildŠ  sˆ   ø€ Ø—o‘oØØ×%Ñ% t×'8Ñ'8¸$¿/¹/ÐJØ×/Ñ/Øð	 &ó 
ˆŒð —O‘OØ˜4×+Ñ+Ð,¸$×:QÑ:QÐY]×YcÑYcÐosð $ó 
ˆŒ	ô 	‰‰�kÕ"r>   c                óà  — t        |«      d   }t        j                  t        j                  |d| j                  | j
                  g«      g d¢«      }t        j                  |t        j                  | j                  g d¢«      «      }t        j                  |g d¢«      }t        j                  ||d| j                  g«      }t        j                  j                  || j                  ¬«      }|S )Nr   rT   )r"   r   r’   )r’   r"   r   ©rV   rï   )r   rG   r–   r•   ré   rê   r£   rí   rè   ÚnnÚbias_addrï   )r:   r©   r˜   r—   s       r=   rj   zGroupedLinearLayer.call—  s©   € Ü Ó.¨qÑ1ˆ
Ü�L‰LœŸ™ M°B¸¿¹È×IZÑIZÐ3[Ó\Ò^gÓhˆÜ�I‰I�aœŸ™ d§k¡k²9Ó=Ó>ˆÜ�L‰L˜šIÓ&ˆÜ�J‰J�q˜: r¨4×+;Ñ+;Ð<Ó=ˆÜ�E‰E�N‰N ¨¯©ˆNÓ3ˆØˆr>   rk   )ro   rp   rq   r.   rN   rj   rs   rt   s   @r=   rä   rä   €  s   ø„ ôAõ#ör>   rä   c                  ó,   ‡ — e Zd Zˆ fd„Zd„ Zdd„Zˆ xZS )ÚTFConvBertIntermediatec                ó   •— t        ‰| �  di |¤Ž |j                  dk(  rEt        j                  j                  |j                  t        |j                  «      d¬«      | _	        nFt        |j                  |j                  |j                  t        |j                  «      d¬«      | _	        t        |j                  t        «      r"t        |j                  «      | _        || _        y |j                  | _        || _        y )Nr"   rÄ   rz   ©ré   r{   r*   r,   )r-   r.   ré   r   r3   rŒ   Úintermediate_sizer   r2   rÄ   rä   r…   Ú
isinstanceÚ
hidden_actÚstrr   Úintermediate_act_fnr/   r9   s      €r=   r.   zTFConvBertIntermediate.__init__¢  sÔ   ø€ Ü‰ÑÑ"˜6Ò"Ø×Ñ Ò!ÜŸ™×+Ñ+Ø×(Ñ(¼_ÈV×MeÑMeÓ=fÐmtð ,ó ˆD�Jô ,Ø×"Ñ"Ø×(Ñ(Ø!×,Ñ,Ü#2°6×3KÑ3KÓ#LØôˆDŒJô �f×'Ñ'¬Ô-Ü'8¸×9JÑ9JÓ'KˆDÔ$ð ˆ�ð (.×'8Ñ'8ˆDÔ$Øˆ�r>   c                óJ   — | j                  |«      }| j                  |«      }|S rk   )rÄ   rý   ©r:   r©   s     r=   rj   zTFConvBertIntermediate.call·  s&   € ØŸ
™
 =Ó1ˆØ×0Ñ0°Ó?ˆàÐr>   c                ó(  — | j                   ry d| _         t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   y xY w)NTrÄ   )	rL   rM   rG   rH   rÄ   r*   rN   r/   r…   rO   s     r=   rN   zTFConvBertIntermediate.build½  s}   € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hð Hð 4÷Hð Hús   Á3BÂBrk   rÐ   rt   s   @r=   rö   rö   ¡  s   ø„ ôò*÷Hr>   rö   c                  ó.   ‡ — e Zd Zˆ fd„Zdd„Zdd„Zˆ xZS )ÚTFConvBertOutputc                ó"  •— t        ‰| �  di |¤Ž |j                  dk(  rEt        j                  j                  |j                  t        |j                  «      d¬«      | _	        nFt        |j                  |j                  |j                  t        |j                  «      d¬«      | _	        t        j                  j                  |j                  d¬«      | _        t        j                  j                  |j                   «      | _        || _        y )Nr"   rÄ   rz   rø   r'   r(   r,   )r-   r.   ré   r   r3   rŒ   r…   r   r2   rÄ   rä   rù   r4   r5   r'   r6   r7   r8   r/   r9   s      €r=   r.   zTFConvBertOutput.__init__Ç  sÖ   ø€ Ü‰ÑÑ"˜6Ò"à×Ñ Ò!ÜŸ™×+Ñ+Ø×"Ñ"´Àv×G_ÑG_Ó7`Ðgnð ,ó ˆD�Jô ,Ø×(Ñ(Ø×"Ñ"Ø!×,Ñ,Ü#2°6×3KÑ3KÓ#LØôˆDŒJô Ÿ™×8Ñ8À×AVÑAVÐ]hÐ8ÓiˆŒÜ—|‘|×+Ñ+¨F×,FÑ,FÓGˆŒØˆ�r>   c                óv   — | j                  |«      }| j                  ||¬«      }| j                  ||z   «      }|S rÆ   rÇ   rÈ   s       r=   rj   zTFConvBertOutput.callÚ  rÊ   r>   c                ó"  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY w©NTr'   rÄ   )rL   rM   rG   rH   r'   r*   rN   r/   r…   rÄ   rù   rO   s     r=   rN   zTFConvBertOutput.buildá  sÞ   € Ø�:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ LØ—‘×$Ñ$ d¨D°$·+±+×2IÑ2IÐ%JÔK÷Lä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ NØ—
‘
× Ñ  $¨¨d¯k©k×.KÑ.KÐ!LÔM÷Nð Nð 4÷Lð Lú÷Nð NúrÏ   r¿   rk   rÐ   rt   s   @r=   r  r  Æ  s   ø„ ôó&÷	Nr>   r  c                  ó.   ‡ — e Zd Zˆ fd„Zdd„Zdd„Zˆ xZS )ÚTFConvBertLayerc                ó�   •— t        ‰| �  di |¤Ž t        |d¬«      | _        t	        |d¬«      | _        t        |d¬«      | _        y )NÚ	attentionrÔ   ÚintermediaterÕ   r,   )r-   r.   rÒ   r
  rö   r  r  Úbert_outputr9   s      €r=   r.   zTFConvBertLayer.__init__î  s?   ø€ Ü‰ÑÑ"˜6Ò"ä,¨V¸+ÔFˆŒÜ2°6ÀÔOˆÔÜ+¨F¸ÔBˆÕr>   c                ó˜   — | j                  |||||¬«      }|d   }| j                  |«      }| j                  |||¬«      }	|	f|dd  z   }
|
S rÞ   )r
  r  r  )r:   r©   rª   r«   r¬   r\   Úattention_outputsrà   Úintermediate_outputÚlayer_outputr½   s              r=   rj   zTFConvBertLayer.callõ  su   € Ø ŸN™NØ˜>¨9Ð6GÐRZð +ó 
Ðð -¨QÑ/ÐØ"×/Ñ/Ð0@ÓAÐØ×'Ñ'Ð(;Ð=MÐX`Ð'ÓaˆØ�/Ð$5°a°bÐ$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 «      �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   Œ¿xY w# 1 sw Y   ŒqxY w# 1 sw Y   y xY w)NTr
  r  r  )	rL   rM   rG   rH   r
  r*   rN   r  r  rO   s     r=   rN   zTFConvBertLayer.build   s	  € Ø�:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ +Ø—‘×$Ñ$ TÔ*÷+ä�4˜¨Ó.Ð:Ü—‘˜t×0Ñ0×5Ñ5Ó6ñ .Ø×!Ñ!×'Ñ'¨Ô-÷.ä�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ð -ð :÷+ð +ú÷.ð .ú÷-ð -úó$   ÁD%Â%D1Ã?D=Ä%D.Ä1D:Ä=Er¿   rk   rÐ   rt   s   @r=   r  r  í  s   ø„ ôCó	÷-r>   r  c                  ó0   ‡ — e Zd Zˆ fd„Z	 dd„Zdd„Zˆ xZS )ÚTFConvBertEncoderc                óš   •— t        ‰| �  di |¤Ž t        |j                  «      D �cg c]  }t	        |d|› �¬«      ‘Œ c}| _        y c c}w )Nzlayer_._rÔ   r,   )r-   r.   ra   Únum_hidden_layersr  Úlayer)r:   r/   r;   rµ   r<   s       €r=   r.   zTFConvBertEncoder.__init__  sA   ø€ Ü‰ÑÑ"˜6Ò"äLQÐRX×RjÑRjÓLkÖlÀq”o f°X¸a¸S°>ÖBÒlˆ�
ùÒls   ¨Ac                ó   — |rdnd }|rdnd }	t        | j                  «      D ].  \  }
}|r||fz   } |||||
   ||¬«      }|d   }|sŒ&|	|d   fz   }	Œ0 |r||fz   }|st        d„ |||	fD «       «      S t        |||	¬«      S )Nr,   r�   r   r"   c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wrk   r,   )Ú.0Úvs     r=   ú	<genexpr>z)TFConvBertEncoder.call.<locals>.<genexpr>3  s   è ø€ Òh˜qÐZ[ÑZgœÑhùs   ‚Š)Úlast_hidden_stater©   Ú
attentions)Ú	enumerater  Útupler	   )r:   r©   rª   r«   r¬   Úoutput_hidden_statesÚreturn_dictr\   Úall_hidden_statesÚall_attentionsrµ   Úlayer_moduleÚlayer_outputss                r=   rj   zTFConvBertEncoder.call  sÇ   € ñ #7™B¸DÐÙ0™°dˆä(¨¯©Ó4ò 
	F‰OˆAˆ|Ù#Ø$5¸Ð8HÑ$HÐ!á(Ø˜~¨y¸©|Ð=NÐYaôˆMð *¨!Ñ,ˆMâ Ø!/°=ÀÑ3CÐ2EÑ!E‘ð
	Fñ  Ø 1°]Ð4DÑ DÐáÜÑh ]Ð4EÀ~Ð$VÔhÓhÐhä Ø+Ð;LÐYgô
ð 	
r>   c                óô   — | j                   ry d| _         t        | dd «      �K| j                  D ];  }t        j                  |j
                  «      5  |j                  d «       d d d «       Œ= y y # 1 sw Y   ŒIxY w)NTr  )rL   rM   r  rG   rH   r*   rN   )r:   rP   r  s      r=   rN   zTFConvBertEncoder.build9  sp   € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3ØŸ™ò &�Ü—]‘] 5§:¡:Ó.ñ &Ø—K‘K Ô%÷&ð &ñ&ð 4÷&ð &ús   ÁA.Á.A7	r¿   rk   rÐ   rt   s   @r=   r  r    s   ø„ ômð ó"
÷H&r>   r  c                  ó,   ‡ — e Zd Zˆ fd„Zd„ Zdd„Zˆ xZS )Ú!TFConvBertPredictionHeadTransformc                ó¦  •— t        ‰| �  di |¤Ž t        j                  j	                  |j
                  t        |j                  «      d¬«      | _        t        |j                  t        «      rt        |j                  «      | _        n|j                  | _        t        j                  j                  |j                  d¬«      | _        || _        y rÃ   )r-   r.   r   r3   rŒ   r0   r   r2   rÄ   rú   rû   rü   r   Útransform_act_fnr4   r5   r'   r/   r9   s      €r=   r.   z*TFConvBertPredictionHeadTransform.__init__D  s£   ø€ Ü‰ÑÑ"˜6Ò"ä—\‘\×'Ñ'Ø×!Ñ!´oÀf×F^ÑF^Ó6_Ðfmð (ó 
ˆŒ
ô �f×'Ñ'¬Ô-Ü$5°f×6GÑ6GÓ$HˆDÕ!à$*×$5Ñ$5ˆDÔ!äŸ™×8Ñ8À×AVÑAVÐ]hÐ8ÓiˆŒØˆ�r>   c                ól   — | j                  |«      }| j                  |«      }| j                  |«      }|S rk   )rÄ   r+  r'   rÿ   s     r=   rj   z&TFConvBertPredictionHeadTransform.callS  s4   € ØŸ
™
 =Ó1ˆØ×-Ñ-¨mÓ<ˆØŸ™ }Ó5ˆàÐr>   c                ó"  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY wrÌ   rÍ   rO   s     r=   rN   z'TFConvBertPredictionHeadTransform.buildZ  rÎ   rÏ   rk   rÐ   rt   s   @r=   r)  r)  C  s   ø„ ôò÷	Lr>   r)  c                  ón   ‡ — e Zd ZeZˆ fd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
e	 	 	 	 	 	 	 	 	 	 d	d„«       Zd
d„Zˆ xZS )ÚTFConvBertMainLayerc                ó  •— t        ‰| �  di |¤Ž t        |d¬«      | _        |j                  |j
                  k7  r0t        j                  j                  |j
                  d¬«      | _	        t        |d¬«      | _        || _        y )NrE   rÔ   Úembeddings_projectÚencoderr,   )r-   r.   r%   rE   r0   r…   r   r3   rŒ   r1  r  r2  r/   r9   s      €r=   r.   zTFConvBertMainLayer.__init__j  sm   ø€ Ü‰ÑÑ"˜6Ò"ä.¨v¸LÔIˆŒà× Ñ  F×$6Ñ$6Ò6Ü&+§l¡l×&8Ñ&8¸×9KÑ9KÐRfÐ&8Ó&gˆDÔ#ä(¨°iÔ@ˆŒØˆ�r>   c                ó   — | j                   S rk   )rE   ©r:   s    r=   Úget_input_embeddingsz(TFConvBertMainLayer.get_input_embeddingsu  s   € Ø�‰Ðr>   c                ób   — || j                   _        |j                  d   | j                   _        y ©Nr   )rE   rA   rB   rJ   ©r:   rV   s     r=   Úset_input_embeddingsz(TFConvBertMainLayer.set_input_embeddingsx  s"   € Ø!&ˆ�‰ÔØ%*§[¡[°¡^ˆ�‰Õ"r>   c                ó   — t         ‚)z�
        Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer} See base
        class PreTrainedModel
        rÙ   )r:   Úheads_to_prunes     r=   Ú_prune_headsz TFConvBertMainLayer._prune_heads|  s
   € ô
 "Ð!r>   c                ó²   — |€t        j                  |d«      }t        j                  ||d   dd|d   f«      }t        j                  ||«      }d|z
  dz  }|S )Nr"   r   g      ð?g     ˆÃÀ)rG   r_   r•   r¤   )r:   rª   rP   r¥   Úextended_attention_masks        r=   Úget_extended_attention_maskz/TFConvBertMainLayer.get_extended_attention_maskƒ  sk   € ØÐ!ÜŸW™W [°!Ó4ˆNô #%§*¡*¨^¸kÈ!¹nÈaÐQRÐT_Ð`aÑTbÐ=cÓ"dÐô #%§'¡'Ð*AÀ5Ó"IÐØ#&Ð)@Ñ#@ÀHÑ"LÐà&Ð&r>   c                óJ   — |�t         ‚d g| j                  j                  z  }|S rk   )rÚ   r/   r  )r:   r«   s     r=   Úget_head_maskz!TFConvBertMainLayer.get_head_mask˜  s*   € ØÐ Ü%Ð%à˜ §¡×!>Ñ!>Ñ>ˆIàÐr>   c           	     óÎ  — |�|�t        d«      ‚|�t        |«      }n|�t        |«      d d }nt        d«      ‚|€t        j                  |d«      }|€t        j                  |d«      }| j	                  |||||
¬«      }| j                  |||j                  «      }| j                  |«      }t        | d«      r| j                  ||
¬«      }| j                  ||||||	|
¬«      }|S )NzDYou cannot specify both input_ids and inputs_embeds at the same timerT   z5You have to specify either input_ids or inputs_embedsr"   r   r�   r1  )r]   r   rG   r_   rE   r?  r¥   rA  Úhasattrr1  r2  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  r\   rP   r©   r>  s                 r=   rj   zTFConvBertMainLayer.call   s  € ð Ð  ]Ð%>ÜÐcÓdÐdØÐ"Ü$ YÓ/‰KØÐ&Ü$ ]Ó3°C°RÐ8‰KäÐTÓUÐUàÐ!ÜŸW™W [°!Ó4ˆNàÐ!ÜŸW™W [°!Ó4ˆNàŸ™¨	°<ÀÐQ^Ðiq˜ÓrˆØ"&×"BÑ"BÀ>ÐS^Ð`m×`sÑ`sÓ"tÐØ×&Ñ& yÓ1ˆ	ä�4Ð-Ô.Ø ×3Ñ3°MÈHÐ3ÓUˆMàŸ™ØØ#ØØØ ØØð %ó 
ˆð Ð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 «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   ŒÖxY w# 1 sw Y   ŒˆxY w# 1 sw Y   y xY w)NTrE   r2  r1  )rL   rM   rG   rH   rE   r*   rN   r2  r1  r/   r0   rO   s     r=   rN   zTFConvBertMainLayer.buildÐ  s  € Ø�:Š:ØØˆŒ
Ü�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ ,Ø—‘×%Ñ% dÔ+÷,ä�4˜ DÓ)Ð5Ü—‘˜tŸ|™|×0Ñ0Ó1ñ )Ø—‘×"Ñ" 4Ô(÷)ä�4Ð-¨tÓ4Ð@Ü—‘˜t×6Ñ6×;Ñ;Ó<ñ XØ×'Ñ'×-Ñ-¨t°T¸4¿;¹;×;UÑ;UÐ.VÔW÷Xð Xð A÷,ð ,ú÷)ð )ú÷Xð Xúó$   ÁD<Â%EÃ?3EÄ<EÅEÅE©
NNNNNNNNNFrk   )ro   rp   rq   r#   Úconfig_classr.   r5  r9  r<  r?  rA  r   rj   rN   rs   rt   s   @r=   r/  r/  f  sa   ø„ à!€Lô	òò4ò"ò'ò*ð ð ØØØØØØØ!ØØò-ó ð-÷^Xr>   r/  c                  ó   — e Zd ZdZeZdZy)ÚTFConvBertPreTrainedModelz†
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    ÚconvbertN)ro   rp   rq   rr   r#   rG  Úbase_model_prefixr,   r>   r=   rI  rI  ß  s   „ ñð
 "€LØ"Ñr>   rI  ax	  

    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.

    <Tip>

    TensorFlow models and layers in `transformers` accept two formats as input:

    - having all inputs as keyword arguments (like PyTorch models), or
    - having all inputs as a list, tuple or dict in the first positional argument.

    The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
    and layers. Because of this support, when using methods like `model.fit()` things should "just work" for you - just
    pass your inputs and labels in any format that `model.fit()` supports! If, however, you want to use the second
    format outside of Keras methods like `fit()` and `predict()`, such as when creating your own layers or models with
    the Keras `Functional` API, there are three possibilities you can use to gather all the input Tensors in the first
    positional argument:

    - a single Tensor with `input_ids` only and nothing else: `model(input_ids)`
    - a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
    `model([input_ids, attention_mask])` or `model([input_ids, attention_mask, token_type_ids])`
    - a dictionary with one or several input Tensors associated to the input names given in the docstring:
    `model({"input_ids": input_ids, "token_type_ids": token_type_ids})`

    Note that when creating models and layers with
    [subclassing](https://keras.io/guides/making_new_layers_and_models_via_subclassing/) then you don't need to worry
    about any of this, as you can just pass inputs like you would to any other Python function!

    </Tip>

    Args:
        config ([`ConvBertConfig`]): 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 [`~PreTrainedModel.from_pretrained`] method to load the model weights.
a•  
    Args:
        input_ids (`Numpy array` or `tf.Tensor` of shape `({0})`):
            Indices of input sequence tokens in the vocabulary.

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

            [What are input IDs?](../glossary#input-ids)
        attention_mask (`Numpy array` or `tf.Tensor` of shape `({0})`, *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)
        token_type_ids (`Numpy array` or `tf.Tensor` of shape `({0})`, *optional*):
            Segment token indices to indicate first and second portions of the inputs. Indices are selected in `[0,
            1]`:

            - 0 corresponds to a *sentence A* token,
            - 1 corresponds to a *sentence B* token.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`Numpy array` or `tf.Tensor` of shape `({0})`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.max_position_embeddings - 1]`.

            [What are position IDs?](../glossary#position-ids)
        head_mask (`Numpy array` or `tf.Tensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
            Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

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

        inputs_embeds (`tf.Tensor` of shape `({0}, 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. This argument can be used only in eager mode, in graph mode the value in the
            config will be used instead.
        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. This argument can be used only in eager mode, in graph mode the value in the config will be
            used instead.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. This argument can be used in
            eager mode, in graph mode the value will always be set to True.
        training (`bool`, *optional*, defaults to `False`):
            Whether or not to use the model in training mode (some modules like dropout modules have different
            behaviors between training and evaluation).
zbThe bare ConvBERT Model transformer outputting raw hidden-states without any specific head on top.c                  óÈ   ‡ — e Zd Zˆ fd„Ze eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zdd„Zˆ xZS )	ÚTFConvBertModelc                óP   •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        y )NrJ  rÔ   )r-   r.   r/  rJ  ©r:   r/   r[   r;   r<   s       €r=   r.   zTFConvBertModel.__init__P  s(   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3ä+¨F¸ÔDˆ�r>   úbatch_size, sequence_length©Ú
checkpointÚoutput_typerG  c                ó<   — | j                  |||||||||	|
¬«
      }|S )N©
rb   rª   rd   rc   r«   re   r¬   r!  r"  r\   )rJ  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  r\   r½   s               r=   rj   zTFConvBertModel.callU  s<   € ð( —-‘-ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#Øð  ó 
ˆð ˆ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)NTrJ  )rL   rM   rG   rH   rJ  r*   rN   rO   s     r=   rN   zTFConvBertModel.buildx  si   € Ø�:Š:ØØˆŒ
Ü�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ *Ø—‘×#Ñ# DÔ)÷*ð *ð 7÷*ð *ús   ÁA1Á1A:rF  )rb   úTFModelInputType | Nonerª   ú$Optional[Union[np.array, tf.Tensor]]rd   rX  rc   rX  r«   rX  re   útf.Tensor | Noner¬   úOptional[bool]r!  rZ  r"  rZ  r\   rm   rn   z*Union[TFBaseModelOutput, Tuple[tf.Tensor]]rk   )ro   rp   rq   r.   r   r    ÚCONVBERT_INPUTS_DOCSTRINGÚformatr   Ú_CHECKPOINT_FOR_DOCr	   Ú_CONFIG_FOR_DOCrj   rN   rs   rt   s   @r=   rM  rM  K  sß   ø„ ô
Eð
 Ù*Ð+D×+KÑ+KÐLiÓ+jÓkÙØ&Ø%Ø$ôð .2Ø?CØ?CØ=AØ:>Ø*.Ø,0Ø/3Ø&*Øðà*ðð =ðð =ð	ð
 ;ðð 8ðð (ðð *ðð -ðð $ðð ðð 
4òóó ló ð÷8*r>   rM  c                  óF   ‡ — e Zd Zˆ fd„Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	ˆ xZ
S )ÚTFConvBertMaskedLMHeadc                ób   •— t        ‰| �  di |¤Ž || _        |j                  | _        || _        y ræ   )r-   r.   r/   r0   Úinput_embeddings)r:   r/   rb  r;   r<   s       €r=   r.   zTFConvBertMaskedLMHead.__init__‚  s0   ø€ Ü‰ÑÑ"˜6Ò"àˆŒØ$×3Ñ3ˆÔØ 0ˆÕr>   c                ó‚   •— | j                  | j                  j                  fddd¬«      | _        t        ‰| �  |«       y )NÚzerosTrï   )rB   rC   rî   r*   )rI   r/   rJ   rï   r-   rN   rð   s     €r=   rN   zTFConvBertMaskedLMHead.build‰  s7   ø€ Ø—O‘O¨4¯;©;×+AÑ+AÐ*CÐQXÐdhÐou�OÓvˆŒ	ä‰‰�kÕ"r>   c                ó   — | j                   S rk   )rb  r4  s    r=   Úget_output_embeddingsz,TFConvBertMaskedLMHead.get_output_embeddingsŽ  s   € Ø×$Ñ$Ð$r>   c                ó`   — || j                   _        t        |«      d   | j                   _        y r7  )rb  rA   r   rJ   r8  s     r=   Úset_output_embeddingsz,TFConvBertMaskedLMHead.set_output_embeddings‘  s(   € Ø',ˆ×ÑÔ$Ü+5°eÓ+<¸QÑ+?ˆ×ÑÕ(r>   c                ó   — d| j                   iS )Nrï   )rï   r4  s    r=   Úget_biaszTFConvBertMaskedLMHead.get_bias•  s   € Ø˜Ÿ	™	Ð"Ð"r>   c                óX   — |d   | _         t        |d   «      d   | j                  _        y )Nrï   r   )rï   r   r/   rJ   r8  s     r=   Úset_biaszTFConvBertMaskedLMHead.set_bias˜  s'   € Ø˜&‘MˆŒ	Ü!+¨E°&©MÓ!:¸1Ñ!=ˆ�‰Õr>   c                ót  — t        |¬«      d   }t        j                  |d| j                  g¬«      }t        j                  || j
                  j                  d¬«      }t        j                  |d|| j                  j                  g¬«      }t        j                  j                  || j                  ¬«      }|S )N)Útensorr"   rT   )rn  rB   T)ÚaÚbrœ   rò   )r   rG   r•   r0   r£   rb  rA   r/   rJ   ró   rô   rï   )r:   r©   Ú
seq_lengths      r=   rj   zTFConvBertMaskedLMHead.callœ  s�   € Ü }Ô5°aÑ8ˆ
ÜŸ
™
¨-ÀÀD×DWÑDWÐ?XÔYˆÜŸ	™	 M°T×5JÑ5J×5QÑ5QÐ_cÔdˆÜŸ
™
¨-ÀÀJÐPT×P[ÑP[×PfÑPfÐ?gÔhˆÜŸ™Ÿ™¨]ÀÇÁ˜ÓKˆàÐr>   )ro   rp   rq   r.   rN   rf  rh  rj  rl  rj   rs   rt   s   @r=   r`  r`  �  s'   ø„ ô1ô#ò
%ò@ò#ò>ör>   r`  c                  ó.   ‡ — e Zd Zˆ fd„Zdd„Zdd„Zˆ xZS )ÚTFConvBertGeneratorPredictionsc                óò   •— t        ‰| �  di |¤Ž t        j                  j	                  |j
                  d¬«      | _        t        j                  j                  |j                  d¬«      | _	        || _
        y )Nr'   r(   rÄ   rÔ   r,   )r-   r.   r   r3   r4   r5   r'   rŒ   r0   rÄ   r/   r9   s      €r=   r.   z'TFConvBertGeneratorPredictions.__init__§  s]   ø€ Ü‰ÑÑ"˜6Ò"äŸ™×8Ñ8À×AVÑAVÐ]hÐ8ÓiˆŒÜ—\‘\×'Ñ'¨×(=Ñ(=ÀGÐ'ÓLˆŒ
Øˆ�r>   c                ól   — | j                  |«      } t        d«      |«      }| j                  |«      }|S )NÚgelu)rÄ   r   r'   )r:   Úgenerator_hidden_statesr\   r©   s       r=   rj   z#TFConvBertGeneratorPredictions.call®  s7   € ØŸ
™
Ð#:Ó;ˆØ1Ô)¨&Ó1°-Ó@ˆØŸ™ }Ó5ˆàÐr>   c                ó"  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY wr  )rL   rM   rG   rH   r'   r*   rN   r/   r0   rÄ   r…   rO   s     r=   rN   z$TFConvBertGeneratorPredictions.buildµ  sÞ   € Ø�:Š:ØØˆŒ
Ü�4˜ dÓ+Ð7Ü—‘˜tŸ~™~×2Ñ2Ó3ñ OØ—‘×$Ñ$ d¨D°$·+±+×2LÑ2LÐ%MÔN÷Oä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hð Hð 4÷Oð Oú÷Hð HúrÏ   r¿   rk   rÐ   rt   s   @r=   rs  rs  ¦  s   ø„ ôó÷	Hr>   rs  z6ConvBERT Model with a `language modeling` head on top.c                  óÚ   ‡ — e Zd Zˆ fd„Zd„ Zd„ Ze eej                  d«      «       e
eee¬«      	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	d„«       «       «       Zd
d„Zˆ xZS )ÚTFConvBertForMaskedLMc                óV  •— t        ‰| �  |fi |¤Ž || _        t        |d¬«      | _        t        |d¬«      | _        t        |j                  t        «      rt        |j                  «      | _        n|j                  | _        t        || j                  j                  d¬«      | _        y )NrJ  rÔ   Úgenerator_predictionsÚgenerator_lm_head)r-   r.   r/   r/  rJ  rs  r|  rú   rû   rü   r   r€   r`  rE   r}  rO  s       €r=   r.   zTFConvBertForMaskedLM.__init__Ã  s…   ø€ Ü‰Ñ˜Ñ* 6Ò*àˆŒÜ+¨F¸ÔDˆŒÜ%CÀFÐQhÔ%iˆÔ"ä�f×'Ñ'¬Ô-Ü/°×0AÑ0AÓBˆD�Oà$×/Ñ/ˆDŒOä!7¸ÀÇÁ×@XÑ@XÐ_rÔ!sˆÕr>   c                ó   — | j                   S rk   )r}  r4  s    r=   Úget_lm_headz!TFConvBertForMaskedLM.get_lm_headÑ  s   € Ø×%Ñ%Ð%r>   c                óN   — | j                   dz   | j                  j                   z   S )Nú/)r*   r}  r4  s    r=   Úget_prefix_bias_namez*TFConvBertForMaskedLM.get_prefix_bias_nameÔ  s!   € Ø�y‰y˜3‰ ×!7Ñ!7×!<Ñ!<Ñ<Ð<r>   rP  rQ  c                ó*  — | j                  |||||||||	|¬«
      }|d   }| j                  ||¬«      }| j                  ||¬«      }|
€dn| j                  |
|«      }|	s|f|dd z   }|�|f|z   S |S t	        |||j
                  |j                  ¬«      S )a›  
        labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,
            config.vocab_size]` (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]`
        rU  r   r�   Nr"   ©ÚlossÚlogitsr©   r  )rJ  r|  r}  Úhf_compute_lossr
   r©   r  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  Úlabelsr\   rw  Úgenerator_sequence_outputÚprediction_scoresr…  rÕ   s                    r=   rj   zTFConvBertForMaskedLM.call×  sß   € ð6 #'§-¡-ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#Øð #0ó #
Ðð %<¸AÑ$>Ð!Ø ×6Ñ6Ð7PÐ[cÐ6ÓdÐØ ×2Ñ2Ð3DÈxÐ2ÓXÐØ�~‰t¨4×+?Ñ+?ÀÐHYÓ+ZˆáØ'Ð)Ð,CÀAÀBÐ,GÑGˆFà)-Ð)9�T�G˜fÑ$ÐE¸vÐEäØØ$Ø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 «      �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   Œ¿xY w# 1 sw Y   ŒqxY w# 1 sw Y   y xY w)NTrJ  r|  r}  )	rL   rM   rG   rH   rJ  r*   rN   r|  r}  rO   s     r=   rN   zTFConvBertForMaskedLM.build  s  € Ø�:Š:ØØˆŒ
Ü�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ *Ø—‘×#Ñ# DÔ)÷*ä�4Ð0°$Ó7ÐCÜ—‘˜t×9Ñ9×>Ñ>Ó?ñ 7Ø×*Ñ*×0Ñ0°Ô6÷7ä�4Ð,¨dÓ3Ð?Ü—‘˜t×5Ñ5×:Ñ:Ó;ñ 3Ø×&Ñ&×,Ñ,¨TÔ2÷3ð 3ð @÷*ð *ú÷7ð 7ú÷3ð 3úr  ©NNNNNNNNNNF)rb   rW  rª   únp.ndarray | tf.Tensor | Nonerd   r�  rc   r�  r«   r�  re   rY  r¬   rZ  r!  rZ  r"  rZ  rˆ  rY  r\   rZ  rn   zUnion[Tuple, TFMaskedLMOutput]rk   )ro   rp   rq   r.   r  r‚  r   r    r[  r\  r   r]  r
   r^  rj   rN   rs   rt   s   @r=   rz  rz  Á  s÷   ø„ ôtò&ò=ð Ù*Ð+D×+KÑ+KÐLiÓ+jÓkÙØ&Ø$Ø$ôð .2Ø8<Ø8<Ø6:Ø37Ø*.Ø,0Ø/3Ø&*Ø#'Ø#(ð/
à*ð/
ð 6ð/
ð 6ð	/
ð
 4ð/
ð 1ð/
ð (ð/
ð *ð/
ð -ð/
ð $ð/
ð !ð/
ð !ð/
ð 
(ò/
óó ló ð/
÷b3r>   rz  c                  ó0   ‡ — e Zd ZdZˆ fd„Zd„ Zdd„Zˆ xZS )ÚTFConvBertClassificationHeadz-Head for sentence-level classification tasks.c                óÒ  •— t        ‰| �  di |¤Ž t        j                  j	                  |j
                  t        |j                  «      d¬«      | _        |j                  �|j                  n|j                  }t        j                  j                  |«      | _        t        j                  j	                  |j                  t        |j                  «      d¬«      | _        || _        y )NrÄ   rz   Úout_projr,   )r-   r.   r   r3   rŒ   r…   r   r2   rÄ   Úclassifier_dropoutr7   r6   r8   Ú
num_labelsr‘  r/   )r:   r/   r;   r’  r<   s       €r=   r.   z%TFConvBertClassificationHead.__init__!  sÁ   ø€ Ü‰ÑÑ"˜6Ò"ä—\‘\×'Ñ'Ø×Ñ´?À6×C[ÑC[Ó3\Ðcjð (ó 
ˆŒ
ð *0×)BÑ)BÐ)NˆF×%Ò%ÐTZ×TnÑTnð 	ô —|‘|×+Ñ+Ð,>Ó?ˆŒÜŸ™×*Ñ*Ø×Ñ´/À&×BZÑBZÓ2[Ðblð +ó 
ˆŒð ˆ�r>   c                óð   — |d d …dd d …f   }| j                  |«      }| j                  |«      } t        | j                  j                  «      |«      }| j                  |«      }| j                  |«      }|S r7  )r8   rÄ   r   r/   rû   r‘  )r:   r©   r;   r—   s       r=   rj   z!TFConvBertClassificationHead.call1  sh   € Øš!˜Q¢˜'Ñ"ˆØ�L‰L˜‹OˆØ�J‰J�q‹MˆØ5Ô˜dŸk™k×4Ñ4Ó5°aÓ8ˆØ�L‰L˜‹OˆØ�M‰M˜!Óˆàˆr>   c                ó"  — | j                   ry d| _         t        | dd «      �dt        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY w)NTrÄ   r‘  )
rL   rM   rG   rH   rÄ   r*   rN   r/   r…   r‘  rO   s     r=   rN   z"TFConvBertClassificationHead.build;  sÞ   € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ HØ—
‘
× Ñ  $¨¨d¯k©k×.EÑ.EÐ!FÔG÷Hä�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ KØ—‘×#Ñ# T¨4°·±×1HÑ1HÐ$IÔJ÷Kð Kð 7÷Hð Hú÷Kð KúrÏ   rk   )ro   rp   rq   rr   r.   rj   rN   rs   rt   s   @r=   r�  r�    s   ø„ Ù7ôò ÷	Kr>   r�  zp
    ConvBERT Model transformer with a sequence classification/regression head on top e.g., for GLUE tasks.
    c                  óÎ   ‡ — e Zd Zˆ fd„Ze eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zdd„Zˆ xZS )	Ú#TFConvBertForSequenceClassificationc                ó–   •— t        ‰| �  |g|¢­i |¤Ž |j                  | _        t        |d¬«      | _        t        |d¬«      | _        y )NrJ  rÔ   Ú
classifier)r-   r.   r“  r/  rJ  r�  r™  rO  s       €r=   r.   z,TFConvBertForSequenceClassification.__init__N  sC   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ø ×+Ñ+ˆŒÜ+¨F¸ÔDˆŒÜ6°vÀLÔQˆ�r>   rP  rQ  c                ó   — | j                  |||||||||	|¬«
      }| j                  |d   |¬«      }|
€dn| j                  |
|«      }|	s|f|dd z   }|�|f|z   S |S t        |||j                  |j
                  ¬«      S )a†  
        labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
            config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
            `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
        ©	rª   rd   rc   r«   re   r¬   r!  r"  r\   r   r�   Nr"   r„  )rJ  r™  r‡  r   r©   r  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  rˆ  r\   r½   r†  r…  rÕ   s                   r=   rj   z(TFConvBertForSequenceClassification.callT  s¶   € ð6 —-‘-ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#Øð  ó 
ˆð —‘ ¨¡°h�Ó?ˆØ�~‰t¨4×+?Ñ+?ÀÈÓ+OˆáØ�Y ¨¨ Ñ,ˆFà)-Ð)9�T�G˜fÑ$ÐE¸vÐEä)ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
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©NTrJ  r™  )rL   rM   rG   rH   rJ  r*   rN   r™  rO   s     r=   rN   z)TFConvBertForSequenceClassification.buildŠ  sµ   € Ø�:Š:ØØˆŒ
Ü�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ *Ø—‘×#Ñ# DÔ)÷*ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ ,Ø—‘×%Ñ% dÔ+÷,ð ,ð 9÷*ð *ú÷,ð ,úrâ   rŒ  )rb   rW  rª   r�  rd   r�  rc   r�  r«   r�  re   rY  r¬   rZ  r!  rZ  r"  rZ  rˆ  rY  r\   rZ  rn   z(Union[Tuple, TFSequenceClassifierOutput]rk   )ro   rp   rq   r.   r   r    r[  r\  r   r]  r   r^  rj   rN   rs   rt   s   @r=   r—  r—  G  sí   ø„ ôRð Ù*Ð+D×+KÑ+KÐLiÓ+jÓkÙØ&Ø.Ø$ôð .2Ø8<Ø8<Ø6:Ø37Ø*.Ø,0Ø/3Ø&*Ø#'Ø#(ð-
à*ð-
ð 6ð-
ð 6ð	-
ð
 4ð-
ð 1ð-
ð (ð-
ð *ð-
ð -ð-
ð $ð-
ð !ð-
ð !ð-
ð 
2ò-
óó ló ð-
÷^	,r>   r—  z©
    ConvBERT Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
    softmax) e.g. for RocStories/SWAG tasks.
    c                  óÎ   ‡ — e Zd Zˆ fd„Ze eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zdd„Zˆ xZS )	ÚTFConvBertForMultipleChoicec                ó  •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        t	        ||j
                  d¬«      | _        t        j                  j                  dt        |j
                  «      d¬«      | _        || _        y )NrJ  rÔ   Úsequence_summary)r2   r*   r"   r™  rz   )r-   r.   r/  rJ  r   r2   r¡  r   r3   rŒ   r   r™  r/   rO  s       €r=   r.   z$TFConvBertForMultipleChoice.__init__ž  s|   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3ä+¨F¸ÔDˆŒÜ 1Ø f×&>Ñ&>ÐEWô!
ˆÔô  Ÿ,™,×,Ñ,Ø¤/°&×2JÑ2JÓ"KÐR^ð -ó 
ˆŒð ˆ�r>   z(batch_size, num_choices, sequence_lengthrQ  c                óú  — |�t        |«      d   }t        |«      d   }nt        |«      d   }t        |«      d   }|�t        j                  |d|f«      nd}|�t        j                  |d|f«      nd}|�t        j                  |d|f«      nd}|�t        j                  |d|f«      nd}|�%t        j                  |d|t        |«      d   f«      nd}| j                  |||||||||	|¬«
      }| j	                  |d   |¬«      }| j                  |«      }t        j                  |d|f«      }|
€dn| j                  |
|«      }|	s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  ¬	«      S )
a5  
        labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the multiple choice classification loss. Indices should be in `[0, ..., num_choices]`
            where `num_choices` is the size of the second dimension of the input tensors. (See `input_ids` above)
        Nr"   r’   rT   r   )r"  r\   r   r�   r„  )
r   rG   r•   rJ  r¡  r™  r‡  r   r©   r  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  rˆ  r\   Únum_choicesrq  Úflat_input_idsÚflat_attention_maskÚflat_token_type_idsÚflat_position_idsÚflat_inputs_embedsr½   r†  Úreshaped_logitsr…  rÕ   s                           r=   rj   z TFConvBertForMultipleChoice.callª  sÊ  € ð8 Ð Ü$ YÓ/°Ñ2ˆKÜ# IÓ.¨qÑ1‰Jä$ ]Ó3°AÑ6ˆKÜ# MÓ2°1Ñ5ˆJàDMÐDYœŸ™ I°°JÐ/?Ô@Ð_cˆØN\ÐNhœbŸj™j¨¸"¸jÐ9IÔJÐnrÐØN\ÐNhœbŸj™j¨¸"¸jÐ9IÔJÐnrÐØJVÐJbœBŸJ™J |°b¸*Ð5EÔFÐhlÐð Ð(ô �J‰J�} r¨:´zÀ-Ó7PÐQRÑ7SÐ&TÔUàð 	ð
 —-‘-ØØØØØØØØ Ø#Øð  ó 
ˆð ×&Ñ& w¨q¡z¸HÐ&ÓEˆØ—‘ Ó(ˆÜŸ*™* V¨b°+Ð->Ó?ˆØ�~‰t¨4×+?Ñ+?ÀÈÓ+XˆáØ%Ð'¨'°!°"¨+Ñ5ˆFà)-Ð)9�T�G˜fÑ$ÐE¸vÐEä*ØØ"Ø!×/Ñ/Ø×)Ñ)ô	
ð 	
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 «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   ŒÖxY w# 1 sw Y   ŒˆxY w# 1 sw Y   y xY w)NTrJ  r¡  r™  )rL   rM   rG   rH   rJ  r*   rN   r¡  r™  r/   r…   rO   s     r=   rN   z!TFConvBertForMultipleChoice.buildó  s  € Ø�:Š:ØØˆŒ
Ü�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ *Ø—‘×#Ñ# DÔ)÷*ä�4Ð+¨TÓ2Ð>Ü—‘˜t×4Ñ4×9Ñ9Ó:ñ 2Ø×%Ñ%×+Ñ+¨DÔ1÷2ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ MØ—‘×%Ñ% t¨T°4·;±;×3JÑ3JÐ&KÔL÷Mð Mð 9÷*ð *ú÷2ð 2ú÷Mð MúrE  rŒ  )rb   rW  rª   r�  rd   r�  rc   r�  r«   r�  re   rY  r¬   rZ  r!  rZ  r"  rZ  rˆ  rY  r\   rZ  rn   z)Union[Tuple, TFMultipleChoiceModelOutput]rk   )ro   rp   rq   r.   r   r    r[  r\  r   r]  r   r^  rj   rN   rs   rt   s   @r=   rŸ  rŸ  –  sð   ø„ ô
ð Ù*Ø!×(Ñ(Ð)SÓTóñ  Ø&Ø/Ø$ôð .2Ø8<Ø8<Ø6:Ø37Ø*.Ø,0Ø/3Ø&*Ø#'Ø#(ð>
à*ð>
ð 6ð>
ð 6ð	>
ð
 4ð>
ð 1ð>
ð (ð>
ð *ð>
ð -ð>
ð $ð>
ð !ð>
ð !ð>
ð 
3ò>
óóó ð>
÷@Mr>   rŸ  z§
    ConvBERT Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
    Named-Entity-Recognition (NER) tasks.
    c                  óÎ   ‡ — e Zd Zˆ fd„Ze eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zdd„Zˆ xZS )	Ú TFConvBertForTokenClassificationc                ó˜  •— t        ‰| �  |g|¢­i |¤Ž |j                  | _        t        |d¬«      | _        |j
                  �|j
                  n|j                  }t        j                  j                  |«      | _
        t        j                  j                  |j                  t        |j                  «      d¬«      | _        || _        y )NrJ  rÔ   r™  rz   )r-   r.   r“  r/  rJ  r’  r7   r   r3   r6   r8   rŒ   r   r2   r™  r/   )r:   r/   r[   r;   r’  r<   s        €r=   r.   z)TFConvBertForTokenClassification.__init__
  s­   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3à ×+Ñ+ˆŒÜ+¨F¸ÔDˆŒà)/×)BÑ)BÐ)NˆF×%Ò%ÐTZ×TnÑTnð 	ô —|‘|×+Ñ+Ð,>Ó?ˆŒÜŸ,™,×,Ñ,Ø×Ñ´/À&×BZÑBZÓ2[Ðbnð -ó 
ˆŒð ˆ�r>   rP  rQ  c                ó&  — | j                  |||||||||	|¬«
      }|d   }| j                  ||¬«      }| j                  |«      }|
€dn| j                  |
|«      }|	s|f|dd z   }|�|f|z   S |S t	        |||j
                  |j                  ¬«      S )zÔ
        labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
        r›  r   r�   Nr"   r„  )rJ  r8   r™  r‡  r   r©   r  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  rˆ  r\   r½   Úsequence_outputr†  r…  rÕ   s                    r=   rj   z%TFConvBertForTokenClassification.call  sÉ   € ð2 —-‘-ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#Øð  ó 
ˆð " !™*ˆØŸ,™, À˜,ÓJˆØ—‘ Ó1ˆØ�~‰t¨4×+?Ñ+?ÀÈÓ+OˆáØ�Y ¨¨ Ñ,ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä&ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r>   c                óô  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY wr�  )
rL   rM   rG   rH   rJ  r*   rN   r™  r/   r…   rO   s     r=   rN   z&TFConvBertForTokenClassification.buildM  óË   € Ø�:Š:ØØˆŒ
Ü�4˜ TÓ*Ð6Ü—‘˜tŸ}™}×1Ñ1Ó2ñ *Ø—‘×#Ñ# DÔ)÷*ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ MØ—‘×%Ñ% t¨T°4·;±;×3JÑ3JÐ&KÔL÷Mð Mð 9÷*ð *ú÷Mð Múó   ÁC"Â%3C.Ã"C+Ã.C7rŒ  )rb   rW  rª   r�  rd   r�  rc   r�  r«   r�  re   rY  r¬   rZ  r!  rZ  r"  rZ  rˆ  rY  r\   rZ  rn   z%Union[Tuple, TFTokenClassifierOutput]rk   )ro   rp   rq   r.   r   r    r[  r\  r   r]  r   r^  rj   rN   rs   rt   s   @r=   r¬  r¬    sí   ø„ ôð Ù*Ð+D×+KÑ+KÐLiÓ+jÓkÙØ&Ø+Ø$ôð .2Ø8<Ø8<Ø6:Ø37Ø*.Ø,0Ø/3Ø&*Ø#'Ø#(ð,
à*ð,
ð 6ð,
ð 6ð	,
ð
 4ð,
ð 1ð,
ð (ð,
ð *ð,
ð -ð,
ð $ð,
ð !ð,
ð !ð,
ð 
/ò,
óó ló ð,
÷\	Mr>   r¬  zà
    ConvBERT Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
    layer on top of the hidden-states output to compute `span start logits` and `span end logits`).
    c                  óÔ   ‡ — e Zd Zˆ fd„Ze eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zdd„Zˆ xZS )	ÚTFConvBertForQuestionAnsweringc                ó  •— t        ‰| �  |g|¢­i |¤Ž |j                  | _        t        |d¬«      | _        t
        j                  j                  |j                  t        |j                  «      d¬«      | _
        || _        y )NrJ  rÔ   Ú
qa_outputsrz   )r-   r.   r“  r/  rJ  r   r3   rŒ   r   r2   r¶  r/   rO  s       €r=   r.   z'TFConvBertForQuestionAnswering.__init__a  sr   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3à ×+Ñ+ˆŒÜ+¨F¸ÔDˆŒÜŸ,™,×,Ñ,Ø×Ñ´/À&×BZÑBZÓ2[Ðbnð -ó 
ˆŒð ˆ�r>   rP  rQ  c                ó°  — | j                  |||||||||	|¬«
      }|d   }| j                  |«      }t        j                  |dd¬«      \  }}t        j                  |d¬«      }t        j                  |d¬«      }d}|
�|�d|
i}||d<   | j                  |||f«      }|	s||f|d	d z   }|�|f|z   S |S t        ||||j                  |j                  ¬
«      S )aõ  
        start_positions (`tf.Tensor` of shape `(batch_size,)`, *optional*):
            Labels for position (index) of the start of the labelled span for computing the token classification loss.
            Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
            are not taken into account for computing the loss.
        end_positions (`tf.Tensor` of shape `(batch_size,)`, *optional*):
            Labels for position (index) of the end of the labelled span for computing the token classification loss.
            Positions are clamped to the length of the sequence (`sequence_length`). Position outside of the sequence
            are not taken into account for computing the loss.
        r›  r   r’   rT   rY   NÚstart_positionÚend_positionr"   )r…  Ústart_logitsÚ
end_logitsr©   r  )	rJ  r¶  rG   ÚsplitÚsqueezer‡  r   r©   r  )r:   rb   rª   rd   rc   r«   re   r¬   r!  r"  Ústart_positionsÚend_positionsr\   r½   r¯  r†  rº  r»  r…  rˆ  rÕ   s                        r=   rj   z#TFConvBertForQuestionAnswering.callk  s  € ð@ —-‘-ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#Øð  ó 
ˆð " !™*ˆØ—‘ Ó1ˆÜ#%§8¡8¨F°A¸BÔ#?Ñ ˆ�jÜ—z‘z ,°RÔ8ˆÜ—Z‘Z 
°Ô4ˆ
ØˆàÐ&¨=Ð+DØ&¨Ð8ˆFØ%2ˆF�>Ñ"Ø×'Ñ'¨°¸zÐ0JÓKˆDáØ" JÐ/°'¸!¸"°+Ñ=ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä-ØØ%Ø!Ø!×/Ñ/Ø×)Ñ)ô
ð 	
r>   c                óô  — | j                   ry d| _         t        | dd «      �Mt        j                  | j                  j
                  «      5  | j                  j                  d «       d d d «       t        | dd «      �et        j                  | j                  j
                  «      5  | j                  j                  d d | j                  j                  g«       d d d «       y y # 1 sw Y   Œ|xY w# 1 sw Y   y xY w)NTrJ  r¶  )
rL   rM   rG   rH   rJ  r*   rN   r¶  r/   r…   rO   s     r=   rN   z$TFConvBertForQuestionAnswering.build¯  r±  r²  )NNNNNNNNNNNF)rb   rW  rª   r�  rd   r�  rc   r�  r«   r�  re   rY  r¬   rZ  r!  rZ  r"  rZ  r¾  rY  r¿  rY  r\   rZ  rn   z,Union[Tuple, TFQuestionAnsweringModelOutput]rk   )ro   rp   rq   r.   r   r    r[  r\  r   r]  r   r^  rj   rN   rs   rt   s   @r=   r´  r´  Y  sú   ø„ ôð Ù*Ð+D×+KÑ+KÐLiÓ+jÓkÙØ&Ø2Ø$ôð .2Ø8<Ø8<Ø6:Ø37Ø*.Ø,0Ø/3Ø&*Ø,0Ø*.Ø#(ð;
à*ð;
ð 6ð;
ð 6ð	;
ð
 4ð;
ð 1ð;
ð (ð;
ð *ð;
ð -ð;
ð $ð;
ð *ð;
ð (ð;
ð !ð;
ð 
6ò;
óó ló ð;
÷z	Mr>   r´  )rz  rŸ  r´  r—  r¬  r  rM  rI  )Krr   Ú
__future__r   Útypingr   r   r   ÚnumpyÚnpÚ
tensorflowrG   Úactivations_tfr   Úmodeling_tf_outputsr	   r
   r   r   r   r   Úmodeling_tf_utilsr   r   r   r   r   r   r   r   r   r   r   r   Útf_utilsr   r   r   Úutilsr   r   r    r!   Úconfiguration_convbertr#   Ú
get_loggerro   Úloggerr]  r^  r3   ÚLayerr%   rv   rÁ   rÒ   rä   rö   r  r  r  r)  r/  rI  ÚCONVBERT_START_DOCSTRINGr[  rM  r`  rs  rz  r�  r—  rŸ  r¬  r´  Ú__all__r,   r>   r=   ú<module>rÑ     s#  ðñ å "ç )Ñ )ã Û å /÷÷ ÷÷ ÷ ó ÷ SÑ R÷ó õ 3ð 
ˆ×	Ñ	˜HÓ	%€à/Ð Ø"€ôQ ˜5Ÿ<™<×-Ñ-ô Q ôhlQ˜eŸl™l×0Ñ0ô lQô^L˜5Ÿ<™<×-Ñ-ô Lô<.˜%Ÿ,™,×,Ñ,ô .ô>˜Ÿ™×+Ñ+ô ôB"H˜UŸ\™\×/Ñ/ô "HôJ$N�u—|‘|×)Ñ)ô $NôN-�e—l‘l×(Ñ(ô -ôD1&˜Ÿ™×*Ñ*ô 1&ôh L¨¯©×(:Ñ(:ô  LðF ôuX˜%Ÿ,™,×,Ñ,ó uXó ðuXôp#Ð 1ô #ð(Ð ðT5Ð ñp ØhØóô/*Ð/ó /*ó	ð/*ôd"˜UŸ\™\×/Ñ/ô "ôJH U§\¡\×%7Ñ%7ô Hñ6 ÐRÐTlÓmôY3Ð5Ð7Só Y3ó nðY3ôx&K 5§<¡<×#5Ñ#5ô &KñR ðð ó	ôF,Ð*CÐEaó F,óðF,ñR ðð óôbMÐ";Ð=Qó bMóðbMñJ ðð óôMMÐ'@ÐB[ó MMóðMMñ` ðð óôXMÐ%>Ð@Wó XMóðXMòv	�r>   