Ë
    T^(hbÝ  ã                  ó–  — d Z ddl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 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 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-m.Z.m/Z/ ddl0m1Z1  e/jd                  e3«      Z4dZ5dZ6d„ Z7d3d„Z8 G d„ de"jr                  jt                  «      Z; G d„ de"jr                  jt                  «      Z<e# G d„ de"jr                  jt                  «      «       Z= G d„ de«      Z>e G d„ de+«      «       Z?dZ@dZA e-de@«       G d„ d e>«      «       ZB G d!„ d"e"jr                  jt                  «      ZC e-d#e@«       G d$„ d%e>«      «       ZD e-d&e@«       G d'„ d(e>e«      «       ZE e-d)e@«       G d*„ d+e>e«      «       ZF e-d,e@«       G d-„ d.e>e «      «       ZG e-d/e@«       G d0„ d1e>e«      «       ZHg d2¢ZIy)4z
TF 2.0 XLM model.
é    )ÚannotationsN)Ú	dataclass)ÚDictÚOptionalÚTupleÚUnioné   )Úget_tf_activation)ÚTFBaseModelOutputÚTFMultipleChoiceModelOutputÚTFQuestionAnsweringModelOutputÚTFSequenceClassifierOutputÚTFTokenClassifierOutput)ÚTFModelInputTypeÚTFMultipleChoiceLossÚTFPreTrainedModelÚTFQuestionAnsweringLossÚTFSequenceClassificationLossÚTFSequenceSummaryÚTFSharedEmbeddingsÚTFTokenClassificationLossÚget_initializerÚkerasÚkeras_serializableÚunpack_inputs)Úcheck_embeddings_within_boundsÚ
shape_listÚstable_softmax)ÚMULTIPLE_CHOICE_DUMMY_INPUTSÚModelOutputÚadd_code_sample_docstringsÚadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚloggingé   )Ú	XLMConfigzFacebookAI/xlm-mlm-en-2048r&   c                óÔ  — t        j                  t        | «      D ��cg c];  }t        |«      D �cg c]$  }|t        j                  dd|dz  z  |z  «      z  ‘Œ& c}‘Œ= c}}«      }t	        j
                  t        j                  |d d …dd d…f   «      «      |d d …dd d…f<   t	        j
                  t        j                  |d d …dd d…f   «      «      |d d …dd d…f<   y c c}w c c}}w )Ni'  é   r   r%   )ÚnpÚarrayÚrangeÚpowerÚtfÚconstantÚsinÚcos)Ún_posÚdimÚoutÚposÚjÚposition_encs         úe/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/xlm/modeling_tf_xlm.pyÚcreate_sinusoidal_embeddingsr8   E   sÃ   € Ü—8‘8ÔhmÐnsÓht×uÐadÔQVÐWZÓQ[Ö\ÈA˜c¤B§H¡H¨U°A¸¸a¹±LÀ3Ñ4FÓ$GÓGÔ\ÓuÓv€LÜ—;‘;œrŸv™v l²1°a°d¸°d°7Ñ&;Ó<Ó=€CŠˆ1ˆ4ˆaˆ4ˆ�LÜ—;‘;œrŸv™v l²1°a°d¸°d°7Ñ&;Ó<Ó=€CŠˆ1ˆ4ˆaˆ4ˆ‚Lùò ]ùÓus   žC$
°)CÁC$
ÃC$
c           
     ó  — t        |«      d   }|�|}n;t        j                  | |j                  ¬«      }|t        j                  |d¬«      k  }|r\t        j
                  t        j                  t        j                  dd| f«      || df«      t        j                  |d| df«      «      }n|}t        j                  j                  t        |«      || g«       |r,t        j                  j                  t        |«      || | g«       ||fS )zH
    Generate hidden states mask, and optionally an attention mask.
    r   ©Údtyper%   ©Úaxis)
r   r-   r+   r;   Úexpand_dimsÚ
less_equalÚtileÚreshapeÚ	debuggingÚassert_equal)ÚslenÚlengthsÚcausalÚpadding_maskÚbsÚmaskÚalenÚ	attn_masks           r7   Ú	get_masksrL   K   së   € ô 
�GÓ	˜QÑ	€BØÐØ‰ô �x‰x˜ G§M¡MÔ2ˆØ”b—n‘n W°1Ô5Ñ5ˆñ Ü—M‘MÜ�G‰G”B—J‘J˜t a¨¨D \Ó2°R¸¸q°MÓBÄBÇJÁJÈtÐVWÐY]Ð_`ÐUaÓDbó
‰	ð ˆ	ô ‡L�L×Ñœj¨Ó.°°T°
Ô;ÙÜ
�‰×!Ñ!¤*¨YÓ"7¸"¸dÀDÐ9IÔJà�ˆ?Ðó    c                  óV   ‡ — e Zd Z ej                  «       Zˆ fd„Zd„ Zdd„Zdd„Z	ˆ xZ
S )ÚTFXLMMultiHeadAttentionc                ó2  •— t        ‰| �  di |¤Ž t        t        j                  «      | _        || _        || _        |j                  | _        | j                  | j                  z  dk(  sJ ‚t        j                  j                  |t        |j                  «      d¬«      | _        t        j                  j                  |t        |j                  «      d¬«      | _        t        j                  j                  |t        |j                  «      d¬«      | _        t        j                  j                  |t        |j                  «      d¬«      | _        t        j                  j%                  |j&                  «      | _        t+        «       | _        || _        y )Nr   Úq_lin©Úkernel_initializerÚnameÚk_linÚv_linÚout_lin© )ÚsuperÚ__init__ÚnextrO   ÚNEW_IDÚlayer_idr2   Ún_headsÚoutput_attentionsr   ÚlayersÚDenser   Úinit_stdrQ   rU   rV   rW   ÚDropoutÚattention_dropoutÚdropoutÚsetÚpruned_heads)Úselfr^   r2   ÚconfigÚkwargsÚ	__class__s        €r7   rZ   z TFXLMMultiHeadAttention.__init__k   s2  ø€ Ü‰ÑÑ"˜6Ò"ÜÔ4×;Ñ;Ó<ˆŒØˆŒØˆŒØ!'×!9Ñ!9ˆÔØ�x‰x˜$Ÿ,™,Ñ&¨!Ò+Ð+Ð+ä—\‘\×'Ñ'¨ÄÐPV×P_ÑP_Ó@`ÐgnÐ'ÓoˆŒ
Ü—\‘\×'Ñ'¨ÄÐPV×P_ÑP_Ó@`ÐgnÐ'ÓoˆŒ
Ü—\‘\×'Ñ'¨ÄÐPV×P_ÑP_Ó@`ÐgnÐ'ÓoˆŒ
Ü—|‘|×)Ñ)¨#Ä/ÐRX×RaÑRaÓBbÐirÐ)ÓsˆŒÜ—|‘|×+Ñ+¨F×,DÑ,DÓEˆŒÜ›EˆÔØˆ�rM   c                ó   — t         ‚©N©ÚNotImplementedError)rh   Úheadss     r7   Úprune_headsz#TFXLMMultiHeadAttention.prune_heads{   s   € Ü!Ð!rM   c                ó\  ‡ ‡‡— t        |«      \  Š}}	|€|€|n|d   |z   }
nt        |«      d   }
‰ j                  ‰ j                  z  Št        t        |«      «      dk(  r‰d||
fn‰dd|
f}ˆˆˆ fd„}ˆˆˆ fd„} |‰ j	                  |«      «      }|€/ |‰ j                  |«      «      } |‰ j                  |«      «      }nB|�‰ j                  |vr2|x}} |‰ j                  |«      «      } |‰ j                  |«      «      }|�x‰ j                  |v rY|€E|‰ j                     \  }}t        j                  |gd¬«      }t        j                  |gd¬«      }n|‰ j                     \  }}f|‰ j                  <   t        j                  ‰|j                  ¬«      }t        j                  |t        j                  j                  |«      «      }t        j                  |j                  ¬«      }t        j                  ||d	¬
«      }t        j                   ||«      }t        j                  ||j                  ¬«      }|dd|z
  z  z
  }t#        |d¬«      }‰ j%                  ||¬«      }|�||z  }t        j                  |«      } ||«      }‰ j'                  |«      f}|r||fz   }|S )zd
        Self-attention (if kv is None) or attention over source sentence (provided by kv).
        rD   r%   r	   c           	     óv   •— t        j                  t        j                  | ‰d‰j                  ‰f«      d¬«      S )Ú
