§
    ‚Štjà›  ã                   óþ  — 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
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZ ddlm Z m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0  e)j1        e2¦  «        Z3de4de4dej5        fd„Z6de4de4dej5        fd„Z7 G d„ dej8        ¦  «        Z9	 	 dAdej8        dej5        d ej5        d!ej5        d"ej5        dz  d#e:dz  d$e:d%e#e'         fd&„Z; G d'„ d(ej8        ¦  «        Z< G d)„ d*ej8        ¦  «        Z= G d+„ d,e¦  «        Z> G d-„ d.ej8        ¦  «        Z?e( G d/„ d0e!¦  «        ¦   «         Z@e( G d1„ d2e@¦  «        ¦   «         ZA e(d3¬4¦  «         G d5„ d6e@¦  «        ¦   «         ZB e(d7¬4¦  «         G d8„ d9e@¦  «        ¦   «         ZCe( G d:„ d;e@¦  «        ¦   «         ZDe( G d<„ d=e@¦  «        ¦   «         ZEe( G d>„ d?e@¦  «        ¦   «         ZFg d@¢ZGdS )Bzà
PyTorch DistilBERT model adapted in part from Facebook, Inc XLM model (https://github.com/facebookresearch/XLM) and in
part from HuggingFace PyTorch version of Google AI Bert model (https://github.com/google-research/bert)
é    )ÚCallableN)Únn)ÚBCEWithLogitsLossÚCrossEntropyLossÚMSELossé   )Úinitialization)Úget_activation)ÚPreTrainedConfig)Úis_deepspeed_zero3_enabled)Úcreate_bidirectional_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚMaskedLMOutputÚMultipleChoiceModelOutputÚQuestionAnsweringModelOutputÚSequenceClassifierOutputÚTokenClassifierOutput)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)Úapply_chunking_to_forward)ÚTransformersKwargsÚauto_docstringÚlogging)Úcan_return_tupleÚmerge_with_config_defaults)Úcapture_outputsé   )ÚDistilBertConfigÚn_posÚdimÚoutc                 ó:  — t          ¦   «         r|dd l}|j                             |d¬¦  «        5  t          j                             ¦   «         dk    rt          | ||¬¦  «        cd d d ¦  «         S 	 d d d ¦  «         d S # 1 swxY w Y   d S t          | ||¬¦  «        S )Nr   )Úmodifier_rank©r!   r"   r#   )r   Ú	deepspeedÚzeroÚGatheredParametersÚtorchÚdistributedÚget_rankÚ_create_sinusoidal_embeddings)r!   r"   r#   r'   s       úp/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/distilbert/modeling_distilbert.pyÚcreate_sinusoidal_embeddingsr/   >   s&  € Ý!Ñ#Ô#ð LØÐÐÐàŒ^×.Ò.¨sÀ!Ð.ÑDÔDð 	Tð 	TÝÔ ×)Ò)Ñ+Ô+¨qÒ0Ð0Ý4¸5ÀcÈsÐSÑSÔSð	Tð 	Tð 	Tð 	Tñ 	Tô 	Tð 	Tð 	TØ0ð	Tð 	Tð 	Tñ 	Tô 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tøøøð 	Tð 	Tð 	Tð 	Tð 	Tð 	Tõ -°5¸cÀsÐKÑKÔKÐKs   ¯4A>Á>BÂBc           	      óŒ  ‡— t          j        ˆfd„t          | ¦  «        D ¦   «         ¦  «        }d|_        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<   |                     ¦   «          |S )Nc                 óJ   •‡— g | ]Šˆˆfd „t          ‰¦  «        D ¦   «         ‘ŒS )c           	      óR   •— g | ]#}‰t          j        d d|dz  z  ‰z  ¦  «        z  ‘Œ$S )i'  é   )ÚnpÚpower)Ú.0Újr"   Úposs     €€r.   ú
<listcomp>z<_create_sinusoidal_embeddings.<locals>.<listcomp>.<listcomp>J   s7   ø€ Ð\Ð\Ð\ÈA˜c¥B¤H¨U°A¸¸a¹±LÀ3Ñ4FÑ$GÔ$GÑGÐ\Ð\Ð\ó    )Úrange)r6   r8   r"   s    @€r.   r9   z1_create_sinusoidal_embeddings.<locals>.<listcomp>J   s=   øø€ ÐuÐuÐuÐadÐ\Ð\Ð\Ð\Ð\ÕQVÐWZÑQ[ÔQ[Ð\Ñ\Ô\ÐuÐuÐur:   Fr   r3   r   )	r4   Úarrayr;   Úrequires_gradr*   ÚFloatTensorÚsinÚcosÚdetach_)r!   r"   r#   Úposition_encs    `  r.   r-   r-   I   sÉ   ø€ Ý”8ÐuÐuÐuÐuÕhmÐnsÑhtÔhtÐuÑuÔuÑvÔv€LØ€CÔÝÔ$¥R¤V¨L¸¸¸¸A¸D¸q¸D¸Ô,AÑ%BÔ%BÑCÔC€Cˆˆˆˆ1ˆ4ˆaˆ4ˆ�LÝÔ$¥R¤V¨L¸¸¸¸A¸D¸q¸D¸Ô,AÑ%BÔ%BÑCÔC€Cˆˆˆˆ1ˆ4ˆaˆ4ˆ�LØ‡K‚K�M„M€MØ€Jr:   c            	       óv   ‡ — e Zd Zdefˆ fd„Z	 	 d	dej        dej        dz  dej        dz  dej        fd„Zˆ xZ	S )
Ú
EmbeddingsÚconfigc                 óæ  •— t          ¦   «                              ¦   «          t          j        |j        |j        |j        ¬¦  «        | _        t          j        |j        |j        ¦  «        | _	        t          j
        |j        d¬¦  «        | _
        t          j        |j        ¦  «        | _        |                      dt          j        |j        ¦  «                             d¦  «        d¬¦  «         d S )N)Úpadding_idxçê-�™—q=©ÚepsÚposition_ids©r   éÿÿÿÿF)Ú
