ó
    ˆŽ¡ju{  ã                   ó¸  • S r SSKrSSKJr  SSKJrJrJr  SSKJr	  SSK
Jr  SSKJr  SSKJrJrJrJrJrJrJr  SS	KJr  SS
KJr  SSKJrJrJr  SSKJr  SSK J!r!J"r"J#r#J$r$J%r%  SSK&J'r'  \RP                  " \)5      r* " S S\"5      r+ " S S\%5      r, " S S\!5      r- " S S\#5      r.\ " S S\5      5       r/ " S S\$5      r0\" SS9 " S S \/\5      5       r1\ " S! S"\/5      5       r2 " S# S$\Rf                  5      r4\" S%S9 " S& S'\/5      5       r5\ " S( S)\/5      5       r6\ " S* S+\/5      5       r7 " S, S-\Rf                  5      r8\ " S. S/\/5      5       r9/ S0Qr:g)1zPyTorch RoBERTa model.é    N)ÚBCEWithLogitsLossÚCrossEntropyLossÚMSELossé   )Úinitialization)Úgelu)ÚGenerationMixin)Ú,BaseModelOutputWithPoolingAndCrossAttentionsÚ!CausalLMOutputWithCrossAttentionsÚMaskedLMOutputÚMultipleChoiceModelOutputÚQuestionAnsweringModelOutputÚSequenceClassifierOutputÚTokenClassifierOutput)ÚPreTrainedModel)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚlogging)Úcan_return_tupleé   )ÚBertCrossAttentionÚBertEmbeddingsÚ	BertLayerÚ	BertModelÚBertSelfAttentioné   )ÚRobertaConfigc                   óà   ^ • \ rS rSrU 4S jr     SS\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S\4
S	 jjr	\
S
 5       r\
SS j5       rSrU =r$ )ÚRobertaEmbeddingsé,   c                 óÀ   >• [         TU ]  U5        U ?U ?UR                  U l        [
        R                  " UR                  UR                  U R                  S9U l        g )N)Úpadding_idx)	ÚsuperÚ__init__Úpad_token_idÚposition_embeddingsr#   ÚnnÚ	EmbeddingÚmax_position_embeddingsÚhidden_size©ÚselfÚconfigÚ	__class__s     €Ú¹C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\transformers/models/roberta/modular_roberta.pyr%   ÚRobertaEmbeddings.__init__-   sT   ø€ Ü‰Ñ˜Ô àÐØÐ$à!×.Ñ.ˆÔÜ#%§<¢<Ø×*Ñ*¨F×,>Ñ,>ÈD×L\ÑL\ñ$
ˆÕ ó    NÚ	input_idsÚtoken_type_idsÚposition_idsÚinputs_embedsÚpast_key_values_lengthc                 ó  • Uc;  Ub  U R                  XR                  U5      nOU R                  X@R                  5      nUb  UR                  5       nOUR                  5       S S nUu  pxUc³  [	        U S5      (       aj  U R
                  R                  UR                  5      R                  UR                  S   S5      n	[        R                  " U	SUS9n	U	R                  Xx5      nO8[        R                  " U[        R                  U R                  R                  S9nUc  U R                  U5      nU R!                  U5      n
XJ-   nU R#                  U5      nX¼-   nU R%                  U5      nU R'                  U5      nU$ )Néÿÿÿÿr4   r   r   )ÚdimÚindex©ÚdtypeÚdevice)Ú"create_position_ids_from_input_idsr#   Ú&create_position_ids_from_inputs_embedsÚsizeÚhasattrr4   Útor>   ÚexpandÚshapeÚtorchÚgatherÚzerosÚlongr5   Úword_embeddingsÚtoken_type_embeddingsr'   Ú	LayerNormÚdropout)r-   r3   r4   r5   r6   r7   Úinput_shapeÚ
batch_sizeÚ
seq_lengthÚbuffered_token_type_idsrK   Ú
embeddingsr'   s                r0   ÚforwardÚRobertaEmbeddings.forward8   st  € ð ÑØÑ$à#×FÑFØ×/Ñ/Ð1Gó ‘ð  $×JÑJÈ=×ZjÑZjÓk�àÑ Ø#Ÿ.™.Ó*‰Kà'×,Ñ,Ó.¨s°Ð3ˆKà!,Ñˆ
ð
 Ñ!Ü�tÐ-×.Ñ.à*.×*=Ñ*=×*@Ñ*@À×ATÑATÓ*U×*\Ñ*\Ð]i×]oÑ]oÐpqÑ]rÐtvÓ*wÐ'Ü*/¯,ª,Ð7NÐTUÐ]iÑ*jÐ'Ø!8×!?Ñ!?À
Ó!W‘ä!&§¢¨[ÄÇ
Á
ÐSW×SdÑSd×SkÑSkÑ!l�àÑ Ø ×0Ñ0°Ó;ˆMØ $× :Ñ :¸>Ó JÐØ"Ñ:ˆ
à"×6Ñ6°|ÓDÐØÑ5ˆ
à—^‘^ JÓ/ˆ
Ø—\‘\ *Ó-ˆ
ØÐr2   c                 óà   • U R                  5       SS nUS   n[        R                  " US-   X1-   S-   [        R                  U R                  S9nUR                  S5      R                  U5      $ )z¯
We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.

Args:
    inputs_embeds: torch.Tensor

Returns: torch.Tensor
Nr9   r   r<   r   )rA   rF   ÚarangerI   r>   Ú	unsqueezerD   )r6   r#   rN   Úsequence_lengthr5   s        r0   r@   Ú8RobertaEmbeddings.create_position_ids_from_inputs_embedsh   sn   € ð $×(Ñ(Ó*¨3¨BÐ/ˆØ% a™.ˆä—|’|Ø˜!‰O˜_Ñ:¸QÑ>ÄeÇjÁjÐYf×YmÑYmñ
ˆð ×%Ñ% aÓ(×/Ñ/°Ó<Ð<r2   c                 óº   • U R                  U5      R                  5       n[        R                  " USS9R	                  U5      U-   U-  nUR                  5       U-   $ )zí
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's `utils.make_positions`.

Args:
    x: torch.Tensor x:

Returns: torch.Tensor
r   ©r:   )ÚneÚintrF   ÚcumsumÚtype_asrI   )r3   r#   r7   ÚmaskÚincremental_indicess        r0   r?   Ú4RobertaEmbeddings.create_position_ids_from_input_idsz   sW   € ð �|‰|˜KÓ(×,Ñ,Ó.ˆÜ$Ÿ|š|¨D°aÑ8×@Ñ@ÀÓFÐI_Ñ_ÐcgÑgÐØ"×'Ñ'Ó)¨KÑ7Ð7r2   )r#   r'   )NNNNr   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r%   rF   Ú
LongTensorÚFloatTensorr]   rS   Ústaticmethodr@   r?   Ú__static_attributes__Ú__classcell__©r/   s   @r0   r    r    ,   s£   ø† õ	
ð .2Ø26Ø04Ø26Ø&'ñ.à×#Ñ# dÑ*ð.ð ×(Ñ(¨4Ñ/ð.ð ×&Ñ&¨Ñ-ð	.ð
 ×(Ñ(¨4Ñ/ð.ð !$õ.ð` ñ=ó ð=ð" ó8ó ö8r2   r    c                   ó   • \ rS rSrSrg)ÚRobertaSelfAttentioné‹   © N©rc   rd   re   rf   rj   rp   r2   r0   rn   rn   ‹   ó   † Úr2   rn   c                   ó   • \ rS rSrSrg)ÚRobertaCrossAttentioné�   rp   Nrq   rp   r2   r0   rt   rt   �   rr   r2   rt   c                   ó   • \ rS rSrSrg)ÚRobertaLayeré“   rp   Nrq   rp   r2   r0   rw   rw   “   rr   r2   rw   c                   óx   ^ • \ rS rSr\rSrSrSrSr	Sr
Sr\\\S.r\R"                  " 5       U 4S j5       rSrU =r$ )ÚRobertaPreTrainedModelé—   ÚrobertaT)Úhidden_statesÚ
attentionsÚcross_attentionsc                 ó²  >• [         TU ]  U5        [        U[        5      (       a!  [        R
                  " UR                  5        g[        U[        5      (       a|  [        R                  " UR                  [        R                  " UR                  R                  S   5      R                  S5      5        [        R
                  " UR                  5        gg)zInitialize the weightsr9   )r   r9   N)r$   Ú_init_weightsÚ
isinstanceÚRobertaLMHeadÚinitÚzeros_Úbiasr    Úcopy_r5   rF   rV   rE   rD   r4   )r-   Úmoduler/   s     €r0   r�   Ú$RobertaPreTrainedModel._init_weights¦   s�   ø€ ô 	‰Ñ˜fÔ%Ü�fœm×,Ñ,Ü�KŠK˜Ÿ™Õ$Ü˜Ô 1×2Ñ2Ü�JŠJ�v×*Ñ*¬E¯LªL¸×9LÑ9L×9RÑ9RÐSUÑ9VÓ,W×,^Ñ,^Ð_fÓ,gÔhÜ�KŠK˜×-Ñ-Õ.ð 3r2   rp   )rc   rd   re   rf   r   Úconfig_classÚbase_model_prefixÚsupports_gradient_checkpointingÚ_supports_flash_attnÚ_supports_sdpaÚ_supports_flex_attnÚ_supports_attention_backendrw   rn   rt   Ú_can_record_outputsrF   Úno_gradr�   rj   rk   rl   s   @r0   rz   rz   —   sV   ø† à €LØ!ÐØ&*Ð#ØÐØ€NØÐØ"&Ðà%Ø*Ø1ñÐð ‡]‚]ƒ_ô/ó ö/r2   rz   c                   ó,   ^ • \ rS rSrSU 4S jjrSrU =r$ )ÚRobertaModelé±   c                 ó$   >• [         TU ]  X5        g ©N)r$   r%   )r-   r.   Úadd_pooling_layerr/   s      €r0   r%   ÚRobertaModel.__init__²   s   ø€ Ü‰Ñ˜Õ&r2   rp   )T)rc   rd   re   rf   r%   rj   rk   rl   s   @r0   r”   r”   ±   s   ø† ÷'õ 'r2   r”   zS
    RoBERTa Model with a `language modeling` head on top for CLM fine-tuning.
    )Úcustom_introc                   óæ  ^ • \ rS rSrSSS.rU 4S jrS rS r\\	           SS	\
R                  S-  S
\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\\\
R                        S-  S\S-  S\\
R                   -  S\\   S\\
R                      \-  4S jj5       5       rSrU =r$ )ÚRobertaForCausalLMé¶   ú)roberta.embeddings.word_embeddings.weightúlm_head.bias©zlm_head.decoder.weightzlm_head.decoder.biasc                 óÎ   >• [         TU ]  U5        UR                  (       d  [        R	                  S5        [        USS9U l        [        U5      U l        U R                  5         g )NzOIf you want to use `RobertaLMHeadModel` as a standalone, add `is_decoder=True.`F©r˜   ©
r$   r%   Ú
is_decoderÚloggerÚwarningr”   r|   rƒ   Úlm_headÚ	post_initr,   s     €r0   r%   ÚRobertaForCausalLM.__init__Á   sL   ø€ Ü‰Ñ˜Ô à× × Ü�N‰NÐlÔmä# F¸eÑDˆŒÜ$ VÓ,ˆŒð 	�‰Õr2   c                 ó.   • U R                   R                  $ r—   ©r§   Údecoder©r-   s    r0   Úget_output_embeddingsÚ(RobertaForCausalLM.get_output_embeddingsÍ   ó   € Ø�|‰|×#Ñ#Ð#r2   c                 ó$   • XR                   l        g r—   r«   ©r-   Únew_embeddingss     r0   Úset_output_embeddingsÚ(RobertaForCausalLM.set_output_embeddingsÐ   ó   € Ø-�‰Õr2   Nr3   Úattention_maskr4   r5   r6   Úencoder_hidden_statesÚencoder_attention_maskÚlabelsÚpast_key_valuesÚ	use_cacheÚlogits_to_keepÚkwargsÚreturnc                 ó¤  • Ub  Sn
U R                   " U4UUUUUUU	U
SS.	UD6nUR                  n[        U[        5      (       a  [	        U* S5      OUnU R                  USS2USS24   5      nSnUb)  U R                  " SUX€R                  R                  S.UD6n[        UUUR                  UR                  UR                  UR                  S9$ )aµ  
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Labels for computing the left-to-right language modeling loss (next word prediction). 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]`

Example:

```python
>>> from transformers import AutoTokenizer, RobertaForCausalLM, AutoConfig
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("FacebookAI/roberta-base")
>>> config = AutoConfig.from_pretrained("FacebookAI/roberta-base")
>>> config.is_decoder = True
>>> model = RobertaForCausalLM.from_pretrained("FacebookAI/roberta-base", config=config)

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)

>>> prediction_logits = outputs.logits
```NFT)	r·   r4   r5   r6   r¸   r¹   r»   r¼   Úreturn_dict)Úlogitsrº   Ú
vocab_size)ÚlossrÂ   r»   r}   r~   r   rp   )r|   Úlast_hidden_stater‚   r]   Úslicer§   Úloss_functionr.   rÃ   r   r»   r}   r~   r   )r-   r3   r·   r4   r5   r6   r¸   r¹   rº   r»   r¼   r½   r¾   Úoutputsr}   Úslice_indicesrÂ   rÄ   s                     r0   rS   ÚRobertaForCausalLM.forwardÓ   sú   € ð` ÑØˆIà@DÇÂØðA
à)Ø)Ø%Ø'Ø"7Ø#9Ø+ØØñA
ð ñA
ˆð  ×1Ñ1ˆä8BÀ>ÔSV×8WÑ8Wœ˜~˜o¨tÔ4Ð]kˆØ—‘˜mªA¨}ºaÐ,?Ñ@ÓAˆàˆØÑØ×%Ò%Ðp¨V¸FÏ{É{×OeÑOeÑpÐioÑpˆDä0ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø$×5Ñ5ñ
ð 	
r2   ©r§   r|   )NNNNNNNNNNr   )rc   rd   re   rf   Ú_tied_weights_keysr%   r®   r´   r   r   rF   rg   rh   ÚtupleÚboolr]   ÚTensorr   r   r   rS   rj   rk   rl   s   @r0   rœ   rœ   ¶   s€  ø† ð #NØ .ñÐõ

ò$ò.ð Øð .2Ø37Ø26Ø04Ø26Ø:>Ø;?Ø*.ØBFØ!%Ø-.ñO
à×#Ñ# dÑ*ðO
ð ×)Ñ)¨DÑ0ðO
ð ×(Ñ(¨4Ñ/ð	O
ð
 ×&Ñ&¨Ñ-ðO
ð ×(Ñ(¨4Ñ/ðO
ð  %×0Ñ0°4Ñ7ðO
ð !&× 1Ñ 1°DÑ 8ðO
ð × Ñ  4Ñ'ðO
ð ˜u U×%6Ñ%6Ñ7Ñ8¸4Ñ?ðO
ð ˜$‘;ðO
ð ˜eŸl™lÑ*ðO
ð Ð+Ñ,ðO
ð 
ˆu�|‰|Ñ	Ð@Ñ	@ôO
ó ó öO
r2   rœ   c                   óŽ  ^ • \ rS rSrSSS.rU 4S jrS rS r\\	        SS	\
R                  S-  S
\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\
R                  S-  S\\   S\\
R                      \-  4S jj5       5       rSrU =r$ )ÚRobertaForMaskedLMi'  rž   rŸ   r    c                 óÎ   >• [         TU ]  U5        UR                  (       a  [        R	                  S5        [        USS9U l        [        U5      U l        U R                  5         g )NznIf you want to use `RobertaForMaskedLM` make sure `config.is_decoder=False` for bi-directional self-attention.Fr¢   r£   r,   s     €r0   r%   ÚRobertaForMaskedLM.__init__.  sR   ø€ Ü‰Ñ˜Ô à××Ü�N‰Nð1ôô
 $ F¸eÑDˆŒÜ$ VÓ,ˆŒð 	�‰Õr2   c                 ó.   • U R                   R                  $ r—   r«   r­   s    r0   r®   Ú(RobertaForMaskedLM.get_output_embeddings=  r°   r2   c                 ó$   • XR                   l        g r—   r«   r²   s     r0   r´   Ú(RobertaForMaskedLM.set_output_embeddings@  r¶   r2   Nr3   r·   r4   r5   r6   r¸   r¹   rº   r¾   r¿   c	                 óp  • U R                   " U4UUUUUUSS.U	D6n
U
S   nU R                  U5      nSnUba  UR                  UR                  5      n[	        5       nU" UR                  SU R                  R                  5      UR                  S5      5      n[        UUU
R                  U
R                  S9$ )a”  
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
labels (`torch.LongTensor` 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]`
T)r·   r4   r5   r6   r¸   r¹   rÁ   r   Nr9   ©rÄ   rÂ   r}   r~   )r|   r§   rC   r>   r   Úviewr.   rÃ   r   r}   r~   )r-   r3   r·   r4   r5   r6   r¸   r¹   rº   r¾   rÈ   Úsequence_outputÚprediction_scoresÚmasked_lm_lossÚloss_fcts                  r0   rS   ÚRobertaForMaskedLM.forwardC  sÑ   € ð: —,’,Øð