projectionéÿÿÿÿ©r   r(   r%   r	   ©Úperm)r-   Ú	transposerA   r^   ©ÚxrH   Údim_per_headrh   s    €€€r7   Úshapez+TFXLMMultiHeadAttention.call.<locals>.shape�   s-   ø€ ä—<‘<¤§
¡
¨1¨r°2°t·|±|À\Ð.RÓ SÐZfÔgÐgrM   c                óz   •— t        j                  t        j                  | d¬«      ‰d‰j                  ‰z  f«      S )zcompute contextrv   rw   ru   )r-   rA   ry   r^   rz   s    €€€r7   Úunshapez-TFXLMMultiHeadAttention.call.<locals>.unshape“   s0   ø€ ä—:‘:œbŸl™l¨1°<Ô@À2ÀrÈ4Ï<É<ÐZfÑKfÐBgÓhÐhrM   r(   r<   r:   T)Útranspose_bgêŒ 9Y>)Fg      ð?ru   ©Útraining)r   r2   r^   ÚlenrQ   rU   rV   r]   r-   ÚconcatÚcastr;   ÚmultiplyÚmathÚrsqrtÚmatmulrA   r   re   rW   )rh   ÚinputrI   ÚkvÚcacheÚ	head_maskr_   r‚   Úqlenr2   ÚklenÚmask_reshaper}   r   ÚqÚkÚvÚk_Úv_Úf_dim_per_headÚscoresÚweightsÚcontextÚoutputsrH   r|   s   `                       @@r7   ÚcallzTFXLMMultiHeadAttention.call~   sx  ú€ ô # 5Ó)‰ˆˆD�#àˆ:Ø ˜=‘4¨e°F©m¸dÑ.B‰Dä˜b“> !Ñ$ˆDð —x‘x 4§<¡<Ñ/ˆÜ.1´*¸TÓ2BÓ.CÀqÒ.H˜˜A˜t TÑ*ÈrÐSTÐVWÐY]ÐN^ˆö	hö	iñ �$—*‘*˜UÓ#Ó$ˆàˆ:Ù�d—j‘j Ó'Ó(ˆAÙ�d—j‘j Ó'Ó(‰AØˆ]˜dŸm™m°5Ñ8ØˆJˆA�Ù�d—j‘j “mÓ$ˆAÙ�d—j‘j “mÓ$ˆAàÐØ�}‰} Ñ%Ø�:Ø" 4§=¡=Ñ1‘F�B˜ÜŸ	™	 2 q '°Ô2�AÜŸ	™	 2 q '°Ô2‘Aà  §¡Ñ/‘D�A�qà$% q 6ˆE�$—-‘-Ñ äŸ™ °Q·W±WÔ=ˆÜ�K‰K˜œ2Ÿ7™7Ÿ=™=¨Ó8Ó9ˆÜ�G‰G�A˜QŸW™WÔ%ˆÜ—‘˜1˜a¨TÔ2ˆÜ�z‰z˜$ Ó-ˆä�w‰w�t 6§<¡<Ô0ˆØ˜$ #¨¡*Ñ-Ñ-ˆÜ  ¨bÔ1ˆØ—,‘,˜w°�,Ó:ˆð Ð Ø 	Ñ)ˆGä—)‘)˜G QÓ'ˆÙ˜'Ó"ˆØ—<‘< Ó(Ð*ˆáØ  
Ñ*ˆGàˆrM   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)NTrQ   rU   rV   rW   )ÚbuiltÚgetattrr-   Ú
name_scoperQ   rT   Úbuildr2   rU   rV   rW   ©rh   Úinput_shapes     r7   r    zTFXLMMultiHeadAttention.buildÄ   ss  € Ø�:Š:ØØˆŒ
Ü�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ 9Ø—
‘
× Ñ  $¨¨d¯h©hÐ!7Ô8÷9ä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ 9Ø—
‘
× Ñ  $¨¨d¯h©hÐ!7Ô8÷9ä�4˜ $Ó'Ð3Ü—‘˜tŸz™zŸ™Ó/ñ 9Ø—
‘
× Ñ  $¨¨d¯h©hÐ!7Ô8÷9ä�4˜ DÓ)Ð5Ü—‘˜tŸ|™|×0Ñ0Ó1ñ ;Ø—‘×"Ñ" D¨$°·±Ð#9Ô:÷;ð ;ð 6÷9ñ 9ú÷9ð 9ú÷9ð 9ú÷;ð ;ús0   Á)F3Â2)G Ä)GÆ )GÆ3F=Ç G	ÇGÇG!©Frm   )Ú__name__Ú
__module__Ú__qualname__Ú	itertoolsÚcountr\   rZ   rq   r›   r    Ú__classcell__©rk   s   @r7   rO   rO   h   s'   ø„ ØˆY�_‰_Ó€Fôò "óD÷L;rM   rO   c                  ó.   ‡ — e Zd Zˆ fd„Zdd„Zdd„Zˆ xZS )ÚTFXLMTransformerFFNc                óÒ  •— t        ‰| �  di |¤Ž t        j                  j	                  |t        |j                  «      d¬«      | _        t        j                  j	                  |t        |j                  «      d¬«      | _        |j                  rt        d«      n
t        d«      | _        t        j                  j                  |j                  «      | _        || _        || _        y )NÚlin1rR   Úlin2ÚgeluÚrelurX   )rY   rZ   r   r`   ra   r   rb   r®   r¯   Úgelu_activationr
   Úactrc   re   Úin_dimÚ
dim_hidden)rh   r´   rµ   Úout_dimri   rj   rk   s         €r7   rZ   zTFXLMTransformerFFN.__init__×   s­   ø€ Ü‰ÑÑ"˜6Ò"ä—L‘L×&Ñ& zÄoÐV\×VeÑVeÓFfÐmsÐ&ÓtˆŒ	Ü—L‘L×&Ñ& wÄ?ÐSY×SbÑSbÓCcÐjpÐ&ÓqˆŒ	Ø06×0FÒ0FÔ$ VÔ,ÔL]Ð^dÓLeˆŒÜ—|‘|×+Ñ+¨F¯N©NÓ;ˆŒØˆŒØ$ˆ�rM   c                ó’   — | j                  |«      }| j                  |«      }| j                  |«      }| j                  ||¬«      }|S )Nr�   )r®   r³   r¯   re   )rh   rŠ   r‚   r{   s       r7   r›   zTFXLMTransformerFFN.callá   sA   € Ø�I‰I�eÓˆØ�H‰H�Q‹KˆØ�I‰I�a‹LˆØ�L‰L˜ XˆLÓ.ˆàˆrM   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 «      �[t        j                  | j                  j
                  «      5  | j                  j                  d d | j                  g«       d d d «       y y # 1 sw Y   ŒrxY w# 1 sw Y   y xY w)NTr®   r¯   )
r�   rž   r-   rŸ   r®   rT   r    r´   r¯   rµ   r¡   s     r7   r    zTFXLMTransformerFFN.buildé   sÃ   € Ø�:Š:ØØˆŒ
Ü�4˜ Ó&Ð2Ü—‘˜tŸy™yŸ~™~Ó.ñ ;Ø—	‘	—‘  t¨T¯[©[Ð 9Ô:÷;ä�4˜ Ó&Ð2Ü—‘˜tŸy™yŸ~™~Ó.ñ ?Ø—	‘	—‘  t¨T¯_©_Ð =Ô>÷?ð ?ð 3÷;ð ;ú÷?ð ?ús   Á)C%Â2)C1Ã%C.Ã1C:r£   rm   )r¤   r¥   r¦   rZ   r›   r    r©   rª   s   @r7   r¬   r¬   Ö   s   ø„ ô%ó÷	?rM   r¬   c                  ól   ‡ — e Zd ZeZˆ fd„Zdd„Zd„ Zd„ Zd„ Z	e
	 	 	 	 	 	 	 	 	 	 	 	 	 d	 d	d„«       Zˆ xZS )