persistent)ÚsuperÚ__init__r   Ú	EmbeddingÚ
vocab_sizer"   Úpad_token_idÚword_embeddingsÚmax_position_embeddingsÚposition_embeddingsÚ	LayerNormÚDropoutÚdropoutÚregister_bufferr*   ÚarangeÚexpand©ÚselfrE   Ú	__class__s     €r.   rP   zEmbeddings.__init__S   sÌ   ø€ Ý‰Œ×ÒÑÔÐÝ!œ|¨FÔ,=¸v¼zÐW]ÔWjÐkÑkÔkˆÔÝ#%¤<°Ô0NÐPVÔPZÑ#[Ô#[ˆÔ åœ f¤j°eÐ<Ñ<Ô<ˆŒÝ”z &¤.Ñ1Ô1ˆŒØ×ÒØ�EœL¨Ô)GÑHÔH×OÒOÐPWÑXÔXÐejð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r:   NÚ	input_idsÚinputs_embedsrK   Úreturnc                 óÎ  — |�|                       |¦  «        }|                     d¦  «        }|€rt          | d¦  «        r| j        d d …d |…f         }nNt	          j        |t          j        |j        ¬¦  «        }|                     d¦  «         	                    |¦  «        }|  
                    |¦  «        }||z   }|                      |¦  «        }|                      |¦  «        }|S )Nr   rK   )ÚdtypeÚdevicer   )rT   ÚsizeÚhasattrrK   r*   r[   Úlongre   Ú	unsqueezeÚ	expand_asrV   rW   rY   )r^   r`   ra   rK   Ú
seq_lengthrV   Ú
embeddingss          r.   ÚforwardzEmbeddings.forward^   sê   € ð Ð Ø ×0Ò0°Ñ;Ô;ˆMà"×'Ò'¨Ñ*Ô*ˆ
àÐõ �t˜^Ñ,Ô,ð NØ#Ô0°°°°K°Z°K°Ô@��å$œ|¨J½e¼jÐQZÔQaÐbÑbÔb�Ø+×5Ò5°aÑ8Ô8×BÒBÀ9ÑMÔM�à"×6Ò6°|ÑDÔDÐà"Ð%8Ñ8ˆ
Ø—^’^ JÑ/Ô/ˆ
Ø—\’\ *Ñ-Ô-ˆ
ØÐr:   )NN)
Ú__name__Ú
__module__Ú__qualname__r   rP   r*   ÚTensorÚ
LongTensorrm   Ú__classcell__©r_   s   @r.   rD   rD   R   sŸ   ø€ € € € € ð	
Ð/ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð .2Ø04ð	ð à”<ðð ”| dÑ*ðð Ô&¨Ñ-ð	ð
 
Œðð ð ð ð ð ð ð r:   rD   ç        ÚmoduleÚqueryÚkeyÚvalueÚattention_maskÚscalingrY   Úkwargsc                 ó®  — |€|                      d¦  «        dz  }t          j        ||                     dd¦  «        ¦  «        |z  }|�||z   }t          j                             |d¬¦  «        }t          j                             ||| j        ¬¦  «        }t          j        ||¦  «        }	|	                     dd¦  «         	                    ¦   «         }	|	|fS )NrM   ç      à¿r3   r   ©r"   )ÚpÚtrainingr   )
rf   r*   ÚmatmulÚ	transposer   Ú
functionalÚsoftmaxrY   r�   Ú
contiguous)
rv   rw   rx   ry   rz   r{   rY   r|   Úattn_weightsÚattn_outputs
             r.   Úeager_attention_forwardr‰   |   sÈ   € ð €Ø—*’*˜R‘.”. DÑ(ˆõ ”<  s§}¢}°Q¸Ñ':Ô':Ñ;Ô;¸gÑE€LàÐ!Ø# nÑ4ˆå”=×(Ò(¨¸2Ð(Ñ>Ô>€LÝ”=×(Ò(¨¸È6Ì?Ð(Ñ[Ô[€Lå”,˜|¨UÑ3Ô3€KØ×'Ò'¨¨1Ñ-Ô-×8Ò8Ñ:Ô:€Kà˜Ð$Ð$r:   c            
       ó|   ‡ — e Zd Zdefˆ fd„Z	 d	dej        dej        dz  dee	         de
ej                 fd„Zˆ xZS )
ÚDistilBertSelfAttentionrE   c                 ó¦  •— t          ¦   «                              ¦   «          || _        |j        | _        |j        | _        | j        | j        z  | _        | j        dz  | _        | j        | j        z  dk    r t          d| j        › d| j        › d�¦  «        ‚t          j	        |j        |j        ¬¦  «        | _
        t          j	        |j        |j        ¬¦  «        | _        t          j	        |j        |j        ¬¦  «        | _        t          j	        |j        |j        ¬¦  «        | _        t          j        |j        ¬¦  «        | _        d| _        d S )	Nr~   r   zself.n_heads: z must divide self.dim: ú evenly©Úin_featuresÚout_features©r€   F)rO   rP   rE   Ún_headsr"   Úattention_head_sizer{   Ú
ValueErrorr   ÚLinearÚq_linÚk_linÚv_linÚout_linrX   Úattention_dropoutrY   Ú	is_causalr]   s     €r.   rP   z DistilBertSelfAttention.__init__™   s  ø€ Ý‰Œ×ÒÑÔÐØˆŒà”~ˆŒØ”:ˆŒØ#'¤8¨t¬|Ñ#;ˆÔ ØÔ/°Ñ5ˆŒð Œ8�d”lÑ" aÒ'Ð'åÐd¨d¬lÐdÐdÐSWÔS[ÐdÐdÐdÑeÔeÐeå”Y¨6¬:ÀFÄJÐOÑOÔOˆŒ
Ý”Y¨6¬:ÀFÄJÐOÑOÔOˆŒ
Ý”Y¨6¬:ÀFÄJÐOÑOÔOˆŒ
Ý”y¨V¬ZÀfÄjÐQÑQÔQˆŒå”z FÔ$<Ð=Ñ=Ô=ˆŒØˆŒˆˆr:   NÚhidden_statesrz   r|   rb   c                 ót  — |j         d d…         }g |¢d‘| j        ‘R } |                      |¦  «        j        |Ž                      dd¦  «        } |                      |¦  «        j        |Ž                      dd¦  «        } |                      |¦  «        j        |Ž                      dd¦  «        }t          j        | j	        j
        t          ¦  «        }	 |	| ||||f| j        sdn| j        j        | j        dœ|¤Ž\  }
} |
j        g |¢d‘R Ž                      ¦   «         }
|                      |
¦  «        }
|
|fS )NrM   r   r3   ru   )rY   r{   )Úshaper“   r–   Úviewrƒ   r—   r˜   r   Úget_interfacerE   Ú_attn_implementationr‰   r�   rY   r€   r{   Úreshaper†   r™   )r^   rœ   rz   r|   Úinput_shapeÚhidden_shapeÚquery_layerÚ	key_layerÚvalue_layerÚattention_interfacerˆ   r‡   s               r.   rm   zDistilBertSelfAttention.forward¯   sn  € ð $Ô)¨#¨2¨#Ô.ˆØC˜ÐC bÐC¨$Ô*BÐCÐCˆð 5�d—j’j Ñ/Ô/Ô4°lÐC×MÒMÈaÐQRÑSÔSˆØ2�D—J’J˜}Ñ-Ô-Ô2°LÐA×KÒKÈAÈqÑQÔQˆ	Ø4�d—j’j Ñ/Ô/Ô4°lÐC×MÒMÈaÐQRÑSÔSˆå(?Ô(MØŒKÔ,Õ.Eñ)
ô )
Ðð %8Ð$7ØØØØØð	%
ð  $œ}Ð@�C�C°$´,´.Ø”Lð	%
ð 	%
ð ð	%
ð 	%
Ñ!ˆ�\ð *�kÔ)Ð;¨;Ð;¸Ð;Ð;Ð;×FÒFÑHÔHˆØ—l’l ;Ñ/Ô/ˆØ˜LÐ(Ð(r:   ©N)rn   ro   rp   r   rP   r*   rq   r>   r   r   Útuplerm   rs   rt   s   @r.   r‹   r‹   ˜   s    ø€ € € € € ðÐ/ð ð ð ð ð ð ð2 48ð)ð )à”|ð)ð Ô)¨DÑ0ð)ð Ð+Ô,ð	)ð
 
ˆuŒ|Ô	ð)ð )ð )ð )ð )ð )ð )ð )r:   r‹   c                   ól   ‡ — e Zd Zdefˆ fd„Zdej        dej        fd„Zdej        dej        fd„Zˆ xZ	S )ÚFFNrE   c                 ór  •— t          ¦   «                              ¦   «          t          j        |j        ¬¦  «        | _        |j        | _        d| _        t          j        |j        |j	        ¬¦  «        | _
        t          j        |j	        |j        ¬¦  «        | _        t          |j        ¦  «        | _        d S )Nr‘   r   rŽ   )rO   rP   r   rX   rY   Úchunk_size_feed_forwardÚseq_len_dimr•   r"   Ú
hidden_dimÚlin1Úlin2r
   Ú
activationr]   s     €r.   rP   zFFN.__init__Ñ   sŽ   ø€ Ý‰Œ×ÒÑÔÐÝ”z F¤NÐ3Ñ3Ô3ˆŒØ'-Ô'EˆÔ$ØˆÔÝ”I¨&¬*À6ÔCTÐUÑUÔUˆŒ	Ý”I¨&Ô*;È&Ì*ÐUÑUÔUˆŒ	Ý(¨Ô):Ñ;Ô;ˆŒˆˆr:   Úinputrb   c                 óD   — t          | j        | j        | j        |¦  «        S r©   )r   Úff_chunkr®   r¯   )r^   r´   s     r.   rm   zFFN.forwardÚ   s    € Ý(¨¬¸Ô8TÐVZÔVfÐhmÑnÔnÐnr:   c                 ó®   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|                      |¦  «        }|S r©   )r±   r³   r²   rY   )r^   r´   Úxs      r.   r¶   zFFN.ff_chunkÝ   sG   € Ø�IŠI�eÑÔˆØ�OŠO˜AÑÔˆØ�IŠI�a‰LŒLˆØ�LŠL˜‰OŒOˆØˆr:   )
rn   ro   rp   r   rP   r*   rq   rm   r¶   rs   rt   s   @r.   r¬   r¬   Ð   s—   ø€ € € € € ð<Ð/ð <ð <ð <ð <ð <ð <ðo˜Uœ\ð o¨e¬lð oð oð oð oð˜eœlð ¨u¬|ð ð ð ð ð ð ð ð r:   r¬   c                   ó€   ‡ — e Zd Zdefˆ fd„Z	 d
dej        dej        dz  dee         de	ej        df         fd	„Z
ˆ xZS )ÚTransformerBlockrE   c                 ó~  •— t          ¦   «                              ¦   «          |j        |j        z  dk    r t	          d|j        › d|j        › d�¦  «        ‚t          |¦  «        | _        t          j        |j        d¬¦  «        | _	        t          |¦  «        | _        t          j        |j        d¬¦  «        | _        d S )Nr   zconfig.n_heads z must divide config.dim r�   rH   )Únormalized_shaperJ   )rO   rP   r"   r’   r”   r‹   Ú	attentionr   rW   Úsa_layer_normr¬   ÚffnÚoutput_layer_normr]   s     €r.   rP   zTransformerBlock.__init__æ   s«   ø€ Ý‰Œ×ÒÑÔÐð Œ:˜œÑ&¨!Ò+Ð+ÝÐj¨v¬~ÐjÐjÐW]ÔWaÐjÐjÐjÑkÔkÐkå0°Ñ8Ô8ˆŒÝœ\¸6¼:È5ÐQÑQÔQˆÔå�v‘;”;ˆŒÝ!#¤¸v¼zÈuÐ!UÑ!UÔ!UˆÔÐÐr:   Nrœ   rz   r|   rb   .c                 ó¶   —  | j         |fd|i|¤Ž\  }}|                      ||z   ¦  «        }|                      |¦  «        }|                      ||z   ¦  «        }|S )Nrz   )r½   r¾   r¿   rÀ   )r^   rœ   rz   r|   Úattention_outputÚ_Ú
ffn_outputs          r.   rm   zTransformerBlock.forwardó   s†   € ð -˜dœnØð
ð 
à)ð
ð ð
ð 
ÑÐ˜!ð
  ×-Ò-Ð.>ÀÑ.NÑOÔOÐð —X’XÐ.Ñ/Ô/ˆ
Ø×+Ò+¨JÐ9IÑ,IÑJÔJˆ
àÐr:   r©   )rn   ro   rp   r   rP   r*   rq   r   r   rª   rm   rs   rt   s   @r.   rº   rº   å   s«   ø€ € € € € ðVÐ/ð Vð Vð Vð Vð Vð Vð  /3ðð à”|ðð œ tÑ+ðð Ð+Ô,ð	ð
 
ˆuŒ|˜SÐ Ô	!ðð ð ð ð ð ð ð r:   rº   c            	       óf   ‡ — e Zd Zdefˆ fd„Z	 d	dej        dej        dz  dee         de	fd„Z
ˆ xZS )
ÚTransformerrE   c                 óÞ   •‡— t          ¦   «                              ¦   «          ‰j        | _        t          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _        d| _        d S )Nc                 ó.   •— g | ]}t          ‰¦  «        ‘ŒS © )rº   )r6   rÃ   rE   s     €r.   r9   z(Transformer.__init__.<locals>.<listcomp>  s"   ø€ Ð#]Ð#]Ð#]ÀÕ$4°VÑ$<Ô$<Ð#]Ð#]Ð#]r:   F)rO   rP   Ún_layersr   Ú
ModuleListr;   ÚlayerÚgradient_checkpointingr]   s    `€r.   rP   zTransformer.__init__	  sa   øø€ Ý‰Œ×ÒÑÔÐØœˆŒÝ”]Ð#]Ð#]Ð#]Ð#]ÅeÈFÌOÑF\ÔF\Ð#]Ñ#]Ô#]Ñ^Ô^ˆŒ
Ø&+ˆÔ#Ð#Ð#r:   Nrœ   rz   r|   rb   c                 óJ   — | j         D ]} |||fi |¤Ž}Œt          |¬¦  «        S )N)Úlast_hidden_state)rÌ   r   )r^   rœ   rz   r|   Úlayer_modules        r.   rm   zTransformer.forward  sP   € ð !œJð 	ð 	ˆLØ(˜LØØðð ð ðð ˆMˆMõ °Ð?Ñ?Ô?Ð?r:   r©   )rn   ro   rp   r   rP   r*   rq   r   r   r   rm   rs   rt   s   @r.   rÆ   rÆ     s¥   ø€ € € € € ð,Ð/ð ,ð ,ð ,ð ,ð ,ð ,ð /3ð@ð @à”|ð@ð œ tÑ+ð@ð Ð+Ô,ð	@ð
 