à)Ø)Ø%Ø'Ø"7Ø#9Øñ

ð ñ

ˆð " !™*ˆØ ŸL™L¨Ó9ÐàˆØÑà—Y‘YÐ0×7Ñ7Ó8ˆFÜ'Ó)ˆHÙ%Ð&7×&<Ñ&<¸RÀÇÁ×AWÑAWÓ&XÐZ`×ZeÑZeÐfhÓZiÓjˆNäØØ$Ø!×/Ñ/Ø×)Ñ)ñ	
ð 	
r2   rË   )NNNNNNNN)rc   rd   re   rf   rÌ   r%   r®   r´   r   r   rF   rg   rh   r   r   rÍ   rÏ   r   rS   rj   rk   rl   s   @r0   rÑ   rÑ   '  s'  ø† ð #NØ .ñÐõ
ò$ò.ð Øð .2Ø37Ø26Ø04Ø26Ø:>Ø;?Ø*.ñ5
à×#Ñ# dÑ*ð5
ð ×)Ñ)¨DÑ0ð5
ð ×(Ñ(¨4Ñ/ð	5
ð
 ×&Ñ&¨Ñ-ð5
ð ×(Ñ(¨4Ñ/ð5
ð  %×0Ñ0°4Ñ7ð5
ð !&× 1Ñ 1°DÑ 8ð5
ð × Ñ  4Ñ'ð5
ð Ð+Ñ,ð5
ð 
ˆu�|‰|Ñ	˜~Ñ	-ô5
ó ó ö5
r2   rÑ   c                   ó2   ^ • \ rS rSrSrU 4S jrS rSrU =r$ )rƒ   i}  z*Roberta Head for masked language modeling.c                 ó°  >• [         TU ]  5         [        R                  " UR                  UR                  5      U l        [        R                  " UR                  UR                  S9U l        [        R                  " UR                  UR                  5      U l
        [        R                  " [        R                  " UR                  5      5      U l        g )N)Úeps)r$   r%   r(   ÚLinearr+   ÚdenserL   Úlayer_norm_epsÚ
layer_normrÃ   r¬   Ú	ParameterrF   rH   r†   r,   s     €r0   r%   ÚRobertaLMHead.__init__€  s‡   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
ÜŸ,š, v×'9Ñ'9¸v×?TÑ?TÑUˆŒä—y’y ×!3Ñ!3°V×5FÑ5FÓGˆŒÜ—L’L¤§¢¨V×->Ñ->Ó!?Ó@ˆ�	r2   c                 ó‚   • U R                  U5      n[        U5      nU R                  U5      nU R                  U5      nU$ r—   )rä   r   ræ   r¬   ©r-   Úfeaturesr¾   Úxs       r0   rS   ÚRobertaLMHead.forwardˆ  s;   € Ø�J‰J�xÓ ˆÜ�‹GˆØ�O‰O˜AÓˆð �L‰L˜‹Oˆàˆr2   )r†   r¬   rä   ræ   ©	rc   rd   re   rf   Ú__doc__r%   rS   rj   rk   rl   s   @r0   rƒ   rƒ   }  s   ø† Ù4õA÷ð r2   rƒ   zŸ
    RoBERTa Model transformer with a sequence classification/regression head on top (a linear layer on top of the
    pooled output) e.g. for GLUE tasks.
    c                   ó8  ^ • \ rS rSrU 4S jr\\      SS\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S	\R                  S-  S
\
\   S\\R                     \-  4S jj5       5       rSrU =r$ )Ú RobertaForSequenceClassificationi“  c                 ó°   >• [         TU ]  U5        UR                  U l        Xl        [	        USS9U l        [        U5      U l        U R                  5         g ©NFr¢   )	r$   r%   Ú
num_labelsr.   r”   r|   ÚRobertaClassificationHeadÚ
classifierr¨   r,   s     €r0   r%   Ú)RobertaForSequenceClassification.__init__š  sH   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒØŒä# F¸eÑDˆŒÜ3°FÓ;ˆŒð 	�‰Õr2   Nr3   r·   r4   r5   r6   rº   r¾   r¿   c           	      óþ  • U R                   " U4UUUUSS.UD6nUS   n	U R                  U	5      n
SnUGb©  UR                  U
R                  5      nU R                  R
                  c‘  U R                  S:X  a  SU R                  l        OoU R                  S:”  aN  UR                  [        R                  :X  d  UR                  [        R                  :X  a  SU R                  l        OSU R                  l        U R                  R
                  S:X  aI  [        5       nU R                  S:X  a&  U" U
R                  5       UR                  5       5      nOŒU" X¦5      nOƒU R                  R
                  S:X  a=  [        5       nU" U
R                  S	U R                  5      UR                  S	5      5      nO,U R                  R
                  S:X  a  [        5       nU" X¦5      n[!        UU
UR"                  UR$                  S
9$ )a  
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
labels (`torch.LongTensor` 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).
T©r·   r4   r5   r6   rÁ   r   Nr   Ú
regressionÚsingle_label_classificationÚmulti_label_classificationr9   rÙ   )r|   rö   rC   r>   r.   Úproblem_typerô   r=   rF   rI   r]   r   Úsqueezer   rÚ   r   r   r}   r~   ©r-   r3   r·   r4   r5   r6   rº   r¾   rÈ   rÛ   rÂ   rÄ   rÞ   s                r0   rS   Ú(RobertaForSequenceClassification.forward¥  s§  € ð6 —,’,Øð
à)Ø)Ø%Ø'Øñ
ð ñ
ˆð " !™*ˆØ—‘ Ó1ˆàˆØÒà—Y‘Y˜vŸ}™}Ó-ˆFØ�{‰{×'Ñ'Ñ/Ø—?‘? aÓ'Ø/;�D—K‘KÕ,Ø—_‘_ qÓ(¨f¯l©l¼e¿j¹jÓ.HÈFÏLÉLÔ\a×\eÑ\eÓLeØ/L�D—K‘KÕ,à/K�D—K‘KÔ,à�{‰{×'Ñ'¨<Ó7Ü"›9�Ø—?‘? aÓ'Ù# F§N¡NÓ$4°f·n±nÓ6FÓG‘Dá# FÓ3‘DØ—‘×)Ñ)Ð-JÓJÜ+Ó-�Ù §¡¨B°·±Ó @À&Ç+Á+ÈbÃ/ÓR‘Ø—‘×)Ñ)Ð-IÓIÜ,Ó.�Ù Ó/�ä'ØØØ!×/Ñ/Ø×)Ñ)ñ	
ð 	
r2   )rö   r.   rô   r|   ©NNNNNN)rc   rd   re   rf   r%   r   r   rF   rg   rh   r   r   rÍ   rÏ   r   rS   rj   rk   rl   s   @r0   rñ   rñ   “  sç   ø† õ	ð Øð .2Ø37Ø26Ø04Ø26Ø*.ñC
à×#Ñ# dÑ*ðC
ð ×)Ñ)¨DÑ0ðC
ð ×(Ñ(¨4Ñ/ð	C
ð
 ×&Ñ&¨Ñ-ðC
ð ×(Ñ(¨4Ñ/ðC
ð × Ñ  4Ñ'ðC
ð Ð+Ñ,ðC
ð 
ˆu�|‰|Ñ	Ð7Ñ	7ôC
ó ó öC
r2   rñ   c                   ó8  ^ • \ rS rSrU 4S jr\\      SS\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S	\R                  S-  S
\
\   S\\R                     \-  4S jj5       5       rSrU =r$ )ÚRobertaForMultipleChoiceií  c                 óú   >• [         TU ]  U5        [        U5      U l        [        R
                  " UR                  5      U l        [        R                  " UR                  S5      U l
        U R                  5         g )Nr   )r$   r%   r”   r|   r(   ÚDropoutÚhidden_dropout_probrM   rã   r+   rö   r¨   r,   s     €r0   r%   Ú!RobertaForMultipleChoice.__init__ï  sV   ø€ Ü‰Ñ˜Ô ä# FÓ+ˆŒÜ—z’z &×"<Ñ"<Ó=ˆŒÜŸ)š) F×$6Ñ$6¸Ó:ˆŒð 	�‰Õr2   Nr3   r4   r·   rº   r5   r6   r¾   r¿   c           	      ó*  • Ub  UR                   S   OUR                   S   nUb!  UR                  SUR                  S5      5      OSn	Ub!  UR                  SUR                  S5      5      OSn
Ub!  UR                  SUR                  S5      5      OSnUb!  UR                  SUR                  S5      5      OSnUb1  UR                  SUR                  S5      UR                  S5      5      OSnU R                  " U	4U
UUUSS.UD6nUS   nU R	                  U5      nU R                  U5      nUR                  SU5      nSnUb.  UR                  UR                  5      n[        5       nU" UU5      n[        UUUR                  UR                  S9$ )aO  
input_ids (`torch.LongTensor` of shape `(batch_size, num_choices, sequence_length)`):
    Indices of input sequence tokens in the vocabulary.

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

    [What are input IDs?](../glossary#input-ids)
token_type_ids (`torch.LongTensor` of shape `(batch_size, num_choices, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels for computing the multiple choice classification loss. Indices should be in `[0, ...,
    num_choices-1]` where `num_choices` is the size of the second dimension of the input tensors. (See
    `input_ids` above)
position_ids (`torch.LongTensor` of shape `(batch_size, num_choices, sequence_length)`, *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)
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, num_choices, sequence_length, hidden_size)`, *optional*):
    Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
    is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
    model's internal embedding lookup matrix.
Nr   r9   éþÿÿÿT)r5   r4   r·   r6   rÁ   rÙ   )rE   rÚ   rA   r|   rM   rö   rC   r>   r   r   r}   r~   )r-   r3   r4   r·   rº   r5   r6   r¾   Únum_choicesÚflat_input_idsÚflat_position_idsÚflat_token_type_idsÚflat_attention_maskÚflat_inputs_embedsrÈ   Úpooled_outputrÂ   Úreshaped_logitsrÄ   rÞ   s                       r0   rS   Ú RobertaForMultipleChoice.forwardù  s³  € ðV -6Ñ,A�i—o‘o aÒ(À}×GZÑGZÐ[\ÑG]ˆàCLÑCX˜Ÿ™¨¨I¯N©N¸2Ó,>Ô?Ð^bˆØLXÑLd˜L×-Ñ-¨b°,×2CÑ2CÀBÓ2GÔHÐjnÐØR`ÑRl˜n×1Ñ1°"°n×6IÑ6IÈ"Ó6MÔNÐrvÐØR`ÑRl˜n×1Ñ1°"°n×6IÑ6IÈ"Ó6MÔNÐrvÐð Ñ(ð ×Ñ˜r =×#5Ñ#5°bÓ#9¸=×;MÑ;MÈbÓ;QÔRàð 	ð —,’,Øð
à*Ø.Ø.Ø,Øñ
ð ñ
ˆð   ™
ˆàŸ™ ]Ó3ˆØ—‘ Ó/ˆØ Ÿ+™+ b¨+Ó6ˆàˆØÑà—Y‘Y˜×5Ñ5Ó6ˆFÜ'Ó)ˆHÙ˜O¨VÓ4ˆDä(ØØ"Ø!×/Ñ/Ø×)Ñ)ñ	
ð 	
r2   )rö   rM   r|   r  )rc   rd   re   rf   r%   r   r   rF   rg   rh   r   r   rÍ   rÏ   r   rS   rj   rk   rl   s   @r0   r  r  í  sç   ø† õð Øð .2Ø26Ø37Ø*.Ø04Ø26ñP
à×#Ñ# dÑ*ðP
ð ×(Ñ(¨4Ñ/ðP
ð ×)Ñ)¨DÑ0ð	P
ð
 × Ñ  4Ñ'ðP