ÚTFXLMMainLayerc                óˆ  •— t        ‰| �  di |¤Ž || _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                   | _        | j                  rt        d«      ‚|j                  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                   | _        | j"                  dz  | _        |j&                  | _        |j(                  | _        |j*                  | _        |j,                  | _        | j"                  | j&                  z  dk7  rt/        d«      ‚t0        j2                  j5                  |j6                  «      | _        t0        j2                  j5                  |j8                  «      | _        |j:                  rt        ‚t=        | j                  | j"                  |j,                  d¬«      | _        t0        j2                  jA                  |jB                  d¬«      | _"        g | _#        g | _$        g | _%        g | _&        tO        | j(                  «      D �]  }| jF                  jQ                  tS        | j&                  | j"                  |d	|› �¬
«      «       | jH                  jQ                  t0        j2                  jA                  |jB                  d|› �¬«      «       | jJ                  jQ                  tU        | j"                  | j$                  | j"                  |d|› �¬
«      «       | jL                  jQ                  t0        j2                  jA                  |jB                  d|› �¬«      «       �Œ tW        |d«      r�|jX                  j[                  «       j]                  «       }i |_,        |D ]h  \  }}| jF                  t_        |«         j&                  |j&                  k(  sŒ6| ja                  t_        |«      tc        te        t^        |«      «      i«       Œj y y )Nz,Currently XLM can only be used as an encoderé   r   z-transformer dim must be a multiple of n_headsÚ
embeddings©Úinitializer_rangerT   Úlayer_norm_emb)ÚepsilonrT   zattentions_._)ri   rT   zlayer_norm1_._zffns_._zlayer_norm2_._rg   rX   )3rY   rZ   ri   Úoutput_hidden_statesr_   Úuse_return_dictÚreturn_dictÚ
is_encoderÚ
is_decoderro   rF   Ún_langsÚuse_lang_embÚn_wordsÚ	eos_indexÚ	pad_indexÚemb_dimr2   Ú
hidden_dimr^   Ún_layersÚmax_position_embeddingsÚembed_init_stdÚ
ValueErrorr   r`   rc   re   rd   Úsinusoidal_embeddingsr   r½   ÚLayerNormalizationÚlayer_norm_epsrÀ   Ú
attentionsÚlayer_norm1ÚffnsÚlayer_norm2r+   ÚappendrO   r¬   Úhasattrrg   ÚcopyÚitemsÚintrq   ÚlistÚmap)rh   ri   rj   Úirg   Úlayerrp   rk   s          €r7   rZ   zTFXLMMainLayer.__init__ù   sr  ø€ Ü‰ÑÑ"˜6Ò"àˆŒØ$*×$?Ñ$?ˆÔ!Ø!'×!9Ñ!9ˆÔØ!×1Ñ1ˆÔð !×+Ñ+ˆŒØ$×/Ñ/Ð/ˆŒà�?Š?Ü%Ð&TÓUÐUð —m‘mˆŒð —~‘~ˆŒØ"×/Ñ/ˆÔØ—~‘~ˆŒØ×)Ñ)ˆŒØ×)Ñ)ˆŒð —>‘>ˆŒØŸ(™( Q™,ˆŒØ—~‘~ˆŒØŸ™ˆŒØ'-×'EÑ'EˆÔ$Ø$×3Ñ3ˆÔØ�8‰8�d—l‘lÑ" aÒ'ÜÐLÓMÐMô —|‘|×+Ñ+¨F¯N©NÓ;ˆŒÜ!&§¡×!5Ñ!5°f×6NÑ6NÓ!OˆÔà×'Ò'Ü%Ð%ô -Ø�L‰L˜$Ÿ(™(°f×6KÑ6KÐR^ô
ˆŒô $Ÿl™l×=Ñ=Àf×F[ÑF[ÐbrÐ=ÓsˆÔð ˆŒØˆÔØˆŒ	ØˆÔô
 �t—}‘}Ó%ó 	ˆAØ�O‰O×"Ñ"Ü'¨¯©°d·h±hÀvÐVcÐdeÐcfÐTgÔhôð ×Ñ×#Ñ#Ü—‘×/Ñ/¸×8MÑ8MÐVdÐefÐdgÐThÐ/Óiôð �I‰I×ÑÜ# D§H¡H¨d¯o©o¸t¿x¹xÐPVÐ_fÐghÐfiÐ]jÔkôð ×Ñ×#Ñ#Ü—‘×/Ñ/¸×8MÑ8MÐVdÐefÐdgÐThÐ/Óiöð	ô" �6˜>Ô*Ø!×.Ñ.×3Ñ3Ó5×;Ñ;Ó=ˆLØ"$ˆFÔà ,ò J‘��uØ—?‘?¤3 u£:Ñ.×6Ñ6¸&¿.¹.ÓHØ×$Ñ$¤c¨%£j´$´s¼3À³Ó2GÐ%HÕIñJð	 +rM   c                ó´  — | j                   ry d| _         t        j                  d«      5  | j                  d| j                  | j
                  gt        | j                  «      ¬«      | _        d d d «       | j                  dkD  rl| j                  r`t        j                  d«      5  | j                  d| j                  | j
                  gt        | j                  «      ¬«      | _        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 «       | j"                  D ];  }t        j                  |j                  «      5  |j                  d «       d d d «       Œ= | j$                  D ]H  }t        j                  |j                  «      5  |j                  d d | j
                  g«       d d d «       ŒJ | j&                  D ];  }t        j                  |j                  «      5  |j                  d «       d d d «       Œ= | j(                  D ]H  }t        j                  |j                  «      5  |j                  d d | j
                  g«       d d d «       ŒJ 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   �ŒtxY w# 1 sw Y   �ŒuxY w# 1 sw Y   �Œ8xY w# 1 sw Y   ŒíxY w# 1 sw Y   Œ¯xY w)NTÚposition_embeddingsr½   )rT   r}   Úinitializerr%   Úlang_embeddingsrÀ   )r�   r-   rŸ   Ú