ð@ð @ð @ð @ð @ð @ð @ð @r:   rÆ   c                   ó†   ‡ — e Zd ZU eed<   dZdZdZdZdZ	dZ
eedœZ ej        ¦   «         dej        fˆ fd„¦   «         Zˆ xZS )ÚDistilBertPreTrainedModelrE   Ú
distilbertT)rœ   Ú
attentionsrv   c           
      óê  •— t          ¦   «                              |¦  «         t          |t          ¦  «        r»| j        j        r^t          j        |j        j	        t          | j        j        | j        j        t          j        |j        j	        ¦  «        ¦  «        ¦  «         t          j        |j        t          j        |j        j        d         ¦  «                             d¦  «        ¦  «         dS dS )zInitialize the weights.rM   rL   N)rO   Ú_init_weightsÚ
isinstancerD   rE   Úsinusoidal_pos_embdsÚinitÚcopy_rV   Úweightr/   rU   r"   r*   Ú
empty_likerK   r[   rž   r\   )r^   rv   r_   s     €r.   rÖ   z'DistilBertPreTrainedModel._init_weights.  sØ   ø€ õ 	‰Œ×Ò˜fÑ%Ô%Ð%Ý�f�jÑ)Ô)ð 
	iØŒ{Ô/ð Ý”
ØÔ.Ô5Ý0ØœÔ;ØœœÝÔ(¨Ô)CÔ)JÑKÔKñô ñô ð õ ŒJ�vÔ*­E¬L¸Ô9LÔ9RÐSUÔ9VÑ,WÔ,W×,^Ò,^Ð_fÑ,gÔ,gÑhÔhÐhÐhÐhð
	ið 
	ir:   )rn   ro   rp   r    Ú__annotations__Úbase_model_prefixÚsupports_gradient_checkpointingÚ_supports_flash_attnÚ_supports_sdpaÚ_supports_flex_attnÚ_supports_attention_backendrº   r‹   Ú_can_record_outputsr*   Úno_gradr   ÚModulerÖ   rs   rt   s   @r.   rÒ   rÒ      s©   ø€ € € € € € àÐÐÑØ$ÐØ&*Ð#ØÐØ€NØÐØ"&Ðà)Ø-ðð Ðð
 €U„]�_„_ði B¤Ið ið ið ið ið iñ „_ðið ið ið ið ir:   rÒ   c                   ó8  ‡ — e Zd Zdefˆ fd„Zdej        fd„Zdefd„Z	dej        fd„Z