ð ×&Ñ&¨Ñ-ðP
ð ×(Ñ(¨4Ñ/ðP
ð Ð+Ñ,ðP
ð 
ˆu�|‰|Ñ	Ð8Ñ	8ôP
ó ó öP
r2   r  c                   ó8  ^ • \ rS rSrU 4S jr\\      SS\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S	\R                  S-  S
\
\   S\\R                     \-  4S jj5       5       rSrU =r$ )ÚRobertaForTokenClassificationiN  c                 ód  >• [         TU ]  U5        UR                  U l        [        USS9U l        UR
                  b  UR
                  OUR                  n[        R                  " U5      U l	        [        R                  " UR                  UR                  5      U l        U R                  5         g ró   )r$   r%   rô   r”   r|   Úclassifier_dropoutr  r(   r  rM   rã   r+   rö   r¨   ©r-   r.   r  r/   s      €r0   r%   Ú&RobertaForTokenClassification.__init__P  sŠ   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒä# F¸eÑDˆŒà)/×)BÑ)BÑ)NˆF×%Ò%ÐTZ×TnÑTnð 	ô —z’zÐ"4Ó5ˆŒÜŸ)š) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Õr2   Nr3   r·   r4   r5   r6   rº   r¾   r¿   c           	      óz  • U R                   " U4UUUUSS.UD6nUS   n	U R                  U	5      n	U R                  U	5      n
SnUbW  UR                  U
R                  5      n[        5       nU" U
R                  SU R                  5      UR                  S5      5      n[        UU
UR                  UR                  S9$ )aÝ  
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
Trù   r   Nr9   rÙ   )r|   rM   rö   rC   r>   r   rÚ   rô   r   r}   r~   rÿ   s                r0   rS   Ú%RobertaForTokenClassification.forward^  sÇ   € ð2 —,’,Øð
à)Ø)Ø%Ø'Øñ
ð ñ
ˆð " !™*ˆàŸ,™, Ó7ˆØ—‘ Ó1ˆàˆØÑà—Y‘Y˜vŸ}™}Ó-ˆFÜ'Ó)ˆHÙ˜FŸK™K¨¨D¯O©OÓ<¸f¿k¹kÈ"»oÓNˆDä$ØØØ!×/Ñ/Ø×)Ñ)ñ	
ð 	
r2   )rö   rM   rô   r|   r  )rc   rd   re   rf   r%   r   r   rF   rg   rh   r   r   rÍ   rÏ   r   rS   rj   rk   rl   s   @r0   r  r  N  sÝ   ø† õð Øð .2Ø37Ø26Ø04Ø26Ø*.ñ2
à×#Ñ# dÑ*ð2
ð ×)Ñ)¨DÑ0ð2
ð ×(Ñ(¨4Ñ/ð	2
ð
 ×&Ñ&¨Ñ-ð2
ð ×(Ñ(¨4Ñ/ð2
ð × Ñ  4Ñ'ð2
ð Ð+Ñ,ð2
ð 
ˆu�|‰|Ñ	Ð4Ñ	4ô2
ó ó ö2
r2   r  c                   ó2   ^ • \ rS rSrSrU 4S jrS rSrU =r$ )rõ   i•  z-Head for sentence-level classification tasks.c                 ób  >• [         TU ]  5         [        R                  " UR                  UR                  5      U l        UR                  b  UR                  OUR                  n[        R                  " U5      U l	        [        R                  " UR                  UR                  5      U l        g r—   )r$   r%   r(   rã   r+   rä   r  r  r  rM   rô   Úout_projr  s      €r0   r%   Ú"RobertaClassificationHead.__init__˜  s   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
à)/×)BÑ)BÑ)NˆF×%Ò%ÐTZ×TnÑTnð 	ô —z’zÐ"4Ó5ˆŒÜŸ	š	 &×"4Ñ"4°f×6GÑ6GÓHˆ�r2   c                 óÒ   • US S 2SS S 24   nU R                  U5      nU R                  U5      n[        R                  " U5      nU R                  U5      nU R	                  U5      nU$ )Nr   )rM   rä   rF   Útanhr  rê   s       r0   rS   Ú!RobertaClassificationHead.forward¡  sY   € Ø’Q˜š1�WÑˆØ�L‰L˜‹OˆØ�J‰J�q‹MˆÜ�JŠJ�q‹MˆØ�L‰L˜‹OˆØ�M‰M˜!ÓˆØˆr2   )rä   rM   r  rî   rl   s   @r0   rõ   rõ   •  s   ø† Ù7õI÷ð r2   rõ   c                   óX  ^ • \ rS rSrU 4S jr\\       SS\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S\R                  S-  S	\R                  S-  S
\R                  S-  S\
\   S\\R                     \-  4S jj5       5       rSrU =r$ )ÚRobertaForQuestionAnsweringi«  c                 óä   >• [         TU ]  U5        UR                  U l        [        USS9U l        [
        R                  " UR                  UR                  5      U l        U R                  5         g ró   )
r$   r%   rô   r”   r|   r(   rã   r+   Ú
qa_outputsr¨   r,   s     €r0   r%   Ú$RobertaForQuestionAnswering.__init__­  sU   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒä# F¸eÑDˆŒÜŸ)š) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Õr2   Nr3   r·   r4   r5   r6   Ústart_positionsÚend_positionsr¾   r¿   c           	      ó¶  • U R                   " U4UUUUSS.UD6n	U	S   n
U R                  U
5      nUR                  SSS9u  pÍUR                  S5      R	                  5       nUR                  S5      R	                  5       nSnUbµ  Ub²  [        UR                  5       5      S:”  a  UR                  S5      n[        UR                  5       5      S:”  a  UR                  S5      nUR                  S5      nUR                  SU5      nUR                  SU5      n[        US9nU" XÆ5      nU" X×5      nUU-   S	-  n[        UUUU	R                  U	R                  S
9$ )a  
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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.
    This parameter can only be used when the model is initialized with `type_vocab_size` parameter with value
    >= 2. All the value in this tensor should be always < type_vocab_size.

    [What are token type IDs?](../glossary#token-type-ids)
Trù   r   r   r9   r[   N)Úignore_indexr   )rÄ   Ústart_logitsÚ
end_logitsr}   r~   )r|   r%  Úsplitrþ   Ú
contiguousÚlenrA   Úclampr   r   r}   r~   )r-   r3   r·   r4   r5   r6   r'  r(  r¾   rÈ   rÛ   rÂ   r+  r,  Ú
total_lossÚignored_indexrÞ   Ú
start_lossÚend_losss                      r0   rS   Ú#RobertaForQuestionAnswering.forward·  sx  € ð0 —,’,Øð
à)Ø)Ø%Ø'Øñ
ð ñ
ˆð " !™*ˆà—‘ Ó1ˆØ#)§<¡<°°r <Ð#:Ñ ˆØ#×+Ñ+¨BÓ/×:Ñ:Ó<ˆØ×'Ñ'¨Ó+×6Ñ6Ó8ˆ
àˆ
ØÑ&¨=Ñ+Dä�?×'Ñ'Ó)Ó*¨QÓ.Ø"1×"9Ñ"9¸"Ó"=�Ü�=×%Ñ%Ó'Ó(¨1Ó,Ø -× 5Ñ 5°bÓ 9�à(×-Ñ-¨aÓ0ˆMØ-×3Ñ3°A°}ÓEˆOØ)×/Ñ/°°=ÓAˆMä'°]ÑCˆHÙ! ,Ó@ˆJÙ 
Ó:ˆHØ$ xÑ/°1Ñ4ˆJä+ØØ%Ø!Ø!×/Ñ/Ø×)Ñ)ñ
ð 	
r2   )rô   r%  r|   )NNNNNNN)rc   rd   re   rf   r%   r   r   rF   rg   rh   r   r   rÍ   rÏ   r   rS   rj   rk   rl   s   @r0   r#  r#  «  sõ   ø† õð Øð .2Ø37Ø26Ø04Ø26Ø37Ø15ñ>
à×#Ñ# dÑ*ð>
ð ×)Ñ)¨DÑ0ð>
ð ×(Ñ(¨4Ñ/ð	>
ð
 ×&Ñ&¨Ñ-ð>
ð ×(Ñ(¨4Ñ/ð>
ð ×)Ñ)¨DÑ0ð>
ð ×'Ñ'¨$Ñ.ð>
ð Ð+Ñ,ð>
ð 
ˆu�|‰|Ñ	Ð;Ñ	;ô>
ó ó ö>
r2   r#  )rœ   rÑ   r  r#  rñ   r  r”   rz   );rï   rF   Útorch.nnr(   r   r   r   Ú r   r„   Úactivationsr   Ú
generationr	   Úmodeling_outputsr
   r   r   r   r   r   r   Úmodeling_utilsr   Úprocessing_utilsr   Úutilsr   r   r   Úutils.genericr   Úbert.modeling_bertr   r   r   r   r   Úconfiguration_robertar   Ú
get_loggerrc   r¥   r    rn   rt   rw   rz   r”   rœ   rÑ   ÚModulerƒ   rñ   r  r  rõ   r#  Ú__all__rp   r2   r0   Ú<module>rD     s³  ðñ ã Ý ß AÑ Aå &Ý Ý )÷÷ ñ õ .Ý &ß @Ñ @Ý -ß lÕ lÝ 0ð 
×	Ò	˜HÓ	%€ô\8˜ô \8ô~	Ð,ô 	ô	Ð.ô 	ô	�9ô 	ð ô/˜_ó /ó ð/ô2'�9ô 'ñ
 ðñô
i
Ð/°ó i
óð
i
ðX ôR
Ð/ó R
ó ðR
ôj�B—I‘Iô ñ, ðñôQ
Ð'=ó Q
óðQ
ðh ô]
Ð5ó ]
ó ð]
ð@ ôC
Ð$:ó C
ó ðC
ôL §	¡	ô ð, ôK
Ð"8ó K
ó ðK
ò\	�r2   