add_weightrÏ   r2   r   rÐ   rã   rÇ   rÈ   rå   rž   r½   rT   r    rÀ   rÕ   rÖ   r×   rØ   )rh   r¢   rá   s      r7   r    zTFXLMMainLayer.buildP  sÏ  € Ø�:Š:ØØˆŒ
Ü�]‰]Ð0Ó1ñ 	Ø'+§¡Ø!Ø×3Ñ3°T·X±XÐ>Ü+¨D×,?Ñ,?Ó@ð (7ó (ˆDÔ$÷	ð �<‰<˜!Ò × 1Ò 1Ü—‘Ð0Ó1ñ Ø'+§¡Ø%ØŸ<™<¨¯©Ð2Ü /°×0CÑ0CÓ Dð (7ó (�Ô$÷ô �4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ ,Ø—‘×%Ñ% dÔ+÷,ä�4Ð)¨4Ó0Ð<Ü—‘˜t×2Ñ2×7Ñ7Ó8ñ BØ×#Ñ#×)Ñ)¨4°°t·x±xÐ*@ÔA÷Bà—_‘_ò 	"ˆEÜ—‘˜uŸz™zÓ*ñ "Ø—‘˜DÔ!÷"ð "ð	"ð ×%Ñ%ò 	4ˆEÜ—‘˜uŸz™zÓ*ñ 4Ø—‘˜T 4¨¯©Ð2Ô3÷4ð 4ð	4ð —Y‘Yò 	"ˆEÜ—‘˜uŸz™zÓ*ñ "Ø—‘˜DÔ!÷"ð "ð	"ð ×%Ñ%ò 	4ˆEÜ—‘˜uŸz™zÓ*ñ 4Ø—‘˜T 4¨¯©Ð2Ô3÷4ð 4ñ	4÷;	ñ 	ú÷ñ ú÷,ñ ,ú÷Bñ Bú÷"ñ "ú÷4ñ 4ú÷"ð "ú÷4ð 4úsa   ªAK4Â%ALÄ&LÆ )LÇL(È)L5Ê MË
MË4K>ÌLÌLÌL%Ì(L2	Ì5L?	ÍM	ÍM	c                ó   — | j                   S rm   )r½   ©rh   s    r7   Úget_input_embeddingsz#TFXLMMainLayer.get_input_embeddingsu  ó   € Ø�‰ÐrM   c                ó`   — || j                   _        t        |«      d   | j                   _        y ©Nr   )r½   Úweightr   Ú
vocab_size©rh   Úvalues     r7   Úset_input_embeddingsz#TFXLMMainLayer.set_input_embeddingsx  s$   € Ø!&ˆ�‰ÔÜ%/°Ó%6°qÑ%9ˆ�‰Õ"rM   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
        rn   )rh   Úheads_to_prunes     r7   Ú_prune_headszTFXLMMainLayer._prune_heads|  s
   € ô
 "Ð!rM   c           
     ó¸  — |�|	�t        d«      ‚|�t        |«      \  }}n|	�t        |	«      d d \  }}nt        d«      ‚|€p|�Ut        j                  t        j                  t        j
                  || j                  «      |j                  ¬«      d¬«      }nt        j                  |g|z  «      }t        j                  j                  t        |«      d   |«      dt        |«      d   › d	|› d
�f t        ||| j                  |¬«      \  }}|€Bt        j                  t        j                  |«      d¬«      }t        j                  ||df«      }t        j                  j                  t        |«      ||g«      dt        |«      › d||g› d
�f |�?t        j                  j                  t        |«      ||g«      dt        |«      › d||g› d
�f |�t         ‚d g| j"                  z  }|�H|�F||d   z
  }|d d …| d …f   }|d d …| d …f   }|�|d d …| d …f   }|d d …| d …f   }|d d …| d …f   }|	€1t%        || j&                  j(                  «       | j'                  |«      }	|	t        j*                  | j,                  |«      z   }|�>| j.                  r2| j0                  dkD  r#|t        j*                  | j2                  |«      z   }|�|| j'                  |«      z   }| j5                  |«      }| j7                  ||¬«      }t        j                  ||j                  ¬«      }|t        j                  |d¬«      z  }|rdnd }|
rdnd }t        | j"                  «      D ]­  }|r||fz   } | j8                  |   ||d |||   |
|¬«      }|d   }|
r	||d   fz   }| j7                  ||¬«      }||z   } | j:                  |   |«      }| | j<                  |   |«      z   } | j>                  |   |«      }|t        j                  |d¬«      z  }Œ¯ |r||fz   }|�|dxx   |jA                  d«      z  cc<   |stC        d„ |||fD «       «      S tE        |||¬«      S )NzDYou cannot specify both input_ids and inputs_embeds at the same timer(   z5You have to specify either input_ids or inputs_embedsr:   r%   r<   r   zExpected batch size z and received batch size z mismatched)rG   zPosition id shape z and input shape zLang shape rD   r�   ru   rX   c              3  ó&   K  — | ]	  }|€Œ|–— Œ y ­wrm   rX   )Ú.0r“   s     r7   ú	<genexpr>z&TFXLMMainLayer.call.<locals>.<genexpr>'  s   è ø€ ÒY˜qÈ1É=œÑYùs   ‚Š)Úlast_hidden_stateÚhidden_statesrÕ   )#rÑ   r   r-   Ú
reduce_sumr…   Ú	not_equalrË   r;   Úconvert_to_tensorrB   rC   rL   rF   r>   r+   r@   ro   rÎ   r   r½   rî   Úgatherrã   rÈ   rÇ   rå   rÀ   re   rÕ   rÖ   r×   rØ   ÚsizeÚtupler   )rh   Ú	input_idsÚattention_maskÚlangsÚtoken_type_idsÚposition_idsrE   rŒ   r�   Úinputs_embedsr_   rÂ   rÄ   r‚   rH   rD   rI   rK   Ú_slenÚtensorrú   rÕ   rà   Úattn_outputsÚattns                            r7   r›   zTFXLMMainLayer.callƒ  s¢  € ð& Ð  ]Ð%>ÜÐcÓdÐdØÐ"Ü! )Ó,‰HˆB‘ØÐ&Ü! -Ó0°°!Ð4‰HˆB‘äÐTÓUÐUàˆ?ØÐ$ÜŸ-™-Ü—G‘GœBŸL™L¨°D·N±NÓCÈ9Ï?É?Ô[Ðbcô‘ô ×.Ñ.°¨v¸©{Ó;�ô �L‰L×%Ñ%¤j°Ó&9¸!Ñ&<¸bÓAØ"¤:¨gÓ#6°qÑ#9Ð":Ð:SÐTVÐSWÐWbÐcñ	
ô $ D¨'°4·;±;È^Ô\‰ˆˆið
 ÐÜŸ>™>¬"¯(©(°4«.¸qÔAˆLÜŸ7™7 <°"°a°Ó9ˆLô �L‰L×%Ñ%¤j°Ó&>ÀÀTÀ
ÓKØ ¤¨LÓ!9Ð :Ð:KÈRÐQUÈJÈ<ÐWbÐcñ	
ð Ðô —‘×)Ñ)¬*°UÓ*;¸bÀ$¸ZÓHØœj¨Ó/Ð0Ð0AÀ2ÀtÀ*ÀÈ[ÐYñð Ð Ü%Ð%à˜ §¡Ñ.ˆIð Ð Ð!6Ø˜5 ™=Ñ(ˆEØ!¢! e V¡W *Ñ-ˆIØ'ª¨E¨6©7¨
Ñ3ˆLØÐ Øša % ¡˜jÑ)�Øš˜E˜6™7˜
Ñ#ˆDØ!¢! e V¡W *Ñ-ˆIð Ð Ü*¨9°d·o±o×6PÑ6PÔQØ ŸO™O¨IÓ6ˆMà¤§¡¨4×+CÑ+CÀ\Ó!RÑRˆàÐ ×!2Ò!2°t·|±|ÀaÒ7GØœbŸi™i¨×(<Ñ(<¸eÓDÑDˆFØÐ%Ø˜dŸo™o¨nÓ=Ñ=ˆFà×$Ñ$ VÓ,ˆØ—‘˜f¨x�Ó8ˆÜ�w‰w�t 6§<¡<Ô0ˆØœ"Ÿ.™.¨°BÔ7Ñ7ˆñ 3™¸ˆÙ,‘R°$ˆ
ä�t—}‘}Ó%ò !	<ˆAÙ#Ø -°°	Ñ 9�ð .˜4Ÿ?™?¨1Ñ-ØØØØØ˜!‘Ø!Ø!ôˆLð   ‘?ˆDá Ø'¨<¸©?Ð*<Ñ<�
à—<‘< ¨x�<Ó8ˆDØ˜d‘]ˆFØ(�T×%Ñ% aÑ(¨Ó0ˆFð ˜l˜dŸi™i¨™l¨6Ó2Ñ2ˆFØ(�T×%Ñ% aÑ(¨Ó0ˆFØœbŸn™n¨T¸Ô;Ñ;‰FðC!	<ñH  Ø)¨V¨IÑ5ˆMð ÐØ�&‹M˜VŸ[™[¨›^Ñ+‹Mñ
 ÜÑY V¨]¸JÐ$GÔYÓYÐYä °6ÈÐcmÔnÐnrM   rm   ©NNNNNNNNNNNNF)Úreturnz*Union[TFBaseModelOutput, Tuple[tf.Tensor]])r¤   r¥   r¦   r&   Úconfig_classrZ   r    ré   rñ   rô   r   r›   r©   rª   s   @r7   rº   rº   õ   sr   ø„ à€LôUJón#4òJò:ò"ð ð ØØØØØØØØØØ!ØØðeoð 
4òeoó ôeorM   rº   c                  ó(   — e Zd ZdZeZdZed„ «       Zy)ÚTFXLMPreTrainedModelz†
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    Útransformerc                ó†  — t        j                  g d¢g d¢g d¢gt         j                  ¬«      }t        j                  g d¢g d¢g d¢gt         j                  ¬«      }| j                  j                  rK| j                  j
                  dkD  r2||t        j                  g d¢g d¢g d¢gt         j                  ¬«      d	œS ||d