dej        fd	„Zeee	 	 	 	 ddej        d
z  dej        d
z  dej        d
z  dej        d
z  dee         deeej        df         z  fd„¦   «         ¦   «         ¦   «         Zˆ xZS )ÚDistilBertModelrE   c                 óÂ   •— t          ¦   «                              |¦  «         t          |¦  «        | _        t	          |¦  «        | _        |                      ¦   «          d S r©   )rO   rP   rD   rl   rÆ   ÚtransformerÚ	post_initr]   s     €r.   rP   zDistilBertModel.__init__A  sR   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å$ VÑ,Ô,ˆŒÝ& vÑ.Ô.ˆÔð 	�ŠÑÔÐÐÐr:   rb   c                 ó   — | j         j        S ©z1
        Returns the position embeddings
        )rl   rV   ©r^   s    r.   Úget_position_embeddingsz'DistilBertModel.get_position_embeddingsJ  s   € ð ŒÔ2Ð2r:   Únew_num_position_embeddingsc                 ó  — || j         j        z
  }|dk    rdS t                               d|› d�¦  «         || j         _        | j        j        j                             ¦   «         }t          j	        | j         j        | j         j
        ¦  «        | j        _        | j         j        r1t          | j         j        | j         j
        | j        j        ¬¦  «         n†t          j        ¦   «         5  |dk    r*t          j        |¦  «        | j        j        j        d| …<   n+t          j        |d|…         ¦  «        | j        j        _        ddd¦  «         n# 1 swxY w Y   | j        j                             | j        ¦  «         dS )áÒ  
        Resizes position embeddings of the model if `new_num_position_embeddings != config.max_position_embeddings`.

        Arguments:
            new_num_position_embeddings (`int`):
                The number of new position embedding matrix. If position embeddings are learned, increasing the size
                will add newly initialized vectors at the end, whereas reducing the size will remove vectors from the
                end. If position embeddings are not learned (*e.g.* sinusoidal position embeddings), increasing the
                size will add correct vectors at the end following the position encoding algorithm, whereas reducing
                the size will remove vectors from the end.
        r   Nz(Setting `config.max_position_embeddings=z`...r&   )rE   rU   ÚloggerÚinforl   rV   rÛ   Úcloner   rQ   r"   rØ   r/   r*   rå   Ú	ParameterÚtore   )r^   rð   Únum_position_embeds_diffÚold_position_embeddings_weights       r.   Úresize_position_embeddingsz*DistilBertModel.resize_position_embeddingsP  s»  € ð $?ÀÄÔAdÑ#dÐ ð $ qÒ(Ð(ØˆFå�ŠÐ`Ð?ZÐ`Ð`Ð`ÑaÔaÐaØ.IˆŒÔ+à)-¬Ô)LÔ)S×)YÒ)YÑ)[Ô)[Ð&å.0¬l¸4¼;Ô;^Ð`dÔ`kÔ`oÑ.pÔ.pˆŒÔ+àŒ;Ô+ð 	Ý(Ø”kÔ9¸t¼{¼ÐTXÔTlÔTsðñ ô ð ð õ ”‘”ð ð Ø+¨aÒ/Ð/Ý]_Ô]iØ6ñ^ô ^�D”OÔ7Ô>Ð?YÐAYÐ@YÐ?YÑZÐZõ BDÄØ6Ð7PÐ8PÐ7PÔQñBô B�D”OÔ7Ô>ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð 	ŒÔ+×.Ò.¨t¬{Ñ;Ô;Ð;Ð;Ð;s   Ã(AEÅEÅEc                 ó   — | j         j        S r©   ©rl   rT   rî   s    r.   Úget_input_embeddingsz$DistilBertModel.get_input_embeddingsz  s   € ØŒÔ.Ð.r:   Únew_embeddingsc                 ó   — || j         _        d S r©   rü   ©r^   rþ   s     r.   Úset_input_embeddingsz$DistilBertModel.set_input_embeddings}  s   € Ø*8ˆŒÔ'Ð'Ð'r:   Nr`   rz   ra   rK   r|   .c                 ó®   — |du |duz  rt          d¦  «        ‚|                      |||¦  «        }t          | j        ||¬¦  «        } | j        d||dœ|¤ŽS )á   
        input_ids (`torch.LongTensor` of shape `(batch_size, num_choices)`):
            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)
        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, num_choices, 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.
        Nz:You must specify exactly one of input_ids or inputs_embeds)rE   ra   rz   )rœ   rz   rÉ   )r”   rl   r   rE   rê   )r^   r`   rz   ra   rK   r|   rl   s          r.   rm   zDistilBertModel.forward€  s’   € ð0 ˜Ð -°tÐ";Ñ<ð 	[ÝÐYÑZÔZÐZà—_’_ Y°¸|ÑLÔLˆ
å2Ø”;Ø$Ø)ð
ñ 
ô 
ˆð  ˆtÔð 
Ø$Ø)ð
ð 
ð ð
ð 
ð 	
r:   )NNNN)rn   ro   rp   r   rP   r   rQ   rï   Úintrú   rý   r  r   r   r   r*   rq   r   r   r   rª   rm   rs   rt   s   @r.   rè   rè   ?  sm  ø€ € € € € ðÐ/ð ð ð ð ð ð ð3¨¬ð 3ð 3ð 3ð 3ð(<Àcð (<ð (<ð (<ð (<ðT/ b¤lð /ð /ð /ð /ð9°2´<ð 9ð 9ð 9ð 9ð  ØØð *.Ø.2Ø-1Ø,0ð$
ð $
à”< $Ñ&ð$
ð œ tÑ+ð$
ð ”| dÑ*ð	$
ð
 ”l TÑ)ð$
ð Ð+Ô,ð$
ð 
˜5 ¤¨sÐ!2Ô3Ñ	3ð$
ð $
ð $
ñ „^ñ „_ñ  Ôð$
ð $
ð $
ð $
ð $
r:   rè   zI
    DistilBert Model with a `masked language modeling` head on top.
    )Úcustom_introc                   óF  ‡ — e Zd ZddiZdefˆ fd„Zdej        fd„Zde	fd„Z
dej        fd	„Zd
ej        fd„Zee	 	 	 	 	 ddej        dz  dej        dz  dej        dz  dej        dz  dej        dz  dee         deeej        df         z  fd„¦   «         ¦   «         Zˆ xZS )ÚDistilBertForMaskedLMzvocab_projector.weightz,distilbert.embeddings.word_embeddings.weightrE   c                 óÌ  •— t          ¦   «                              |¦  «         t          |j        ¦  «        | _        t	          |¦  «        | _        t          j        |j        |j        ¦  «        | _	        t          j
        |j        d¬¦  «        | _        t          j        |j        |j        ¦  «        | _        |                      ¦   «          t          j        ¦   «         | _        d S )NrH   rI   )rO   rP   r
   r³   rè   rÓ   r   r•   r"   Úvocab_transformrW   Úvocab_layer_normrR   Úvocab_projectorrë   r   Úmlm_loss_fctr]   s     €r.   rP   zDistilBertForMaskedLM.__init__²  s¯   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å(¨Ô):Ñ;Ô;ˆŒå)¨&Ñ1Ô1ˆŒÝ!œy¨¬°V´ZÑ@Ô@ˆÔÝ "¤¨V¬Z¸UÐ CÑ CÔ CˆÔÝ!œy¨¬°VÔ5FÑGÔGˆÔð 	�ŠÑÔÐåÔ/Ñ1Ô1ˆÔÐÐr:   rb   c                 ó4   — | j                              ¦   «         S rí   ©rÓ   rï   rî   s    r.   rï   z-DistilBertForMaskedLM.get_position_embeddingsÁ  ó   € ð Œ×6Ò6Ñ8Ô8Ð8r:   rð   c                 ó:   — | j                              |¦  «         dS ©rò   N©rÓ   rú   ©r^   rð   s     r.   rú   z0DistilBertForMaskedLM.resize_position_embeddingsÇ  ó!   € ð 	Œ×2Ò2Ð3NÑOÔOÐOÐOÐOr:   c                 ó   — | j         S r©   ©r  rî   s    r.   Úget_output_embeddingsz+DistilBertForMaskedLM.get_output_embeddingsÕ  s   € ØÔ#Ð#r:   rþ   c                 ó   — || _         d S r©   r  r   s     r.   Úset_output_embeddingsz+DistilBertForMaskedLM.set_output_embeddingsØ  s   € Ø-ˆÔÐÐr:   Nr`   rz   ra   ÚlabelsrK   r|   .c           	      óÂ  —  | j         d||||ddœ|¤Ž}|d         }|                      |¦  «        }	|                      |	¦  «        }	|                      |	¦  «        }	|                      |	¦  «        }	d}
|�P|                      |	                     d|	                     d¦  «        ¦  «        |                     d¦  «        ¦  «        }
t          |
|	|j	        |j
        ¬¦  «        S )aš  
        input_ids (`torch.LongTensor` of shape `(batch_size, num_choices)`):
            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)
        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, num_choices, 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.
        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`   rz   ra   rK   Úreturn_dictr   NrM   ©ÚlossÚlogitsrœ   rÔ   rÉ   )rÓ   r	  r³   r
  r  r  rŸ   rf   r   rœ   rÔ   )r^   r`   rz   ra   r  rK   r|   Údlbrt_outputrœ   Úprediction_logitsÚmlm_losss              r.   rm   zDistilBertForMaskedLM.forwardÛ  s  € ð8 '�t”ð 
ØØ)Ø'Ø%Øð
ð 
ð ð
ð 
ˆð % QœˆØ ×0Ò0°Ñ?Ô?ÐØ ŸOšOÐ,=Ñ>Ô>ÐØ ×1Ò1Ð2CÑDÔDÐØ ×0Ò0Ð1BÑCÔCÐàˆØÐØ×(Ò(Ð):×)?Ò)?ÀÐDU×DZÒDZÐ[]ÑD^ÔD^Ñ)_Ô)_Ðag×alÒalÐmoÑapÔapÑqÔqˆHåØØ$Ø&Ô4Ø#Ô.ð	
ñ 
ô 
ð 	
r:   ©NNNNN)rn   ro   rp   Ú_tied_weights_keysr   rP   r   rQ   rï   r  rú   ræ   r  r  r   r   r*   rq   rr   r   r   r   rª   rm   rs   rt   s   @r.   r  r  ª  sŠ  ø€ € € € € ð 3Ð4bÐcÐð2Ð/ð 2ð 2ð 2ð 2ð 2ð 2ð9¨¬ð 9ð 9ð 9ð 9ðPÀcð Pð Pð Pð Pð$ r¤yð $ð $ð $ð $ð.°B´Ið .ð .ð .ð .ð Øð *.Ø.2Ø-1Ø*.Ø,0ð1
ð 1
à”< $Ñ&ð1
ð œ tÑ+ð1
ð ”| dÑ*ð	1
ð
 Ô  4Ñ'ð1
ð ”l TÑ)ð1
ð Ð+Ô,ð1
ð 
˜% ¤¨cÐ 1Ô2Ñ	2ð1
ð 1
ð 1
ñ „^ñ Ôð1
ð 1
ð 1
ð 1
ð 1
r:   r  z¢
    DistilBert 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                   ó  ‡ — e Zd Zdefˆ fd„Zdej        fd„Zdefd„Z	e
e	 	 	 	 	 ddej        dz  d	ej        dz  d
ej        dz  dej        dz  dej        dz  dee         deeej        df         z  fd„¦   «         ¦   «         Zˆ xZS )Ú#DistilBertForSequenceClassificationrE   c                 óŒ  •— t          ¦   «                              |¦  «         |j        | _        || _        t	          |¦  «        | _        t          j        |j        |j        ¦  «        | _	        t          j        |j        |j        ¦  «        | _
        t          j        |j        ¦  «        | _        |                      ¦   «          d S r©   )rO   rP   Ú