œS )N)é   é   r   r   r%   )r%   r(   r	   r   r   )r   r   r   r¼   é   r:   )r%   r%   r   r   r%   )r%   r%   r%   r   r   )r%   r   r   r%   r%   r%   )r  r  r  )r  r  )r-   r.   Úint32ri   rÈ   rÇ   )rh   Úinputs_listÚ
attns_lists      r7   Údummy_inputsz!TFXLMPreTrainedModel.dummy_inputs5  s—   € ô —k‘k¢?²OÂ_Ð"UÔ]_×]eÑ]eÔfˆÜ—[‘[¢/²?ÂOÐ!TÔ\^×\dÑ\dÔeˆ
Ø�;‰;×#Ò#¨¯©×(;Ñ(;¸aÒ(?à(Ø",ÜŸ™¢o²ÊÐ%XÔ`b×`hÑ`hÔiñð ð "-À
ÑKÐKrM   N)	r¤   r¥   r¦   Ú__doc__r&   r  Úbase_model_prefixÚpropertyr  rX   rM   r7   r  r  ,  s(   „ ñð
 €LØ%ÐàñLó ñLrM   r  c                  ó<   — e Zd ZU dZdZded<   dZded<   dZded<   y)ÚTFXLMWithLMHeadModelOutputa^  
    Base class for [`TFXLMWithLMHeadModel`] outputs.

    Args:
        logits (`tf.Tensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
            Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
        hidden_states (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
            Tuple of `tf.Tensor` (one for the output of the embeddings + one for the output of each layer) of shape
            `(batch_size, sequence_length, hidden_size)`.

            Hidden-states of the model at the output of each layer plus the initial embedding outputs.
        attentions (`tuple(tf.Tensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
            Tuple of `tf.Tensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
            sequence_length)`.

            Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
            heads.
    NzOptional[tf.Tensor]ÚlogitszTuple[tf.Tensor, ...] | Nonerú   rÕ   )r¤   r¥   r¦   r  r  Ú__annotations__rú   rÕ   rX   rM   r7   r  r  E  s*   … ñð& #'€FÐÓ&Ø26€MÐ/Ó6Ø/3€JÐ,Ô3rM   r  ay	  

    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>

    Parameters:
        config ([`XLMConfig`]): 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)
        langs (`tf.Tensor` or `Numpy array` of shape `({0})`, *optional*):
            A parallel sequence of tokens to be used to indicate the language of each token in the input. Indices are
            languages ids which can be obtained from the language names by using two conversion mappings provided in
            the configuration of the model (only provided for multilingual models). More precisely, the *language name
            to language id* mapping is in `model.config.lang2id` (which is a dictionary string to int) and the
            *language id to language name* mapping is in `model.config.id2lang` (dictionary int to string).

            See usage examples detailed in the [multilingual documentation](../multilingual).
        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)
        lengths (`tf.Tensor` or `Numpy array` of shape `(batch_size,)`, *optional*):
            Length of each sentence that can be used to avoid performing attention on padding token indices. You can
            also use *attention_mask* for the same result (see above), kept here for compatibility. Indices selected in
            `[0, ..., input_ids.size(-1)]`.
        cache (`Dict[str, tf.Tensor]`, *optional*):
            Dictionary string to `tf.Tensor` that contains precomputed hidden states (key and values in the attention
            blocks) as computed by the model (see `cache` output below). Can be used to speed up sequential decoding.

            The dictionary object will be modified in-place during the forward pass to add newly computed
            hidden-states.
        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).
z]The bare XLM 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 )	Ú
TFXLMModelc                óP   •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        y )Nr  ©rT   )rY   rZ   rº   r  ©rh   ri   Úinputsrj   rk   s       €r7   rZ   zTFXLMModel.__init__Ø  s)   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ü)¨&°}ÔEˆÕrM   úbatch_size, sequence_length©Ú
checkpointÚoutput_typer  c                óB   — | j                  |||||||||	|
|||¬«      }|S )N©r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   r‚   )r  )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   r‚   rš   s                  r7   r›   zTFXLMModel.callÜ  sG   € ð. ×"Ñ"ØØ)ØØ)Ø%ØØØØ'Ø/Ø!5Ø#Øð #ó 
ˆð  ˆrM   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  rT   r    r¡   s     r7   r    zTFXLMModel.build  sm   € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ð -ð :÷-ð -ús   ÁA1Á1A:r  )r  úTFModelInputType | Noner  útf.Tensor | Noner  r.  r  r.  r  r.  rE   r.  rŒ   zDict[str, tf.Tensor] | Noner�   r.  r  r.  r_   úbool | NonerÂ   r/  rÄ   r/  r‚   Úboolr  z$TFBaseModelOutput | Tuple[tf.Tensor]rm   )r¤   r¥   r¦   rZ   r   r#   ÚXLM_INPUTS_DOCSTRINGÚformatr!   Ú_CHECKPOINT_FOR_DOCr   Ú_CONFIG_FOR_DOCr›   r    r©   rª   s   @r7   r!  r!  Ó  s  ø„ ô
Fð Ù*Ð+?×+FÑ+FÐGdÓ+eÓfÙØ&Ø%Ø$ôð .2Ø+/Ø"&Ø+/Ø)-Ø$(Ø-1Ø&*Ø*.Ø)-Ø,0Ø#'Øð à*ð ð )ð ð  ð	 ð
 )ð ð 'ð ð "ð ð +ð ð $ð ð (ð ð 'ð ð *ð ð !ð ð ð ð 