num_labelsrE   rè   rÓ   r   r•   r"   Úpre_classifierÚ
classifierrX   Úseq_classif_dropoutrY   rë   r]   s     €r.   rP   z,DistilBertForSequenceClassification.__init__  s—   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø Ô+ˆŒØˆŒå)¨&Ñ1Ô1ˆŒÝ œi¨¬
°F´JÑ?Ô?ˆÔÝœ) F¤J°Ô0AÑBÔBˆŒÝ”z &Ô"<Ñ=Ô=ˆŒð 	�ŠÑÔÐÐÐr:   rb   c                 ó4   — | j                              ¦   «         S rí   r  rî   s    r.   rï   z;DistilBertForSequenceClassification.get_position_embeddings%  r  r:   rð   c                 ó:   — | j                              |¦  «         dS r  r  r  s     r.   rú   z>DistilBertForSequenceClassification.resize_position_embeddings+  r  r:   Nr`   rz   ra   r  rK   r|   .c           	      óþ  —  | j         d||||ddœ|¤Ž}|d         }|dd…df         }	|                      |	¦  «        }	 t          j        ¦   «         |	¦  «        }	|                      |	¦  «        }	|                      |	¦  «        }
d}|��Z| j        j        €f| j        dk    rd| j        _        nN| j        dk    r7|j	        t          j        k    s|j	        t          j        k    rd| j        _        nd| j        _        | j        j        dk    rWt          ¦   «         }| j        dk    r1 ||
                     ¦   «         |                     ¦   «         ¦  «        }nŽ ||
|¦  «        }n�| j        j        dk    rGt          ¦   «         } ||
                     d	| j        ¦  «        |                     d	¦  «        ¦  «        }n*| j        j        dk    rt#          ¦   «         } ||
|¦  «        }t%          ||
|j        |j        ¬
¦  «        S )a�  
        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).
        Tr  r   Nr   Ú
regressionÚsingle_label_classificationÚmulti_label_classificationrM   r  rÉ   )rÓ   r*  r   ÚReLUrY   r+  rE   Úproblem_typer)  rd   r*   rh   r  r   Úsqueezer   rŸ   r   r   rœ   rÔ   )r^   r`   rz   ra   r  rK   r|   Údistilbert_outputÚhidden_stateÚpooled_outputr   r  Úloss_fcts                r.   rm   z+DistilBertForSequenceClassification.forward9  s  € ð" ,˜DœOð 
ØØ)Ø'Ø%Øð
ð 
ð ð
ð 
Ðð )¨Ô+ˆØ$ Q Q Q¨ TÔ*ˆØ×+Ò+¨MÑ:Ô:ˆØ!�œ™	œ	 -Ñ0Ô0ˆØŸš ]Ñ3Ô3ˆØ—’ Ñ/Ô/ˆàˆØÑØŒ{Ô'Ð/Ø”? aÒ'Ð'Ø/;�D”KÔ,Ð,Ø”_ qÒ(Ð(¨f¬l½e¼jÒ.HÐ.HÈFÌLÕ\aÔ\eÒLeÐLeØ/L�D”KÔ,Ð,à/K�D”KÔ,àŒ{Ô'¨<Ò7Ð7Ý"™9œ9�Ø”? aÒ'Ð'Ø#˜8 F§N¢NÑ$4Ô$4°f·n²nÑ6FÔ6FÑGÔG�D�Dà#˜8 F¨FÑ3Ô3�D�DØ”Ô)Ð-JÒJÐJÝ+Ñ-Ô-�Ø�x §¢¨B°´Ñ @Ô @À&Ç+Â+ÈbÁ/Ä/ÑRÔR��Ø”Ô)Ð-IÒIÐIÝ,Ñ.Ô.�Ø�x ¨Ñ/Ô/�å'ØØØ+Ô9Ø(Ô3ð	
ñ 
ô 
ð 	
r:   r$  )rn   ro   rp   r   rP   r   rQ   rï   r  rú   r   r   r*   rq   rr   r   r   r   rª   rm   rs   rt   s   @r.   r'  r'    sB  ø€ € € € € ðÐ/ð ð ð ð ð ð ð9¨¬ð 9ð 9ð 9ð 9ðPÀcð Pð Pð Pð Pð Øð *.Ø.2Ø-1Ø*.Ø,0ð:
ð :
à”< $Ñ&ð:
ð œ tÑ+ð:
ð ”| dÑ*ð	:
ð
 Ô  4Ñ'ð:
ð ”l TÑ)ð:
ð Ð+Ô,ð:
ð 
" E¨%¬,¸Ð*;Ô$<Ñ	<ð:
ð :
ð :
ñ „^ñ Ôð:
ð :
ð :
ð :
ð :
r:   r'  c                   ó(  ‡ — e Zd Zdefˆ fd„Zdej        fd„Zdefd„Z	e
e	 	 	 	 	 	 ddej        dz  d	ej        dz  d
ej        dz  dej        dz  dej        dz  dej        dz  dee         deeej        df         z  fd„¦   «         ¦   «         Zˆ xZS )ÚDistilBertForQuestionAnsweringrE   c                 ób  •— t          ¦   «                              |¦  «         t          |¦  «        | _        t	          j        |j        |j        ¦  «        | _        |j        dk    rt          d|j        › �¦  «        ‚t	          j
        |j        ¦  «        | _        |                      ¦   «          d S )Nr3   z)config.num_labels should be 2, but it is )rO   rP   rè   rÓ   r   r•   r"   r)  Ú
qa_outputsr”   rX   Ú
qa_dropoutrY   rë   r]   s     €r.   rP   z'DistilBertForQuestionAnswering.__init__z  s–   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å)¨&Ñ1Ô1ˆŒÝœ) F¤J°Ô0AÑBÔBˆŒØÔ Ò!Ð!ÝÐ\ÈÔIZÐ\Ð\Ñ]Ô]Ð]å”z &Ô"3Ñ4Ô4ˆŒð 	�ŠÑÔÐÐÐr:   rb   c                 ó4   — | j                              ¦   «         S rí   r  rî   s    r.   rï   z6DistilBertForQuestionAnswering.get_position_embeddings‡  r  r:   rð   c                 ó:   — | j                              |¦  «         dS r  r  r  s     r.   rú   z9DistilBertForQuestionAnswering.resize_position_embeddings�  r  r:   Nr`   rz   ra   Ústart_positionsÚend_positionsrK   r|   .c           	      óx  —  | j         d||||ddœ|¤Ž}|d         }	|                      |	¦  «        }	|                      |	¦  «        }
|
                     dd¬¦  «        \  }}|                     d¦  «                             ¦   «         }|                     d¦  «                             ¦   «         }d}|�ì|�êt          |                     ¦   «         ¦  «        dk    r|                     d¦  «        }t          |                     ¦   «         ¦  «        dk    r|                     d¦  «        }|                     d¦  «        }|                     d|¦  «        }|                     d|¦  «        }t          j
        |¬¦  «        } |||¦  «        } |||¦  «        }||z   d	z  }t          ||||j        |j        ¬
¦  «        S )r  Tr  r   r   rM   r   N)Úignore_indexr3   )r  Ústart_logitsÚ
end_logitsrœ   rÔ   rÉ   )rÓ   rY   r=  Úsplitr5  r†   Úlenrf   Úclampr   r   r   rœ   rÔ   )r^   r`   rz   ra   rA  rB  rK   r|   r6  rœ   r   rE  rF  Ú
total_lossÚignored_indexr9  Ú
start_lossÚend_losss                     r.   rm   z&DistilBertForQuestionAnswering.forward›  sâ  € ð2 ,˜DœOð 
ØØ)Ø'Ø%Øð
ð 
ð ð
ð 
Ðð *¨!Ô,ˆàŸš ]Ñ3Ô3ˆØ—’ Ñ/Ô/ˆØ#)§<¢<°°r <Ñ#:Ô#:Ñ ˆ�jØ#×+Ò+¨BÑ/Ô/×:Ò:Ñ<Ô<ˆØ×'Ò'¨Ñ+Ô+×6Ò6Ñ8Ô8ˆ
àˆ
ØÐ&¨=Ð+Då�?×'Ò'Ñ)Ô)Ñ*Ô*¨QÒ.Ð.Ø"1×"9Ò"9¸"Ñ"=Ô"=�Ý�=×%Ò%Ñ'Ô'Ñ(Ô(¨1Ò,Ð,Ø -× 5Ò 5°bÑ 9Ô 9�à(×-Ò-¨aÑ0Ô0ˆMØ-×3Ò3°A°}ÑEÔEˆOØ)×/Ò/°°=ÑAÔAˆMåÔ*¸ÐFÑFÔFˆHØ!˜ ,°Ñ@Ô@ˆJØ�x 
¨MÑ:Ô:ˆHØ$ xÑ/°1Ñ4ˆJå+ØØ%Ø!Ø+Ô9Ø(Ô3ð
ñ 
ô 
ð 	
r:   )NNNNNN)rn   ro   rp   r   rP   r   rQ   rï   r  rú   r   r   r*   rq   r   r   r   rª   rm   rs   rt   s   @r.   r;  r;  x  sU  ø€ € € € € ðÐ/ð ð ð ð ð ð ð9¨¬ð 9ð 9ð 9ð 9ðPÀcð Pð Pð Pð Pð Øð *.Ø.2Ø-1Ø/3Ø-1Ø,0ð>
ð >
à”< $Ñ&ð>
ð œ tÑ+ð>
ð ”| dÑ*ð	>
ð
 œ¨Ñ,ð>
ð ”| dÑ*ð>
ð ”l TÑ)ð>
ð Ð+Ô,ð>
ð 
&¨¨e¬l¸CÐ.?Ô(@Ñ	@ð>
ð >
ð >
ñ „^ñ Ôð>
ð >
ð >
ð >
ð >
r:   r;  c                   ó  ‡ — e Zd Zdefˆ fd„Zdej        fd„Zdefd„Z	e
e	 	 	 	 	 ddej        dz  d	ej        dz  d
ej        dz  dej        dz  dej        dz  dee         deeej        df         z  fd„¦   «         ¦   «         Zˆ xZS )Ú DistilBertForTokenClassificationrE   c                 ó6  •— t          ¦   «                              |¦  «         |j        | _        t          |¦  «        | _        t          j        |j        ¦  «        | _        t          j        |j	        |j        ¦  «        | _
        |                      ¦   «          d S r©   )rO   rP   r)  rè   rÓ   r   rX   rY   r•   Úhidden_sizer+  rë   r]   s     €r.   rP   z)DistilBertForTokenClassification.__init__à  sx   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø Ô+ˆŒå)¨&Ñ1Ô1ˆŒÝ”z &¤.Ñ1Ô1ˆŒÝœ) FÔ$6¸Ô8IÑJÔJˆŒð 	�ŠÑÔÐÐÐr:   rb   c                 ó4   — | j                              ¦   «         S rí   r  rî   s    r.   rï   z8DistilBertForTokenClassification.get_position_embeddingsë  r  r:   rð   c                 ó:   — | j                              |¦  «         dS r  r  r  s     r.   rú   z;DistilBertForTokenClassification.resize_position_embeddingsñ  r  r:   Nr`   rz   ra   r  rK   r|   .c                 óZ  —  | j         |f|||ddœ|¤Ž}|d         }|                      |¦  «        }|                      |¦  «        }	d}
|�Ft          ¦   «         } ||	                     d| j        ¦  «        |                     d¦  «        ¦  «        }
t          |
|	|j        |j        ¬¦  «        S )zÛ
        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]`.
        T©rz   ra   rK   r  r   NrM   r  )	rÓ   rY   r+  r   rŸ   r)  r   rœ   rÔ   )r^   r`   rz   ra   r  rK   r|   ÚoutputsÚsequence_outputr   r  r9  s               r.   rm   z(DistilBertForTokenClassification.forwardÿ  sÑ   € ð "�$”/Øð
à)Ø'Ø%Øð
ð 
ð ð
ð 
ˆð " !œ*ˆàŸ,š, Ñ7Ô7ˆØ—’ Ñ1Ô1ˆàˆØÐÝ'Ñ)Ô)ˆHØ�8˜FŸKšK¨¨D¬OÑ<Ô<¸f¿kºkÈ"¹o¼oÑNÔNˆDå$ØØØ!Ô/ØÔ)ð	
ñ 
ô 
ð 	
r:   r$  )rn   ro   rp   r   rP   r   rQ   rï   r  rú   r   r   r*   rq   rr   r   r   r   rª   rm   rs   rt   s   @r.   rO  rO  Þ  sB  ø€ € € € € ð	Ð/ð 	ð 	ð 	ð 	ð 	ð 	ð9¨¬ð 9ð 9ð 9ð 9ðPÀcð Pð Pð Pð Pð Øð *.Ø.2Ø-1Ø*.Ø,0ð%
ð %
à”< $Ñ&ð%
ð œ tÑ+ð%
ð ”| dÑ*ð	%
ð
 Ô  4Ñ'ð%
ð ”l TÑ)ð%
ð Ð+Ô,ð%
ð 
  u¤|°SÐ'8Ô!9Ñ	9ð%
ð %
ð %
ñ „^ñ Ôð%
ð %
ð %
ð %
ð %
r:   rO  c                   ó  ‡ — e Zd Zdefˆ fd„Zdej        fd„Zdefd„Z	e
e	 	 	 	 	 ddej        dz  d	ej        dz  d
ej        dz  dej        dz  dej        dz  dee         deeej        df         z  fd„¦   «         ¦   «         Zˆ xZS )ÚDistilBertForMultipleChoicerE   c                 ó\  •— t          ¦   «                              |¦  «         t          |¦  «        | _        t	          j        |j        |j        ¦  «        | _        t	          j        |j        d¦  «        | _        t	          j	        |j
        ¦  «        | _        |                      ¦   «          d S )Nr   )rO   rP   rè   rÓ   r   r•   r"   r*  r+  rX   r,  rY   rë   r]   s     €r.   rP   z$DistilBertForMultipleChoice.__init__+  sƒ   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å)¨&Ñ1Ô1ˆŒÝ œi¨¬