.ò óó gó ð ÷D-rM   r!  c                  óJ   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
ˆ xZS )	ÚTFXLMPredLayerz?
    Prediction layer (cross_entropy or adaptive_softmax).
    c                óÀ   •— t        ‰| �  di |¤Ž |j                  | _        |j                  | _        |j                  | _        |j                  du r|| _        y t        ‚)NFrX   )rY   rZ   ÚasmrÉ   rË   Úinput_embeddingsro   )rh   ri   r9  rj   rk   s       €r7   rZ   zTFXLMPredLayer.__init__  sP   ø€ Ü‰ÑÑ"˜6Ò"à—:‘:ˆŒØ—~‘~ˆŒØ×)Ñ)ˆŒà�:‰:˜ÑØ$4ˆDÕ!ä%Ð%rM   c                ón   •— | j                  | j                  fddd¬«      | _        t        ‰| �  |«       y )NÚzerosTÚbias)r}   rä   Ú	trainablerT   )ræ   rÉ   r<  rY   r    )rh   r¢   rk   s     €r7   r    zTFXLMPredLayer.build&  s/   ø€ à—O‘O¨4¯<©<¨/ÀwÐZ^Ðek�OÓlˆŒ	ä‰‰�kÕ"rM   c                ó   — | j                   S rm   )r9  rè   s    r7   Úget_output_embeddingsz$TFXLMPredLayer.get_output_embeddings,  s   € Ø×$Ñ$Ð$rM   c                ó`   — || j                   _        t        |«      d   | j                   _        y rì   )r9  rí   r   rî   rï   s     r7   Úset_output_embeddingsz$TFXLMPredLayer.set_output_embeddings/  s(   € Ø',ˆ×ÑÔ$Ü+5°eÓ+<¸QÑ+?ˆ×ÑÕ(rM   c                ó   — d| j                   iS )Nr<  )r<  rè   s    r7   Úget_biaszTFXLMPredLayer.get_bias3  s   € Ø˜Ÿ	™	Ð"Ð"rM   c                óD   — |d   | _         t        |d   «      d   | _        y )Nr<  r   )r<  r   rî   rï   s     r7   Úset_biaszTFXLMPredLayer.set_bias6  s"   € Ø˜&‘MˆŒ	Ü$ U¨6¡]Ó3°AÑ6ˆ�rM   c                óJ   — | j                  |d¬«      }|| j                  z   }|S )NÚlinear)Úmode)r9  r<  )rh   rú   s     r7   r›   zTFXLMPredLayer.call:  s+   € Ø×-Ñ-¨mÀ(Ð-ÓKˆØ%¨¯	©	Ñ1ˆàÐrM   )r¤   r¥   r¦   r  rZ   r    r?  rA  rC  rE  r›   r©   rª   s   @r7   r6  r6    s,   ø„ ñô
&ô&#ò%ò@ò#ò7örM   r6  z†
    The XLM Model transformer with a language modeling head on top (linear layer with weights tied to the input
    embeddings).
    c                  óì   ‡ — e Zd Zˆ fd„Z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 )ÚTFXLMWithLMHeadModelc                ó¬   •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        t	        || j                  j
                  d¬«      | _        d| _        y )Nr  r#  zpred_layer_._projF)rY   rZ   rº   r  r6  r½   Ú
pred_layerÚsupports_xla_generationr$  s       €r7   rZ   zTFXLMWithLMHeadModel.__init__I  sN   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ü)¨&°}ÔEˆÔÜ(¨°×1AÑ1A×1LÑ1LÐSfÔgˆŒà',ˆÕ$rM   c                ó   — | j                   S rm   )rL  rè   s    r7   Úget_lm_headz TFXLMWithLMHeadModel.get_lm_headP  rê   rM   c                ó‚   — t        j                  dt        «       | j                  dz   | j                  j                  z   S )NzMThe method get_prefix_bias_name is deprecated. Please use `get_bias` instead.ú/)ÚwarningsÚwarnÚFutureWarningrT   rL  rè   s    r7   Úget_prefix_bias_namez)TFXLMWithLMHeadModel.get_prefix_bias_nameS  s/   € Ü�‰ÐeÔgtÔuØ�y‰y˜3‰ §¡×!5Ñ!5Ñ5Ð5rM   c                ó$  — | j                   j                  }| j                   j                  }|j                  d   }t	        j
                  |dfd«      |z  }t	        j                  ||gd¬«      }|�t	        j                  |«      |z  }nd }||dœS )Nr   r%   r<   ©r  r  )ri   Úmask_token_idÚlang_idr}   r-   Úfillr„   Ú	ones_like)rh   r%  rj   rX  rY  Úeffective_batch_sizeÚ
mask_tokenr  s           r7   Úprepare_inputs_for_generationz2TFXLMWithLMHeadModel.prepare_inputs_for_generationW  s‡   € ØŸ™×1Ñ1ˆØ—+‘+×%Ñ%ˆà%Ÿ|™|¨A™ÐÜ—W‘WÐ2°AÐ6¸Ó:¸]ÑJˆ
Ü—‘˜F JÐ/°aÔ8ˆàÐÜ—L‘L Ó(¨7Ñ2‰EàˆEØ#¨eÑ4Ð4rM   r&  r'  c                óÄ   — | j                  |||||||||	|
|||¬«      }|d   }| j                  |«      }|s	|f|dd  z   S t        ||j                  |j                  ¬«      S )Nr+  r   r%   )r  rú   rÕ   )r  rL  r  rú   rÕ   )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   r‚   Útransformer_outputsÚoutputrš   s                    r7   r›   zTFXLMWithLMHeadModel.calle  s•   € ð. #×.Ñ.ØØ)ØØ)Ø%ØØØØ'Ø/Ø!5Ø#Øð /ó 
Ðð  % QÑ'ˆØ—/‘/ &Ó)ˆáØ�:Ð 3°A°BÐ 7Ñ7Ð7ä)ØÐ*=×*KÑ*KÐXk×XvÑXvô
ð 	
rM   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  rL  )r�   rž   r-   rŸ   r  rT   r    rL  r¡   s     r7   r    zTFXLMWithLMHeadModel.build–  s¹   € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ ,Ø—‘×%Ñ% dÔ+÷,ð ,ð 9÷-ð -ú÷,ð ,úó   ÁCÂ%CÃCÃC r  )r  r-  r  únp.ndarray | tf.Tensor | Noner  rd  r  rd  r  rd  rE   rd  rŒ   úOptional[Dict[str, tf.Tensor]]r�   rd  r  rd  r_   úOptional[bool]rÂ   rf  rÄ   rf  r‚   r0  r  z3Union[TFXLMWithLMHeadModelOutput, Tuple[tf.Tensor]]rm   )r¤   r¥   r¦   rZ   rO  rU  r^  r   r#   r1  r2  r!   r3  r  r4  r›   r    r©   rª   s   @r7   rJ  rJ  A  s  ø„ ô-òò6ò5ð Ù*Ð+?×+FÑ+FÐGdÓ+eÓfÙØ&Ø.Ø$ôð .2Ø8<Ø/3Ø8<Ø6:Ø15Ø04Ø37Ø7;Ø,0Ø/3Ø&*Øð(
à*ð(
ð 6ð(
ð -ð	(
ð
 6ð(
ð 4ð(
ð /ð(
ð .ð(
ð 1ð(
ð 5ð(
ð *ð(
ð -ð(
ð $ð(
ð ð(
ð 
=ò(
óó gó ð(
÷T	,rM   rJ  z�
    XLM Model with a sequence classification/regression head on top (a linear layer on top of the pooled output) 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 )	ÚTFXLMForSequenceClassificationc                ó¬   •— t        ‰| �  |g|¢­i |¤Ž |j                  | _        t        |d¬«      | _        t        ||j                  d¬«      | _        y )Nr  r#  Úsequence_summaryr¾   )rY   rZ   Ú
num_labelsrº   r  r   rb   rj  r$  s       €r7   rZ   z'TFXLMForSequenceClassification.__init__ª  sL   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ø ×+Ñ+ˆŒä)¨&°}ÔEˆÔÜ 1°&ÈFÏOÉOÐbtÔ uˆÕrM   r&  r'  c                ó  — | j                  |||||||||	|
|||¬«      }|d   }| 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,)`, *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+  r   Nr%   ©Úlossr  rú   rÕ   )r  rj  Úhf_compute_lossr   rú   rÕ   )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   Úlabelsr‚   r`  ra  r  rn  s                      r7   r›   z#TFXLMForSequenceClassification.call±  sÈ   € ð< #×.Ñ.ØØ)ØØ)Ø%ØØØØ'Ø/Ø!5Ø#Øð /ó 
Ðð % QÑ'ˆà×&Ñ& vÓ.ˆà�~‰t¨4×+?Ñ+?ÀÈÓ+OˆáØ�YÐ!4°Q°RÐ!8Ñ8ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä)ØØØ-×;Ñ;Ø*×5Ñ5ô	
ð 	
rM   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  rj  )r�   rž   r-   rŸ   r  rT   r    rj  r¡   s     r7   r    z$TFXLMForSequenceClassification.buildï  s¾   € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ä�4Ð+¨TÓ2Ð>Ü—‘˜t×4Ñ4×9Ñ9Ó:ñ 2Ø×%Ñ%×+Ñ+¨DÔ1÷2ð 2ð ?÷-ð -ú÷2ð 2úrc  ©NNNNNNNNNNNNNF)r  r-  r  rd  r  rd  r  rd  r  rd  rE   rd  rŒ   re  r�   rd  r  rd  r_   rf  rÂ   rf  rÄ   rf  rp  rd  r‚   r0  r  z3Union[TFSequenceClassifierOutput, Tuple[tf.Tensor]]rm   )r¤   r¥   r¦   rZ   r   r#   r1  r2  r!   r3  r   r4  r›   r    r©   rª   s   @r7   rh  rh  ¢  s  ø„ ôvð Ù*Ð+?×+FÑ+FÐGdÓ+eÓfÙØ&Ø.Ø$ôð .2Ø8<Ø/3Ø8<Ø6:Ø15Ø04Ø37Ø7;Ø,0Ø/3Ø&*Ø04Øð5
à*ð5
ð 6ð5
ð -ð	5
ð
 6ð5
ð 4ð5
ð /ð5
ð .ð5
ð 1ð5
ð 5ð5
ð *ð5
ð -ð5
ð $ð5
ð .ð5
ð ð5
ð  
=ò!5
óó gó ð5
÷n	2rM   rh  z¤
    XLM 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d„ «       Ze eej                  d«      «       e
eee¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       «       «       Zd	d„Zˆ xZS )
ÚTFXLMForMultipleChoicec                ó  •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        t	        ||j
                  d¬«      | _        t        j                  j                  dt        |j                  «      d¬«      | _        || _        y )Nr  r#  rj  r¾   r%   Úlogits_projrR   )rY   rZ   rº   r  r   rb   rj  r   r`   ra   r   r¿   rv  ri   r$  s       €r7   rZ   zTFXLMForMultipleChoice.__init__  sw   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3ä)¨&°}ÔEˆÔÜ 1°&ÈFÏOÉOÐbtÔ uˆÔÜ Ÿ<™<×-Ñ-Ø¤/°&×2JÑ2JÓ"KÐR_ð .ó 
ˆÔð ˆ�rM   c                ó\  — | j                   j                  rl| j                   j                  dkD  rSt        j                  t
        t        j                  ¬«      t        j                  t
        t        j                  ¬«      dœS dt        j                  t
        t        j                  ¬«      iS )zn
        Dummy inputs to build the network.

        Returns:
            tf.Tensor with dummy inputs
        r%   r:   rW  r  )ri   rÈ   rÇ   r-   r.   r   r  rè   s    r7   r  z#TFXLMForMultipleChoice.dummy_inputs  ss   € ð �;‰;×#Ò#¨¯©×(;Ñ(;¸aÒ(?äŸ[™[Ô)EÌRÏXÉXÔVÜŸ™Ô%AÌÏÉÔRñð ð œRŸ[™[Ô)EÌRÏXÉXÔVðð rM   z(batch_size, num_choices, sequence_lengthr'  c                ój  — |�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|f«      nd }|	�%t        j                  |	d|t        |	«      d   f«      nd }|�t        j	                  d«       d }| j                  ||||||||||
|||¬«      }|d   }| j                  |«      }| j                  |«      }t        j                  |d|f«      }|€d n| j                  ||«      }|s|f|dd  z   }|�|f|z   S |S t        |||j                  |j                  ¬«      S )	Nr%   r(   ru   r	   zrThe `lengths` parameter cannot be used with the XLM multiple choice models. Please use the attention mask instead.)rÄ   r‚   r   rm  )r   r-   rA   ÚloggerÚwarningr  rj  rv  ro  r   rú   rÕ   )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   rp  r‚   Únum_choicesÚ
seq_lengthÚflat_input_idsÚflat_attention_maskÚflat_token_type_idsÚflat_position_idsÚ
flat_langsÚflat_inputs_embedsr`  ra  r  Úreshaped_logitsrn  s                               r7   r›   zTFXLMForMultipleChoice.call   s  € ð0 Ð Ü$ 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ÐØ<AÐ<M”R—Z‘Z ¨¨JÐ'7Ô8ÐSWˆ
ð Ð(ô �J‰J�} r¨:´zÀ-Ó7PÐQRÑ7SÐ&TÔUàð 	ð ÐÜ�N‰Nð*ôð ˆGà"×.Ñ.ØØØØØØØØØØØ Ø#Øð /ó 
Ðð % QÑ'ˆØ×&Ñ& vÓ.ˆØ×!Ñ! &Ó)ˆÜŸ*™* V¨b°+Ð->Ó?ˆà�~‰t¨4×+?Ñ+?ÀÈÓ+XˆáØ%Ð'Ð*=¸a¸bÐ*AÑAˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä*ØØ"Ø-×;Ñ;Ø*×5Ñ5ô	
ð 	
rM   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)NTr  rj  rv  )r�   rž   r-   rŸ   r  rT   r    rj  rv  ri   rk  r¡   s     r7   r    zTFXLMForMultipleChoice.buildr  s$  € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ä�4Ð+¨TÓ2Ð>Ü—‘˜t×4Ñ4×9Ñ9Ó:ñ 2Ø×%Ñ%×+Ñ+¨DÔ1÷2ä�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ MØ× Ñ ×&Ñ&¨¨d°D·K±K×4JÑ4JÐ'KÔL÷Mð Mð :÷-ð -ú÷2ð 2ú÷Mð Mús$   ÁD<Â%EÃ?3EÄ<EÅEÅErr  )r  r-  r  rd  r  rd  r  rd  r  rd  rE   rd  rŒ   re  r�   rd  r  rd  r_   rf  rÂ   rf  rÄ   rf  rp  rd  r‚   r0  r  z4Union[TFMultipleChoiceModelOutput, Tuple[tf.Tensor]]rm   )r¤   r¥   r¦   rZ   r  r  r   r#   r1  r2  r!   r3  r   r4  r›   r    r©   rª   s   @r7   rt  rt  û  s9  ø„ ôð ñó ðð$ Ù*Ð+?×+FÑ+FÐGqÓ+rÓsÙØ&Ø/Ø$ôð .2Ø8<Ø/3Ø8<Ø6:Ø15Ø04Ø37Ø7;Ø,0Ø/3Ø&*Ø04ØðI
à*ðI
ð 6ðI
ð -ð	I
ð
 6ðI
ð 4ðI
ð /ðI
ð .ðI
ð 1ðI
ð 5ðI
ð *ðI
ð -ðI
ð $ðI
ð .ðI
ð ðI
ð  
>ò!I
óó tó ðI
÷VMrM   rt  z¢
    XLM 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 )	ÚTFXLMForTokenClassificationc                ód  •— t        ‰| �  |g|¢­i |¤Ž |j                  | _        t        |d¬«      | _        t
        j                  j                  |j                  «      | _        t
        j                  j                  |j                  t        |j                  «      d¬«      | _        || _        y )Nr  r#  Ú
classifierrR   )rY   rZ   rk  rº   r  r   r`   rc   re   ra   r   rb   rˆ  ri   r$  s       €r7   rZ   z$TFXLMForTokenClassification.__init__‰  s‹   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ø ×+Ñ+ˆŒä)¨&°}ÔEˆÔÜ—|‘|×+Ñ+¨F¯N©NÓ;ˆŒÜŸ,™,×,Ñ,Ø×Ñ´/À&Ç/Á/Ó2RÐYeð -ó 
ˆŒð ˆ�rM   r&  r'  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%   rm  )r  re   rˆ  ro  r   rú   rÕ   )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   rp  r‚   r`  Úsequence_outputr  rn  ra  s                       r7   r›   z TFXLMForTokenClassification.call”  sØ   € ð8 #×.Ñ.ØØ)ØØ)Ø%ØØØØ'Ø/Ø!5Ø#Øð /ó 
Ðð .¨aÑ0ˆàŸ,™, À˜,ÓJˆØ—‘ Ó1ˆà�~‰t¨4×+?Ñ+?ÀÈÓ+OˆáØ�YÐ!4°Q°RÐ!8Ñ8ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä&ØØØ-×;Ñ;Ø*×5Ñ5ô	
ð 	
rM   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)NTr  rˆ  )
r�   rž   r-   rŸ   r  rT   r    rˆ  ri   Úhidden_sizer¡   s     r7   r    z!TFXLMForTokenClassification.buildÑ  óÏ   € Ø�:Š:ØØˆŒ
Ü�4˜¨Ó-Ð9Ü—‘˜t×/Ñ/×4Ñ4Ó5ñ -Ø× Ñ ×&Ñ& tÔ,÷-ä�4˜ tÓ,Ð8Ü—‘˜tŸ™×3Ñ3Ó4ñ MØ—‘×%Ñ% t¨T°4·;±;×3JÑ3JÐ&KÔL÷Mð Mð 9÷-ð -ú÷Mð Múó   ÁC"Â%3C.Ã"C+Ã.C7rr  )r  r-  r  rd  r  rd  r  rd  r  rd  rE   rd  rŒ   re  r�   rd  r  rd  r_   rf  rÂ   rf  rÄ   rf  rp  rd  r‚   r0  r  z0Union[TFTokenClassifierOutput, Tuple[tf.Tensor]]rm   )r¤   r¥   r¦   rZ   r   r#   r1  r2  r!   r3  r   r4  r›   r    r©   rª   s   @r7   r†  r†  �  s  ø„ ô	ð Ù*Ð+?×+FÑ+FÐGdÓ+eÓfÙØ&Ø+Ø$ôð .2Ø8<Ø/3Ø8<Ø6:Ø15Ø04Ø37Ø7;Ø,0Ø/3Ø&*Ø04Øð4
à*ð4
ð 6ð4
ð -ð	4
ð
 6ð4