°F´JÑ?Ô?ˆÔÝœ) F¤J°Ñ2Ô2ˆŒÝ”z &Ô"<Ñ=Ô=ˆŒð 	�ŠÑÔÐÐÐr:   rb   c                 ó4   — | j                              ¦   «         S rí   r  rî   s    r.   rï   z3DistilBertForMultipleChoice.get_position_embeddings6  r  r:   rð   c                 ó:   — | j                              |¦  «         dS )aË  
        Resizes position embeddings of the model if `new_num_position_embeddings != config.max_position_embeddings`.

        Arguments:
            new_num_position_embeddings (`int`)
                The number of new position embeddings. If position embeddings are learned, increasing the size will add
                newly initialized vectors at the end, whereas reducing the size will remove vectors from the end. If
                position embeddings are not learned (*e.g.* sinusoidal position embeddings), increasing the size will
                add correct vectors at the end following the position encoding algorithm, whereas reducing the size
                will remove vectors from the end.
        Nr  r  s     r.   rú   z6DistilBertForMultipleChoice.resize_position_embeddings<  r  r:   Nr`   rz   ra   r  rK   r|   .c                 ó  — |�|j         d         n|j         d         }|�)|                     d|                     d¦  «        ¦  «        nd}|�)|                     d|                     d¦  «        ¦  «        nd}|�=|                     d|                     d¦  «        |                     d¦  «        ¦  «        nd} | j        |f|||ddœ|¤Ž}|d         }	|	dd…df         }
|                      |
¦  «        }
 t          j        ¦   «         |
¦  «        }
|                      |
¦  «        }
|                      |
¦  «        }|                     d|¦  «        }d}|�t          ¦   «         } |||¦  «        }t          |||j        |j        ¬¦  «        S )	a^  
        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)
        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.
        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)

        Examples:

        ```python
        >>> from transformers import AutoTokenizer, DistilBertForMultipleChoice
        >>> import torch

        >>> tokenizer = AutoTokenizer.from_pretrained("distilbert-base-cased")
        >>> model = DistilBertForMultipleChoice.from_pretrained("distilbert-base-cased")

        >>> prompt = "In Italy, pizza served in formal settings, such as at a restaurant, is presented unsliced."
        >>> choice0 = "It is eaten with a fork and a knife."
        >>> choice1 = "It is eaten while held in the hand."
        >>> labels = torch.tensor(0).unsqueeze(0)  # choice0 is correct (according to Wikipedia ;)), batch size 1

        >>> encoding = tokenizer([[prompt, choice0], [prompt, choice1]], return_tensors="pt", padding=True)
        >>> outputs = model(**{k: v.unsqueeze(0) for k, v in encoding.items()}, labels=labels)  # batch size is 1

        >>> # the linear classifier still needs to be trained
        >>> loss = outputs.loss
        >>> logits = outputs.logits
        ```Nr   rM   éþÿÿÿTrU  r   r  )rž   rŸ   rf   rÓ   r*  r   r3  rY   r+  r   r   rœ   rÔ   )r^   r`   rz   ra   r  rK   r|   Únum_choicesrV  r7  r8  r   Úreshaped_logitsr  r9  s                  r.   rm   z#DistilBertForMultipleChoice.forwardJ  sÄ  € ðb -6Ð,A�i”o aÔ(Ð(À}ÔGZÐ[\ÔG]ˆà>GÐ>S�I—N’N 2 y§~¢~°bÑ'9Ô'9Ñ:Ô:Ð:ÐY]ˆ	ØM[ÐMg˜×,Ò,¨R°×1DÒ1DÀRÑ1HÔ1HÑIÔIÐIÐmqˆð Ð(ð ×Ò˜r =×#5Ò#5°bÑ#9Ô#9¸=×;MÒ;MÈbÑ;QÔ;QÑRÔRÐRàð 	ð "�$”/Øð
à)Ø'Ø%Øð
ð 
ð ð
ð 
ˆð ˜q”zˆØ$ Q Q Q¨ TÔ*ˆØ×+Ò+¨MÑ:Ô:ˆØ!�œ™	œ	 -Ñ0Ô0ˆØŸš ]Ñ3Ô3ˆØ—’ Ñ/Ô/ˆà Ÿ+š+ b¨+Ñ6Ô6ˆàˆØÐÝ'Ñ)Ô)ˆHØ�8˜O¨VÑ4Ô4ˆDå(ØØ"Ø!Ô/ØÔ)ð	
ñ 
ô 
ð 	
r:   r$  )rn   ro   rp   r   rP   r   rQ   rï   r  rú   r   r   r*   rq   rr   r   r   r   rª   rm   rs   rt   s   @r.   rY  rY  )  sR  ø€ € € € € ð	Ð/ð 	ð 	ð 	ð 	ð 	ð 	ð9¨¬ð 9ð 9ð 9ð 9ðPÀcð Pð Pð Pð Pð Øð *.Ø.2Ø-1Ø*.Ø,0ðU
ð U
à”< $Ñ&ðU
ð œ tÑ+ðU
ð ”| dÑ*ð	U
ð
 Ô  4Ñ'ðU
ð ”l TÑ)ðU
ð Ð+Ô,ðU
ð 
# U¨5¬<¸Ð+<Ô%=Ñ	=ðU
ð U
ð U
ñ „^ñ ÔðU
ð U
ð U
ð U
ð U
r:   rY  )r  rY  r;  r'  rO  rè   rÒ   )Nru   )HÚ__doc__Úcollections.abcr   Únumpyr4   r*   r   Útorch.nnr   r   r   Ú r	   rÙ   Úactivationsr
   Úconfiguration_utilsr   Úintegrations.deepspeedr   Úmasking_utilsr   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   r   r   Úmodeling_utilsr   r   Úprocessing_utilsr   Úpytorch_utilsr   Úutilsr   r   r   Úutils.genericr   r   Úutils.output_capturingr   Úconfiguration_distilbertr    Ú
get_loggerrn   ró   r  rq   r/   r-   ræ   rD   Úfloatr‰   r‹   r¬   rº   rÆ   rÒ   rè   r  r'  r;  rO  rY  Ú__all__rÉ   r:   r.   ú<module>rv     sÂ  ððð ð
 %Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ø €€€Ø Ð Ð Ð Ð Ð Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ Aà &Ð &Ð &Ð &Ð &Ð &Ø )Ð )Ð )Ð )Ð )Ð )Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø @Ð @Ð @Ð @Ð @Ð @Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð GÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ &Ð &Ð &Ð &Ð &Ð &ðð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð
 JÐ IÐ IÐ IÐ IÐ IÐ IÐ IØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6ð 
ˆÔ	˜HÑ	%Ô	%€ðL¨ð L°#ð L¸E¼Lð Lð Lð Lð Lð¨ð °3ð ¸U¼\ð ð ð ð ð&ð &ð &ð &ð &�”ñ &ô &ð &ð` !Øð%ð %ØŒIð%àŒ<ð%ð 
Œð%ð Œ<ð	%ð
 ”L 4Ñ'ð%ð �T‰\ð%ð ð%ð Ð'Ô(ð%ð %ð %ð %ð85)ð 5)ð 5)ð 5)ð 5)˜bœiñ 5)ô 5)ð 5)ðpð ð ð ð ˆ"Œ)ñ ô ð ð* ð  ð  ð  ð  Ð1ñ  ô  ð  ðF@ð @ð @ð @ð @�"”)ñ @ô @ð @ð0 ðið ið ið ið i ñ iô iñ „ðið< ðg
ð g
ð g
ð g
ð g
Ð/ñ g
ô g
ñ „ðg
ðT €ððñ ô ð
_
ð _
ð _
ð _
ð _
Ð5ñ _
ô _
ñô ð
_
ðD €ððñ ô ð^
ð ^
ð ^
ð ^
ð ^
Ð*Cñ ^
ô ^
ñô ð^
ðB ðb
ð b
ð b
ð b
ð b
Ð%>ñ b
ô b
ñ „ðb
ðJ ðG
ð G
ð G
ð G
ð G
Ð'@ñ G
ô G
ñ „ðG
ðT ðw
ð w
ð w
ð w
ð w
Ð";ñ w
ô w
ñ „ðw
ðtð ð €€€r:   