ð 4ð4
ð /ð4
ð .ð4
ð 1ð4
ð 5ð4
ð *ð4
ð -ð4
ð $ð4
ð .ð4
ð ð4
ð  
:ò!4
óó gó ð4
÷l	MrM   r†  zÛ
    XLM 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 )	ÚTFXLMForQuestionAnsweringSimplec                óæ   •— t        ‰| �  |g|¢­i |¤Ž t        |d¬«      | _        t        j
                  j                  |j                  t        |j                  «      d¬«      | _
        || _        y )Nr  r#  Ú
qa_outputsrR   )rY   rZ   rº   r  r   r`   ra   rk  r   rb   r’  ri   r$  s       €r7   rZ   z(TFXLMForQuestionAnsweringSimple.__init__å  sd   ø€ Ü‰Ñ˜Ð3 &Ò3¨FÒ3Ü)¨&°}ÔEˆÔÜŸ,™,×,Ñ,Ø×Ñ´/À&Ç/Á/Ó2RÐYeð -ó 
ˆŒð ˆ�rM   r&  r'  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(   ru   r<   NÚstart_positionÚend_positionr%   )rn  Ústart_logitsÚ
end_logitsrú   rÕ   )	r  r’  r-   ÚsplitÚsqueezero  r   rú   rÕ   )rh   r  r  r  r  r  rE   rŒ   r�   r  r_   rÂ   rÄ   Ústart_positionsÚend_positionsr‚   r`  rŠ  r  r–  r—  rn  rp  ra  s                           r7   r›   z$TFXLMForQuestionAnsweringSimple.callí  s'  € ðF #×.Ñ.ØØ)ØØ)Ø%ØØØØ'Ø/Ø!5Ø#Øð /ó 
Ðð .¨aÑ0ˆà—‘ Ó1ˆÜ#%§8¡8¨F°A¸BÔ#?Ñ ˆ�jÜ—z‘z ,°RÔ8ˆÜ—Z‘Z 
°Ô4ˆ
àˆØÐ&¨=Ð+DØ&¨Ð8ˆFØ%2ˆF�>Ñ"Ø×'Ñ'¨°¸zÐ0JÓKˆDáØ" JÐ/Ð2EÀaÀbÐ2IÑIˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä-ØØ%Ø!Ø-×;Ñ;Ø*×5Ñ5ô
ð 	
rM   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)NTr  r’  )
r�   rž   r-   rŸ   r  rT   r    r’  ri   rŒ  r¡   s     r7   r    z%TFXLMForQuestionAnsweringSimple.build8  r�  rŽ  )NNNNNNNNNNNNNNF) r  r-  r  rd  r  rd  r  rd  r  rd  rE   rd  rŒ   re  r�   rd  r  rd  r_   rf  rÂ   rf  rÄ   rf  rš  rd  r›  rd  r‚   r0  r  z7Union[TFQuestionAnsweringModelOutput, Tuple[tf.Tensor]]rm   )r¤   r¥   r¦   rZ   r   r#   r1  r2  r!   r3  r   r4  r›   r    r©   rª   s   @r7   r�  r�  Ý  s4  ø„ ôð Ù*Ð+?×+FÑ+FÐGdÓ+eÓfÙØ&Ø2Ø$ôð .2Ø8<Ø/3Ø8<Ø6:Ø15Ø04Ø37Ø7;Ø,0Ø/3Ø&*Ø9=Ø7;Øð!B
à*ðB
ð 6ðB
ð -ð	B
ð
 6ðB
ð 4ðB
ð /ðB
ð .ðB
ð 1ðB
ð 5ðB
ð *ðB
ð -ðB
ð $ðB
ð 7ðB
ð 5ðB
ð  ð!B
ð" 
Aò#B
óó gó ðB
÷H	MrM   r�  )rt  r�  rh  r†  rº   r!  r  rJ  rm   )Jr  Ú
__future__r   r§   rR  Údataclassesr   Útypingr   r   r   r   Únumpyr)   Ú
tensorflowr-   Úactivations_tfr
   Úmodeling_tf_outputsr   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"   r#   r$   Úconfiguration_xlmr&   Ú
get_loggerr¤   ry  r3  r4  r8   rL   r`   ÚLayerrO   r¬   rº   r  r  ÚXLM_START_DOCSTRINGr1  r!  r6  rJ  rh  rt  r†  r�  Ú__all__rX   rM   r7   ú<module>r¬     sd  ðñõ #ã Û Ý !ß /Ó /ã Û å /÷õ ÷÷ ÷ ó ÷ SÑ R÷÷ õ )ð 
ˆ×	Ñ	˜HÓ	%€à2Ð Ø€ò>óô:k;˜eŸl™l×0Ñ0ô k;ô\?˜%Ÿ,™,×,Ñ,ô ?ð> ôso�U—\‘\×'Ñ'ó soó ðsoôl	LÐ,ô Lð2 ô4 ó 4ó ð4ð2(Ð ðTGÐ ñT ØcØóô4-Ð%ó 4-ó	ð4-ôn0�U—\‘\×'Ñ'ô 0ñf ðð óôW,Ð/ó W,óðW,ñt ðð óôO2Ð%9Ð;Wó O2óðO2ñd ðð óô|MÐ1Ð3Gó |Móð|Mñ~ ðð óôRMÐ"6Ð8Qó RMóðRMñj ðð óô]MÐ&:Ð<Só ]Móð]Mò@	�rM   