Ë
    S^(hDý  ã                   óô  — d 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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mZmZmZmZmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,  e)jZ                  e.«      Z/dZ0dZ1d„ Z2 G d„ dejf                  «      Z4 G d„ dejf                  «      Z5 G d„ de5«      Z6e5e6dœZ7 G d„ dejf                  «      Z8 G d„ dejf                  «      Z9 G d„ dejf                  «      Z: G d „ d!e«      Z;e G d"„ d#e%«      «       Z<d$Z=d%Z> e'd&e=«       G d'„ d(e;«      «       Z? e'd)e=«       G d*„ d+e;«      «       Z@ G d,„ d-ejf                  «      ZA G d.„ d/ejf                  «      ZB e'd0e=«       G d1„ d2e;«      «       ZC e'd3e=«       G d4„ d5e;«      «       ZD e'd6e=«       G d7„ d8e;«      «       ZE e'd9e=«       G d:„ d;e;«      «       ZF e'd<e=«       G d=„ d>e;«      «       ZGg d?¢ZHy)@zPyTorch ALBERT model.é    N)Ú	dataclass)ÚDictÚListÚOptionalÚTupleÚUnion)Únn)ÚBCEWithLogitsLossÚCrossEntropyLossÚMSELossé   )ÚACT2FN)Ú#_prepare_4d_attention_mask_for_sdpa)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚMaskedLMOutputÚMultipleChoiceModelOutputÚQuestionAnsweringModelOutputÚSequenceClassifierOutputÚTokenClassifierOutput)ÚPreTrainedModel)Úapply_chunking_to_forwardÚ find_pruneable_heads_and_indicesÚ"is_torch_greater_or_equal_than_2_2Úprune_linear_layer)ÚModelOutputÚadd_code_sample_docstringsÚadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚloggingÚreplace_return_docstringsé   )ÚAlbertConfigzalbert/albert-base-v2r#   c           	      ó²	  — 	 ddl }ddl}ddl}t        j                  j                  |«      }t        j                  d|› �«       |j                  j                  |«      }g }g }	|D ]^  \  }
}t        j                  d|
› d|› �«       |j                  j                  ||
«      }|j                  |
«       |	j                  |«       Œ` t        ||	«      D ]  \  }
}t        |
«       Œ t        ||	«      D �]J  \  }
}|
}|
j!                  dd«      }
|
j!                  d	d
«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  dd«      }
|
j!                  d d!«      }
|
j!                  d"d#«      }
|
j!                  d$d%«      }
t#        |
j%                  d«      «      d&k(  rd'|
v sd(|
v rd)|
z   }
d*|
v r$|
j!                  d+d,«      }
|
j!                  d-d.«      }
|
j%                  d«      }
d/|
v sd0|
v sd1|
v sd2|
v sd3|
v r)t        j                  d4dj'                  |
«      › �«       �Œí| }|
D ]À  }|j)                  d5|«      r|j%                  d6|«      }n|g}|d   d7k(  s|d   d8k(  rt+        |d.«      }nW|d   d'k(  s|d   d9k(  rt+        |d:«      }n:|d   d(k(  rt+        |d.«      }n%|d   d;k(  rt+        |d<«      }n	 t+        ||d   «      }t#        |«      d=k\  sŒ®t/        |d&   «      }||   }ŒÂ d>d d?k(  rt+        |d.«      }n|d7k(  r|j1                  |«      }	 |j2                  |j2                  k7  r&t5        d@|j2                  › dA|j2                  › dB�«      ‚	 t        dC|
› dD|› �«       t9        j:                  |«      |_        �ŒM | S # t        $ r t        j                  d«       ‚ w xY w# t,        $ r+ t        j                  d4dj'                  |
«      › �«       Y �Œµw xY w# t4        $ r1}|xj6                  |j2                  |j2                  fz  c_        ‚ d}~ww xY w)Ez'Load tf checkpoints in a pytorch model.r   Nz™Loading a TensorFlow model in PyTorch, requires TensorFlow to be installed. Please see https://www.tensorflow.org/install/ for installation instructions.z&Converting TensorFlow checkpoint from zLoading TF weight z with shape zmodule/Ú Úffn_1Úffnzbert/zalbert/Úattention_1Ú	attentionz
transform/ÚLayerNorm_1Úfull_layer_layer_normÚ	LayerNormzattention/LayerNormztransformer/zintermediate/dense/zffn/intermediate/output/dense/zffn_output/z/output/ú/z/self/zpooler/denseÚpoolerzcls/predictionsÚpredictionszpredictions/attentionzembeddings/attentionÚ
embeddingsÚinner_group_zalbert_layers/Úgroup_zalbert_layer_groups/r"   Úoutput_biasÚoutput_weightszclassifier/Úseq_relationshipzseq_relationship/output_zsop_classifier/classifier/ÚweightsÚweightÚadam_mÚadam_vÚAdamWeightDecayOptimizerÚAdamWeightDecayOptimizer_1Úglobal_stepz	Skipping z[A-Za-z]+_\d+z_(\d+)ÚkernelÚgammaÚbetaÚbiasÚsquadÚ
classifieré   iõÿÿÿÚ_embeddingszPointer shape z and array shape z mismatchedzInitialize PyTorch weight z from )ÚreÚnumpyÚ
tensorflowÚImportErrorÚloggerÚerrorÚosÚpathÚabspathÚinfoÚtrainÚlist_variablesÚload_variableÚappendÚzipÚprintÚreplaceÚlenÚsplitÚjoinÚ	fullmatchÚgetattrÚAttributeErrorÚintÚ	transposeÚshapeÚ
ValueErrorÚargsÚtorchÚ
from_numpyÚdata)ÚmodelÚconfigÚtf_checkpoint_pathrE   ÚnpÚtfÚtf_pathÚ	init_varsÚnamesÚarraysÚnamer^   ÚarrayÚoriginal_nameÚpointerÚm_nameÚscope_namesÚnumÚes                      úh/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/albert/modeling_albert.pyÚload_tf_weights_in_albertrv   =   sý  € ð
ÛãÛô �g‰g�o‰oÐ0Ó1€GÜ
‡K�KÐ8¸¸	ÐBÔCà—‘×'Ñ'¨Ó0€IØ€EØ€FØ ò ‰ˆˆeÜ�‰Ð(¨¨¨l¸5¸'ÐBÔCØ—‘×&Ñ& w°Ó5ˆØ�‰�TÔØ�‰�eÕð	ô ˜5 &Ó)ò ‰ˆˆeÜˆd�ðô ˜5 &Ó)ó ]/‰ˆˆeØˆð �|‰|˜I rÓ*ˆð �|‰|˜G UÓ+ˆØ�|‰|˜G YÓ/ˆØ�|‰|˜M¨;Ó7ˆØ�|‰|˜L¨"Ó-ˆØ�|‰|˜MÐ+BÓCˆØ�|‰|˜KÐ)>Ó?ˆØ�|‰|˜N¨BÓ/ˆð �|‰|Ð1°2Ó6ˆØ�|‰|Ð<¸mÓLˆð �|‰|˜J¨Ó,ˆØ�|‰|˜H cÓ*ˆð �|‰|˜N¨HÓ5ˆð �|‰|Ð-¨}Ó=ˆØ�|‰|Ð3°]ÓCˆð �|‰|Ð2°LÓAˆØ�|‰|˜NÐ,<Ó=ˆØ�|‰|˜HÐ&<Ó=ˆô ˆt�z‰z˜#‹Ó 1Ò$¨-¸4Ñ*?ÐCSÐW[ÑC[Ø  4Ñ'ˆDð  Ñ%Ø—<‘<Ð :Ð<XÓYˆDØ—<‘< 	¨8Ó4ˆDà�z‰z˜#‹ˆð ˜ÑØ˜4ÑØ)¨TÑ1Ø+¨tÑ3Ø Ñ$ä�K‰K˜) C§H¡H¨T£NÐ#3Ð4Ô5ÙàˆØò 	'ˆFØ�|‰|Ð,¨fÔ5Ø Ÿh™h y°&Ó9‘à%˜h�à˜1‰~ Ò)¨[¸©^¸wÒ-FÜ! '¨8Ó4‘Ø˜Q‘ =Ò0°KÀ±NÀfÒ4LÜ! '¨6Ó2‘Ø˜Q‘Ð#3Ò3Ü! '¨8Ó4‘Ø˜Q‘ 7Ò*Ü! '¨<Ó8‘ðÜ% g¨{¸1©~Ó>�Gô �;Ó 1Ó$Ü˜+ a™.Ó)�Ø! #™,‘ð-	'ð0 �#�$ˆ<˜=Ò(Ü˜g xÓ0‰GØ�xÒØ—L‘L Ó'ˆEð	Ø�}‰} §¡Ò+Ü  >°'·-±-°Ð@QÐRW×R]ÑR]ÐQ^Ð^iÐ!jÓkÐkð ,ô
 	Ð*¨4¨&°°}°oÐFÔGÜ×'Ñ'¨Ó.ˆŽð{]/ð~ €Løôi ò Ü�‰ðQô	
ð 	ðûô@ &ò Ü—K‘K )¨C¯H©H°T«NÐ+;Ð <Ô=Úðûô ò 	Ø�FŠF�w—}‘} e§k¡kÐ2Ñ2�FØûð	ús5   ‚Q Í3Q%Ï?RÑ Q"Ñ%0RÒRÒ	SÒ%,SÓSc                   óÐ   ‡ — e Zd ZdZdefˆ fd„Z	 	 	 	 	 ddeej                     deej                     deej                     deej                     de
d	ej                  fd
„Zˆ xZS )ÚAlbertEmbeddingszQ
    Construct the embeddings from word, position and token_type embeddings.
    re   c                 ó>  •— t         ‰| �  «        t        j                  |j                  |j
                  |j                  ¬«      | _        t        j                  |j                  |j
                  «      | _	        t        j                  |j                  |j
                  «      | _        t        j                  |j
                  |j                  ¬«      | _        t        j                  |j                  «      | _        | j#                  dt%        j&                  |j                  «      j)                  d«      d¬«       t+        |dd«      | _        | j#                  d	t%        j.                  | j0                  j3                  «       t$        j4                  ¬
«      d¬«       y )N)Úpadding_idx©ÚepsÚposition_ids)r"   éÿÿÿÿF)Ú
persistentÚposition_embedding_typeÚabsoluteÚtoken_type_ids©Údtype)ÚsuperÚ__init__r	   Ú	EmbeddingÚ
vocab_sizeÚembedding_sizeÚpad_token_idÚword_embeddingsÚmax_position_embeddingsÚposition_embeddingsÚtype_vocab_sizeÚtoken_type_embeddingsr,   Úlayer_norm_epsÚDropoutÚhidden_dropout_probÚdropoutÚregister_bufferra   ÚarangeÚexpandrZ   r€   Úzerosr}   ÚsizeÚlong©Úselfre   Ú	__class__s     €ru   r†   zAlbertEmbeddings.__init__À   s1  ø€ Ü‰ÑÔÜ!Ÿ|™|¨F×,=Ñ,=¸v×?TÑ?TÐbh×buÑbuÔvˆÔÜ#%§<¡<°×0NÑ0NÐPV×PeÑPeÓ#fˆÔ Ü%'§\¡\°&×2HÑ2HÈ&×J_ÑJ_Ó%`ˆÔ"ô Ÿ™ f×&;Ñ&;À×AVÑAVÔWˆŒÜ—z‘z &×"<Ñ"<Ó=ˆŒð 	×ÑØœEŸL™L¨×)GÑ)GÓH×OÑOÐPWÓXÐejð 	ô 	
ô (/¨vÐ7PÐR\Ó']ˆÔ$Ø×ÑØœeŸk™k¨$×*;Ñ*;×*@Ñ*@Ó*BÌ%Ï*É*ÔUÐbgð 	õ 	
ó    Ú	input_idsr‚   r}   Úinputs_embedsÚpast_key_values_lengthÚreturnc                 óZ  — |�|j                  «       }n|j                  «       d d }|d   }|€| j                  d d …|||z   …f   }|€st        | d«      r-| j                  d d …d |…f   }|j	                  |d   |«      }	|	}n:t        j                  |t
        j                  | j                  j                  ¬«      }|€| j                  |«      }| j                  |«      }
||
z   }| j                  dk(  r| j                  |«      }||z  }| j                  |«      }| j                  |«      }|S )Nr~   r"   r‚   r   ©r„   Údevicer�   )r˜   r}   Úhasattrr‚   r–   ra   r—   r™   r¤   r‹   r�   r€   r�   r,   r“   )r›   rž   r‚   r}   rŸ   r    Úinput_shapeÚ
seq_lengthÚbuffered_token_type_idsÚ buffered_token_type_ids_expandedr�   r0   r�   s                ru   ÚforwardzAlbertEmbeddings.forwardÕ   sH  € ð Ð Ø#Ÿ.™.Ó*‰Kà'×,Ñ,Ó.¨s°Ð3ˆKà  ‘^ˆ
àÐØ×,Ñ,ªQÐ0FÈÐVlÑIlÐ0lÐ-lÑmˆLð
 Ð!Ü�tÐ-Ô.Ø*.×*=Ñ*=ºaÀÀ*À¸nÑ*MÐ'Ø3J×3QÑ3QÐR]Ð^_ÑR`ÐblÓ3mÐ0Ø!A‘ä!&§¡¨[ÄÇ
Á
ÐSW×SdÑSd×SkÑSkÔ!l�àÐ Ø ×0Ñ0°Ó;ˆMØ $× :Ñ :¸>Ó JÐà"Ð%:Ñ:ˆ
Ø×'Ñ'¨:Ò5Ø"&×":Ñ":¸<Ó"HÐØÐ-Ñ-ˆJØ—^‘^ JÓ/ˆ
Ø—\‘\ *Ó-ˆ
ØÐr�   )NNNNr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r†   r   ra   Ú
LongTensorÚFloatTensorr\   ÚTensorrª   Ú__classcell__©rœ   s   @ru   rx   rx   »   s”   ø„ ñð
˜|õ 
ð. 15Ø59Ø37Ø59Ø&'ñ'à˜E×,Ñ,Ñ-ð'ð ! ×!1Ñ!1Ñ2ð'ð ˜u×/Ñ/Ñ0ð	'ð
   × 1Ñ 1Ñ2ð'ð !$ð'ð 
�‰÷'r�   rx   c                   ó4  ‡ — e Zd Zdefˆ fd„Zdej                  dej                  fd„Zdee	   ddfd„Z
	 	 	 dd	ej                  d
eej                     deej                     dedeeej                     eej                  ej                  f   f   f
d„Zˆ xZS )ÚAlbertAttentionre   c                 óì  •— t         ‰| �  «        |j                  |j                  z  dk7  r1t	        |d«      s%t        d|j                  › d|j                  › �«      ‚|j                  | _        |j                  | _        |j                  |j                  z  | _        | j                  | j                  z  | _        t        j                  |j                  | j                  «      | _
        t        j                  |j                  | j                  «      | _        t        j                  |j                  | j                  «      | _        t        j                  |j                  «      | _        t        j                  |j                   «      | _        t        j                  |j                  |j                  «      | _        t        j&                  |j                  |j(                  ¬«      | _        t+        «       | _        t/        |dd«      | _        | j0                  dk(  s| j0                  d	k(  rG|j2                  | _        t        j4                  d
|j2                  z  dz
  | j                  «      | _        y y )Nr   r‰   zThe hidden size (z6) is not a multiple of the number of attention heads (r{   r€   r�   Úrelative_keyÚrelative_key_queryrC   r"   )r…   r†   Úhidden_sizeÚnum_attention_headsr¥   r_   Úattention_head_sizeÚall_head_sizer	   ÚLinearÚqueryÚkeyÚvaluer‘   Úattention_probs_dropout_probÚattention_dropoutr’   Úoutput_dropoutÚdenser,   r�   ÚsetÚpruned_headsrZ   r€   rŒ   r‡   Údistance_embeddingrš   s     €ru   r†   zAlbertAttention.__init__   sï  ø€ Ü‰ÑÔØ×Ñ × :Ñ :Ñ:¸aÒ?ÌÐPVÐXhÔHiÜØ# F×$6Ñ$6Ð#7ð 8Ø ×4Ñ4Ð5ð7óð ð
 $*×#=Ñ#=ˆÔ Ø!×-Ñ-ˆÔØ#)×#5Ñ#5¸×9SÑ9SÑ#SˆÔ Ø!×5Ñ5¸×8PÑ8PÑPˆÔä—Y‘Y˜v×1Ñ1°4×3EÑ3EÓFˆŒ
Ü—9‘9˜V×/Ñ/°×1CÑ1CÓDˆŒÜ—Y‘Y˜v×1Ñ1°4×3EÑ3EÓFˆŒ
ä!#§¡¨F×,OÑ,OÓ!PˆÔÜ Ÿj™j¨×)CÑ)CÓDˆÔÜ—Y‘Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
ÜŸ™ f×&8Ñ&8¸f×>SÑ>SÔTˆŒÜ›EˆÔä'.¨vÐ7PÐR\Ó']ˆÔ$Ø×'Ñ'¨>Ò9¸T×=YÑ=YÐ]qÒ=qØ+1×+IÑ+IˆDÔ(Ü&(§l¡l°1°v×7UÑ7UÑ3UÐXYÑ3YÐ[_×[sÑ[sÓ&tˆDÕ#ð >rr�   Úxr¡   c                 ó¤   — |j                  «       d d | j                  | j                  fz   }|j                  |«      }|j	                  dddd«      S )Nr~   r   rC   r"   r   )r˜   rº   r»   ÚviewÚpermute)r›   rÈ   Únew_x_shapes      ru   Útranspose_for_scoresz$AlbertAttention.transpose_for_scores  sL   € Ø—f‘f“h˜s �m t×'?Ñ'?À×AYÑAYÐ&ZÑZˆØ�F‰F�;ÓˆØ�y‰y˜˜A˜q !Ó$Ð$r�   ÚheadsNc                 ó  — t        |«      dk(  ry t        || j                  | j                  | j                  «      \  }}t        | j                  |«      | _        t        | j                  |«      | _        t        | j                  |«      | _        t        | j                  |d¬«      | _	        | j                  t        |«      z
  | _        | j                  | j                  z  | _
        | j                  j                  |«      | _        y )Nr   r"   ©Údim)rV   r   rº   r»   rÆ   r   r¾   r¿   rÀ   rÄ   r¼   Úunion)r›   rÎ   Úindexs      ru   Úprune_headszAlbertAttention.prune_heads"  sÐ   € Üˆu‹:˜Š?ØÜ7Ø�4×+Ñ+¨T×-EÑ-EÀt×GXÑGXó
‰ˆˆuô
 (¨¯
©
°EÓ:ˆŒ
Ü% d§h¡h°Ó6ˆŒÜ'¨¯
©
°EÓ:ˆŒ
Ü'¨¯
©
°E¸qÔAˆŒ
ð $(×#;Ñ#;¼cÀ%»jÑ#HˆÔ Ø!×5Ñ5¸×8PÑ8PÑPˆÔØ ×-Ñ-×3Ñ3°EÓ:ˆÕr�   Úhidden_statesÚattention_maskÚ	head_maskÚoutput_attentionsc                 ó”  — | j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }	| j                  |«      }
t	        j
                  ||	j                  dd«      «      }|t        j                  | j                  «      z  }|�||z   }| j                  dk(  s| j                  dk(  �rF|j                  «       d   }t	        j                  |t        j                  |j                  ¬«      j                  dd«      }t	        j                  |t        j                  |j                  ¬«      j                  dd«      }||z
  }| j!                  || j"                  z   dz
  «      }|j%                  |j&                  ¬«      }| j                  dk(  rt	        j(                  d||«      }||z   }nE| j                  dk(  r6t	        j(                  d||«      }t	        j(                  d	|	|«      }||z   |z   }t*        j,                  j/                  |d¬
«      }| j1                  |«      }|�||z  }t	        j
                  ||
«      }|j                  dd«      j3                  d«      }| j5                  |«      }| j7                  |«      }| j9                  ||z   «      }|r||fS |fS )Nr~   éþÿÿÿr·   r¸   r"   r£   rƒ   zbhld,lrd->bhlrzbhrd,lrd->bhlrrÐ   rC   )r¾   r¿   rÀ   rÍ   ra   Úmatmulr]   ÚmathÚsqrtr»   r€   r˜   r•   r™   r¤   rÊ   rÇ   rŒ   Útor„   Úeinsumr	   Ú
functionalÚsoftmaxrÂ   ÚflattenrÄ   rÃ   r,   )r›   rÕ   rÖ   r×   rØ   Úmixed_query_layerÚmixed_key_layerÚmixed_value_layerÚquery_layerÚ	key_layerÚvalue_layerÚattention_scoresr§   Úposition_ids_lÚposition_ids_rÚdistanceÚpositional_embeddingÚrelative_position_scoresÚrelative_position_scores_queryÚrelative_position_scores_keyÚattention_probsÚcontext_layerÚprojected_context_layerÚprojected_context_layer_dropoutÚlayernormed_context_layers                            ru   rª   zAlbertAttention.forward4  s­  € ð !ŸJ™J }Ó5ÐØŸ(™( =Ó1ˆØ ŸJ™J }Ó5Ðà×/Ñ/Ð0AÓBˆØ×-Ñ-¨oÓ>ˆ	Ø×/Ñ/Ð0AÓBˆô !Ÿ<™<¨°Y×5HÑ5HÈÈRÓ5PÓQÐØ+¬d¯i©i¸×8PÑ8PÓ.QÑQÐàÐ%à/°.Ñ@Ðà×'Ñ'¨>Ò9¸T×=YÑ=YÐ]qÓ=qØ&×+Ñ+Ó-¨aÑ0ˆJÜ"Ÿ\™\¨*¼E¿J¹JÈ}×OcÑOcÔd×iÑiÐjlÐnoÓpˆNÜ"Ÿ\™\¨*¼E¿J¹JÈ}×OcÑOcÔd×iÑiÐjkÐmoÓpˆNØ%¨Ñ6ˆHØ#'×#:Ñ#:¸8Àd×FbÑFbÑ;bÐefÑ;fÓ#gÐ Ø#7×#:Ñ#:À×ARÑARÐ#:Ó#SÐ à×+Ñ+¨~Ò=Ü+0¯<©<Ð8HÈ+ÐWkÓ+lÐ(Ø#3Ð6NÑ#NÑ Ø×-Ñ-Ð1EÒEÜ16·±Ð>NÐP[Ð]qÓ1rÐ.Ü/4¯|©|Ð<LÈiÐYmÓ/nÐ,Ø#3Ð6TÑ#TÐWsÑ#sÐ ô Ÿ-™-×/Ñ/Ð0@ÀbÐ/ÓIˆð ×0Ñ0°ÓAˆð Ð Ø-°	Ñ9ˆOäŸ™ _°kÓBˆØ%×/Ñ/°°1Ó5×=Ñ=¸aÓ@ˆà"&§*¡*¨]Ó";ÐØ*.×*=Ñ*=Ð>UÓ*VÐ'Ø$(§N¡N°=ÐCbÑ3bÓ$cÐ!Ù?PÐ)¨?Ð;ÐrÐWpÐVrÐrr�   ©NNF)r«   r¬   r­   r#   r†   ra   r±   rÍ   r   r\   rÔ   r   r°   Úboolr   r   rª   r²   r³   s   @ru   rµ   rµ   ÿ   sÈ   ø„ ðu˜|õ uð:% e§l¡lð %°u·|±|ó %ð
;  c¡ð ;¨tó ;ð* 7;Ø15Ø"'ñ8sà—|‘|ð8sð ! ×!2Ñ!2Ñ3ð8sð ˜E×-Ñ-Ñ.ð	8sð
  ð8sð 
ˆu�U—\‘\Ñ" E¨%¯,©,¸¿¹Ð*DÑ$EÐEÑ	F÷8sr�   rµ   c                   óä   ‡ — e Zd Zˆ fd„Z	 	 	 ddej
                  deej                     deej                     dede	e
ej
                     e
ej
                  ej
                  f   f   f
ˆ fd„Zˆ xZS )	ÚAlbertSdpaAttentionc                 ó^   •— t         ‰| �  |«       |j                  | _        t         | _        y ©N)r…   r†   rÁ   Údropout_probr   Úrequire_contiguous_qkvrš   s     €ru   r†   zAlbertSdpaAttention.__init__p  s)   ø€ Ü‰Ñ˜Ô Ø"×?Ñ?ˆÔÜ*LÐ&LˆÕ#r�   rÕ   rÖ   r×   rØ   r¡   c                 ól  •— | j                   dk7  s|s|�'t        j                  d«       t        ‰| �  ||||«      S |j                  «       \  }}}| j                  | j                  |«      «      }| j                  | j                  |«      «      }	| j                  | j                  |«      «      }
| j                  rK|j                  j                  dk(  r2|�0|j                  «       }|	j                  «       }	|
j                  «       }
t        j                  j                   j#                  ||	|
|| j$                  r| j&                  ndd¬«      }|j)                  dd«      }|j+                  ||| j,                  «      }| j/                  |«      }| j1                  |«      }| j3                  ||z   «      }|fS )	Nr�   a²  AlbertSdpaAttention is used but `torch.nn.functional.scaled_dot_product_attention` does not support non-absolute `position_embedding_type` or `output_attentions=True` or `head_mask`. Falling back to the eager attention implementation, but specifying the eager implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.Úcudaç        F)r¾   r¿   rÀ   Ú	attn_maskÚ	dropout_pÚ	is_causalr"   rC   )r€   rI   Úwarningr…   rª   r˜   rÍ   r¾   r¿   rÀ   rý   r¤   ÚtypeÚ
contiguousra   r	   rà   Úscaled_dot_product_attentionÚtrainingrü   r]   Úreshaper¼   rÄ   rÃ   r,   )r›   rÕ   rÖ   r×   rØ   Ú
batch_sizeÚseq_lenÚ_ræ   rç   rè   Úattention_outputró   rô   rõ   rœ   s                  €ru   rª   zAlbertSdpaAttention.forwardu  s¤  ø€ ð ×'Ñ'¨:Ò5Ñ9JÈiÐNcÜ�N‰NðHôô ‘7‘? =°.À)ÐM^Ó_Ð_à!.×!3Ñ!3Ó!5Ñˆ
�G˜QØ×/Ñ/°·
±
¸=Ó0IÓJˆØ×-Ñ-¨d¯h©h°}Ó.EÓFˆ	Ø×/Ñ/°·
±
¸=Ó0IÓJˆð
 ×&Ò&¨;×+=Ñ+=×+BÑ+BÀfÒ+LÐQ_ÐQkØ%×0Ñ0Ó2ˆKØ!×,Ñ,Ó.ˆIØ%×0Ñ0Ó2ˆKä Ÿ8™8×.Ñ.×KÑKØØØØ$Ø+/¯=ª=�d×'Ò'¸cØð Ló 
Ðð ,×5Ñ5°a¸Ó;ÐØ+×3Ñ3°JÀÈ×I[ÑI[Ó\Ðà"&§*¡*Ð-=Ó">ÐØ*.×*=Ñ*=Ð>UÓ*VÐ'Ø$(§N¡N°=ÐCbÑ3bÓ$cÐ!Ø)Ð+Ð+r�   rö   )r«   r¬   r­   r†   ra   r±   r   r°   r÷   r   r   rª   r²   r³   s   @ru   rù   rù   o  s�   ø„ ôMð 7;Ø15Ø"'ñ-,à—|‘|ð-,ð ! ×!2Ñ!2Ñ3ð-,ð ˜E×-Ñ-Ñ.ð	-,ð
  ð-,ð 
ˆu�U—\‘\Ñ" E¨%¯,©,¸¿¹Ð*DÑ$EÐEÑ	F÷-,ñ -,r�   rù   )ÚeagerÚsdpac                   ó   ‡ — e Zd Zdefˆ fd„Z	 	 	 	 ddej                  deej                     deej                     de	de	de
ej                  ej                  f   fd	„Zd
ej                  dej                  fd„Zˆ xZS )ÚAlbertLayerre   c                 ó.  •— t         ‰| �  «        || _        |j                  | _        d| _        t        j                  |j                  |j                  ¬«      | _	        t        |j                     |«      | _        t        j                  |j                  |j                  «      | _        t        j                  |j                  |j                  «      | _        t"        |j$                     | _        t        j(                  |j*                  «      | _        y )Nr"   r{   )r…   r†   re   Úchunk_size_feed_forwardÚseq_len_dimr	   r,   r¹   r�   r+   ÚALBERT_ATTENTION_CLASSESÚ_attn_implementationr)   r½   Úintermediate_sizer'   Ú
ffn_outputr   Ú
hidden_actÚ
activationr‘   r’   r“   rš   s     €ru   r†   zAlbertLayer.__init__¬  sÅ   ø€ Ü‰ÑÔàˆŒØ'-×'EÑ'EˆÔ$ØˆÔÜ%'§\¡\°&×2DÑ2DÈ&×J_ÑJ_Ô%`ˆÔ"Ü1°&×2MÑ2MÑNÈvÓVˆŒÜ—9‘9˜V×/Ñ/°×1IÑ1IÓJˆŒÜŸ)™) F×$<Ñ$<¸f×>PÑ>PÓQˆŒÜ  ×!2Ñ!2Ñ3ˆŒÜ—z‘z &×"<Ñ"<Ó=ˆ�r�   rÕ   rÖ   r×   rØ   Úoutput_hidden_statesr¡   c                 óÈ   — | j                  ||||«      }t        | j                  | j                  | j                  |d   «      }| j                  ||d   z   «      }|f|dd  z   S )Nr   r"   )r)   r   Úff_chunkr  r  r+   )r›   rÕ   rÖ   r×   rØ   r  r  r  s           ru   rª   zAlbertLayer.forward¹  sy   € ð  Ÿ>™>¨-¸ÈÐTeÓfÐä.Ø�M‰MØ×(Ñ(Ø×ÑØ˜QÑó	
ˆ
ð ×2Ñ2°:Ð@PÐQRÑ@SÑ3SÓTˆàÐÐ"2°1°2Ð"6Ñ6Ð6r�   r  c                 ól   — | j                  |«      }| j                  |«      }| j                  |«      }|S rû   )r'   r  r  )r›   r  r  s      ru   r  zAlbertLayer.ff_chunkÍ  s3   € Ø—X‘XÐ.Ó/ˆ
Ø—_‘_ ZÓ0ˆ
Ø—_‘_ ZÓ0ˆ
ØÐr�   ©NNFF)r«   r¬   r­   r#   r†   ra   r±   r   r°   r÷   r   rª   r  r²   r³   s   @ru   r  r  «  s£   ø„ ð>˜|õ >ð  7;Ø15Ø"'Ø%*ñ7à—|‘|ð7ð ! ×!2Ñ!2Ñ3ð7ð ˜E×-Ñ-Ñ.ð	7ð
  ð7ð #ð7ð 
ˆu�|‰|˜UŸ\™\Ð)Ñ	*ó7ð(¨¯©ð ¸%¿,¹,÷ r�   r  c                   óØ   ‡ — e Zd Zdefˆ fd„Z	 	 	 	 ddej                  deej                     deej                     de	de	de
eej                  e
ej                     f   d	f   fd
„Zˆ xZS )ÚAlbertLayerGroupre   c                 ó´   •— t         ‰| �  «        t        j                  t	        |j
                  «      D �cg c]  }t        |«      ‘Œ c}«      | _        y c c}w rû   )r…   r†   r	   Ú
ModuleListÚrangeÚinner_group_numr  Úalbert_layers©r›   re   r  rœ   s      €ru   r†   zAlbertLayerGroup.__init__Õ  s=   ø€ Ü‰ÑÔäŸ]™]ÌÈv×OeÑOeÓIfÖ+gÀA¬K¸Õ,?Ò+gÓhˆÕùÒ+gs   ¶ArÕ   rÖ   r×   rØ   r  r¡   .c                 ó¼   — d}d}t        | j                  «      D ],  \  }}	 |	||||   |«      }
|
d   }|r	||
d   fz   }|sŒ'||fz   }Œ. |f}|r||fz   }|r||fz   }|S )N© r   r"   )Ú	enumerater&  )r›   rÕ   rÖ   r×   rØ   r  Úlayer_hidden_statesÚlayer_attentionsÚlayer_indexÚalbert_layerÚlayer_outputÚoutputss               ru   rª   zAlbertLayerGroup.forwardÚ  s¨   € ð !ÐØÐä)2°4×3EÑ3EÓ)Fò 	MÑ%ˆK˜Ù'¨°~ÀyÐQ\ÑG]Ð_pÓqˆLØ(¨™OˆMá Ø#3°|ÀA±Ð6HÑ#HÐ â#Ø&9¸]Ð<LÑ&LÑ#ð	Mð !Ð"ˆÙØÐ!4Ð 6Ñ6ˆGÙØÐ!1Ð 3Ñ3ˆGØˆr�   r  )r«   r¬   r­   r#   r†   ra   r±   r   r°   r÷   r   r   rª   r²   r³   s   @ru   r!  r!  Ô  s™   ø„ ði˜|õ ið 7;Ø15Ø"'Ø%*ñà—|‘|ðð ! ×!2Ñ!2Ñ3ðð ˜E×-Ñ-Ñ.ð	ð
  ðð #ðð 
ˆu�U—\‘\ 5¨¯©Ñ#6Ð6Ñ7¸Ð<Ñ	=÷r�   r!  c                   ó¦   ‡ — e Zd Zdefˆ fd„Z	 	 	 	 	 ddej                  deej                     deej                     de	de	de	d	e
eef   fd
„Zˆ xZS )ÚAlbertTransformerre   c                 ó   •— t         ‰| �  «        || _        t        j                  |j
                  |j                  «      | _        t        j                  t        |j                  «      D �cg c]  }t        |«      ‘Œ c}«      | _        y c c}w rû   )r…   r†   re   r	   r½   r‰   r¹   Úembedding_hidden_mapping_inr#  r$  Únum_hidden_groupsr!  Úalbert_layer_groupsr'  s      €ru   r†   zAlbertTransformer.__init__ø  sf   ø€ Ü‰ÑÔàˆŒÜ+-¯9©9°V×5JÑ5JÈF×L^ÑL^Ó+_ˆÔ(Ü#%§=¡=ÔTYÐZ`×ZrÑZrÓTsÖ1tÈqÔ2BÀ6Õ2JÒ1tÓ#uˆÕ ùÒ1ts   Á,BrÕ   rÖ   r×   rØ   r  Úreturn_dictr¡   c           	      ód  — | j                  |«      }|r|fnd }|rdnd }|€d g| j                  j                  z  n|}t        | j                  j                  «      D ]®  }	t	        | j                  j                  | j                  j
                  z  «      }
t	        |	| j                  j                  | j                  j
                  z  z  «      } | j                  |   |||||
z  |dz   |
z   ||«      }|d   }|r||d   z   }|sŒ©||fz   }Œ° |st        d„ |||fD «       «      S t        |||¬«      S )Nr)  r"   r   r~   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wrû   r)  )Ú.0Úvs     ru   ú	<genexpr>z,AlbertTransformer.forward.<locals>.<genexpr>&  s   è ø€ Òh˜qÐZ[ÑZgœÑhùs   ‚Š)Úlast_hidden_staterÕ   Ú
attentions)	r4  re   Únum_hidden_layersr$  r\   r5  r6  Útupler   )r›   rÕ   rÖ   r×   rØ   r  r7  Úall_hidden_statesÚall_attentionsÚiÚlayers_per_groupÚ	group_idxÚlayer_group_outputs                ru   rª   zAlbertTransformer.forwardÿ  sX  € ð ×8Ñ8¸ÓGˆá0D˜]Ñ,È$ÐÙ0™°dˆà>GÐ>O�T�F˜TŸ[™[×:Ñ:Ò:ÐU^ˆ	ä�t—{‘{×4Ñ4Ó5ò 	IˆAä" 4§;¡;×#@Ñ#@À4Ç;Á;×C`ÑC`Ñ#`ÓaÐô ˜A §¡×!>Ñ!>ÀÇÁ×A^ÑA^Ñ!^Ñ_Ó`ˆIà!D ×!9Ñ!9¸)Ñ!DØØØ˜)Ð&6Ñ6¸)Àa¹-ÐK[Ñ9[Ð\Ø!Ø$ó"Ðð /¨qÑ1ˆMá Ø!/Ð2DÀRÑ2HÑ!H�â#Ø$5¸Ð8HÑ$HÑ!ð)	Iñ, ÜÑh ]Ð4EÀ~Ð$VÔhÓhÐhÜØ+Ð;LÐYgô
ð 	
r�   )NNFFT)r«   r¬   r­   r#   r†   ra   r±   r   r°   r÷   r   r   r   rª   r²   r³   s   @ru   r2  r2  ÷  s�   ø„ ðv˜|õ vð 7;Ø15Ø"'Ø%*Ø ñ*
à—|‘|ð*
ð ! ×!2Ñ!2Ñ3ð*
ð ˜E×-Ñ-Ñ.ð	*
ð
  ð*
ð #ð*
ð ð*
ð 
ˆ Ð%Ñ	&÷*
r�   r2  c                   ó&   — e Zd ZdZeZeZdZdZ	d„ Z
y)ÚAlbertPreTrainedModelz†
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    ÚalbertTc                 ól  — t        |t        j                  «      rm|j                  j                  j                  d| j                  j                  ¬«       |j                  �%|j                  j                  j                  «        yyt        |t        j                  «      rz|j                  j                  j                  d| j                  j                  ¬«       |j                  �2|j                  j                  |j                     j                  «        yyt        |t        j                  «      rJ|j                  j                  j                  «        |j                  j                  j                  d«       yt        |t        «      r%|j                  j                  j                  «        yy)zInitialize the weights.r   )ÚmeanÚstdNç      ð?)Ú
isinstancer	   r½   r7   rc   Únormal_re   Úinitializer_ranger@   Úzero_r‡   rz   r,   Úfill_ÚAlbertMLMHead)r›   Úmodules     ru   Ú_init_weightsz#AlbertPreTrainedModel._init_weights7  s&  € ä�fœbŸi™iÔ(ð �M‰M×Ñ×&Ñ&¨C°T·[±[×5RÑ5RÐ&ÔSØ�{‰{Ð&Ø—‘× Ñ ×&Ñ&Õ(ð 'ä˜¤§¡Ô-Ø�M‰M×Ñ×&Ñ&¨C°T·[±[×5RÑ5RÐ&ÔSØ×!Ñ!Ð-Ø—‘×"Ñ" 6×#5Ñ#5Ñ6×<Ñ<Õ>ð .ä˜¤§¡Ô-Ø�K‰K×Ñ×"Ñ"Ô$Ø�M‰M×Ñ×$Ñ$ SÕ)Ü˜¤Ô.Ø�K‰K×Ñ×"Ñ"Õ$ð /r�   N)r«   r¬   r­   r®   r#   Úconfig_classrv   Úload_tf_weightsÚbase_model_prefixÚ_supports_sdparU  r)  r�   ru   rH  rH  ,  s#   „ ñð
  €LØ/€OØ ÐØ€Nó%r�   rH  c                   óæ   — e Zd ZU dZdZeej                     ed<   dZ	eej                     ed<   dZ
eej                     ed<   dZeeej                        ed<   dZeeej                        ed<   y)ÚAlbertForPreTrainingOutputaQ  
    Output type of [`AlbertForPreTraining`].

    Args:
        loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
            Total loss as the sum of the masked language modeling loss and the next sequence prediction
            (classification) loss.
        prediction_logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
            Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
        sop_logits (`torch.FloatTensor` of shape `(batch_size, 2)`):
            Prediction scores of the next sequence prediction (classification) head (scores of True/False continuation
            before SoftMax).
        hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
            Tuple of `torch.FloatTensor` (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(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
            Tuple of `torch.FloatTensor` (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.
    NÚlossÚprediction_logitsÚ
sop_logitsrÕ   r>  )r«   r¬   r­   r®   r\  r   ra   r°   Ú__annotations__r]  r^  rÕ   r   r>  r)  r�   ru   r[  r[  J  s}   … ñð2 )-€Dˆ(�5×$Ñ$Ñ
%Ó,Ø59Ð�x × 1Ñ 1Ñ2Ó9Ø.2€J�˜×*Ñ*Ñ+Ó2Ø8<€M�8˜E %×"3Ñ"3Ñ4Ñ5Ó<Ø59€J�˜˜u×0Ñ0Ñ1Ñ2Ô9r�   r[  a:  

    This model inherits from [`PreTrainedModel`]. 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 PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Args:
        config ([`AlbertConfig`]): 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.
a5
  
    Args:
        input_ids (`torch.LongTensor` 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 (`torch.FloatTensor` of shape `({0})`, *optional*):
            Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

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

            [What are attention masks?](../glossary#attention-mask)
        token_type_ids (`torch.LongTensor` 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 (`torch.LongTensor` of shape `({0})`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.max_position_embeddings - 1]`.

            [What are position IDs?](../glossary#position-ids)
        head_mask (`torch.FloatTensor` 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 (`torch.FloatTensor` 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.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
z`The bare ALBERT Model transformer outputting raw hidden-states without any specific head on top.c                   óâ  ‡ — e Zd ZeZdZddedefˆ fd„Zdej                  fd„Z
dej                  ddfd	„Zd
eeee   f   ddfd„Z eej%                  d«      «       eeee¬«      	 	 	 	 	 	 	 	 	 ddeej2                     deej4                     deej2                     deej2                     deej4                     deej4                     dee   dee   dee   deeef   fd„«       «       Zˆ xZS )ÚAlbertModelrI  re   Úadd_pooling_layerc                 óˆ  •— t         ‰| �  |«       || _        t        |«      | _        t        |«      | _        |rIt        j                  |j                  |j                  «      | _
        t        j                  «       | _        nd | _
        d | _        |j                  | _        |j                  | _        | j!                  «        y rû   )r…   r†   re   rx   r0   r2  Úencoderr	   r½   r¹   r.   ÚTanhÚpooler_activationr  Úattn_implementationr€   Ú	post_init)r›   re   rb  rœ   s      €ru   r†   zAlbertModel.__init__¶  s•   ø€ Ü‰Ñ˜Ô àˆŒÜ*¨6Ó2ˆŒÜ(¨Ó0ˆŒÙÜŸ)™) F×$6Ñ$6¸×8JÑ8JÓKˆDŒKÜ%'§W¡W£YˆDÕ"àˆDŒKØ%)ˆDÔ"à#)×#>Ñ#>ˆÔ Ø'-×'EÑ'EˆÔ$ð 	�‰Õr�   r¡   c                 ó.   — | j                   j                  S rû   ©r0   r‹   ©r›   s    ru   Úget_input_embeddingsz AlbertModel.get_input_embeddingsÉ  s   € Ø�‰×.Ñ.Ð.r�   rÀ   Nc                 ó&   — || j                   _        y rû   rj  )r›   rÀ   s     ru   Úset_input_embeddingsz AlbertModel.set_input_embeddingsÌ  s   € Ø*/ˆ�‰Õ'r�   Úheads_to_prunec                 ó@  — |j                  «       D ]‹  \  }}t        || j                  j                  z  «      }t        ||| j                  j                  z  z
  «      }| j                  j
                  |   j                  |   j                  j                  |«       Œ� y)aÖ  
        Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer} ALBERT has
        a different architecture in that its layers are shared across groups, which then has inner groups. If an ALBERT
        model has 12 hidden layers and 2 hidden groups, with two inner groups, there is a total of 4 different layers.

        These layers are flattened: the indices [0,1] correspond to the two inner groups of the first hidden layer,
        while [2,3] correspond to the two inner groups of the second hidden layer.

        Any layer with in index other than [0,1,2,3] will result in an error. See base class PreTrainedModel for more
        information about head pruning
        N)	Úitemsr\   re   r%  rd  r6  r&  r)   rÔ   )r›   ro  ÚlayerrÎ   rE  Úinner_group_idxs         ru   Ú_prune_headszAlbertModel._prune_headsÏ  sˆ   € ð +×0Ñ0Ó2ò 	t‰LˆE�5Ü˜E D§K¡K×$?Ñ$?Ñ?Ó@ˆIÜ! %¨)°d·k±k×6QÑ6QÑ*QÑ"QÓRˆOØ�L‰L×,Ñ,¨YÑ7×EÑEÀoÑV×`Ñ`×lÑlÐmrÕsñ	tr�   úbatch_size, sequence_length©Ú
checkpointÚoutput_typerV  rž   rÖ   r‚   r}   r×   rŸ   rØ   r  r7  c
                 ót  — |�|n| j                   j                  }|�|n| j                   j                  }|	�|	n| j                   j                  }	|�|�t	        d«      ‚|�#| j                  ||«       |j                  «       }
n!|�|j                  «       d d }
nt	        d«      ‚|
\  }}|�|j                  n|j                  }|€t        j                  |
|¬«      }|€pt        | j                  d«      r4| j                  j                  d d …d |…f   }|j                  ||«      }|}n&t        j                  |
t        j                  |¬«      }| j                  ||||¬«      }| j                   dk(  xr | j"                  d	k(  xr	 |d u xr | }|rt%        ||j&                  |¬
«      }nk|j)                  d«      j)                  d«      }|j+                  | j&                  ¬«      }d|z
  t        j,                  | j&                  «      j.                  z  }| j1                  || j                   j2                  «      }| j5                  ||||||	¬«      }|d   }| j6                  �'| j9                  | j7                  |d d …df   «      «      nd }|	s
||f|dd  z   S t;        |||j<                  |j>                  ¬«      S )NzDYou cannot specify both input_ids and inputs_embeds at the same timer~   z5You have to specify either input_ids or inputs_embeds)r¤   r‚   r£   )r}   r‚   rŸ   r  r�   )Útgt_lenr"   rC   rƒ   rM  )r×   rØ   r  r7  r   )r=  Úpooler_outputrÕ   r>  ) re   rØ   r  Úuse_return_dictr_   Ú%warn_if_padding_and_no_attention_maskr˜   r¤   ra   Úonesr¥   r0   r‚   r–   r—   r™   rg  r€   r   r„   Ú	unsqueezerÞ   ÚfinfoÚminÚget_head_maskr?  rd  r.   rf  r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   rØ   r  r7  r¦   r
  r§   r¤   r¨   r©   Úembedding_outputÚuse_sdpa_attention_maskÚextended_attention_maskÚencoder_outputsÚsequence_outputÚpooled_outputs                         ru   rª   zAlbertModel.forwardà  sä  € ð$ 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆàÐ  ]Ð%>ÜÐcÓdÐdØÐ"Ø×6Ñ6°yÀ.ÔQØ#Ÿ.™.Ó*‰KØÐ&Ø'×,Ñ,Ó.¨s°Ð3‰KäÐTÓUÐUà!,Ñˆ
�JØ%.Ð%:�×!Ò!À×@TÑ@TˆàÐ!Ü"ŸZ™Z¨¸FÔCˆNØÐ!Ü�t—‘Ð(8Ô9Ø*.¯/©/×*HÑ*HÊÈKÈZÈKÈÑ*XÐ'Ø3J×3QÑ3QÐR\Ð^hÓ3iÐ0Ø!A‘ä!&§¡¨[ÄÇ
Á
ÐSYÔ!Z�àŸ?™?Ø LÀÐ_lð +ó 
Ðð
 ×$Ñ$¨Ñ.ò &Ø×,Ñ,°
Ñ:ò&à˜TÐ!ò&ð &Ð%ð	 	 ñ #Ü&IØÐ 0× 6Ñ 6À
ô'Ñ#ð '5×&>Ñ&>¸qÓ&A×&KÑ&KÈAÓ&NÐ#Ø&=×&@Ñ&@ÀtÇzÁzÐ&@Ó&RÐ#Ø'*Ð-DÑ'DÌÏÉÐTX×T^ÑT^ÓH_×HcÑHcÑ&cÐ#à×&Ñ& y°$·+±+×2OÑ2OÓPˆ	àŸ,™,ØØ#ØØ/Ø!5Ø#ð 'ó 
ˆð *¨!Ñ,ˆàVZ×VaÑVaÐVm˜×.Ñ.¨t¯{©{¸?Ê1ÈaÈ4Ñ;PÓ/QÔRÐswˆáØ# ]Ð3°oÀaÀbÐ6IÑIÐIä)Ø-Ø'Ø)×7Ñ7Ø&×1Ñ1ô	
ð 	
r�   )T)	NNNNNNNNN)r«   r¬   r­   r#   rV  rX  r÷   r†   r	   r‡   rl  rn  r   r\   r   rt  r   ÚALBERT_INPUTS_DOCSTRINGÚformatr   Ú_CHECKPOINT_FOR_DOCr   Ú_CONFIG_FOR_DOCr   ra   r¯   r°   r   r   rª   r²   r³   s   @ru   ra  ra  ®  sŽ  ø„ ð
  €LØ Ðñ˜|ð Àõ ð&/ b§l¡ló /ð0¨"¯,©,ð 0¸4ó 0ðt¨4°°T¸#±Y°Ñ+?ð tÀDó tñ" +Ð+B×+IÑ+IÐJgÓ+hÓiÙØ&Ø.Ø$ôð 15Ø6:Ø59Ø37Ø15Ø59Ø,0Ø/3Ø&*ñT
à˜E×,Ñ,Ñ-ðT
ð ! ×!2Ñ!2Ñ3ðT
ð ! ×!1Ñ!1Ñ2ð	T
ð
 ˜u×/Ñ/Ñ0ðT
ð ˜E×-Ñ-Ñ.ðT
ð   × 1Ñ 1Ñ2ðT
ð $ D™>ðT
ð ' t™nðT
ð ˜d‘^ðT
ð 
Ð)¨5Ð0Ñ	1òT
óó jôT
r�   ra  z«
    Albert Model with two heads on top as done during the pretraining: a `masked language modeling` head and a
    `sentence order prediction (classification)` head.
    c                   ó  ‡ — e Zd ZddgZdefˆ fd„Zdej                  fd„Zdej                  ddfd	„Z	dej                  fd
„Z eej                  d«      «       eee¬«      	 	 	 	 	 	 	 	 	 	 	 ddeej(                     deej*                     deej(                     deej(                     deej*                     deej*                     deej(                     deej(                     dee   dee   dee   deeef   fd„«       «       Zˆ xZS )ÚAlbertForPreTrainingúpredictions.decoder.biasúpredictions.decoder.weightre   c                 ó¤   •— t         ‰| �  |«       t        |«      | _        t	        |«      | _        t        |«      | _        | j                  «        y rû   )	r…   r†   ra  rI  rS  r/   ÚAlbertSOPHeadÚsop_classifierrh  rš   s     €ru   r†   zAlbertForPreTraining.__init__G  sB   ø€ Ü‰Ñ˜Ô ä! &Ó)ˆŒÜ(¨Ó0ˆÔÜ+¨FÓ3ˆÔð 	�‰Õr�   r¡   c                 ó.   — | j                   j                  S rû   ©r/   Údecoderrk  s    ru   Úget_output_embeddingsz*AlbertForPreTraining.get_output_embeddingsQ  ó   € Ø×Ñ×'Ñ'Ð'r�   Únew_embeddingsNc                 ó&   — || j                   _        y rû   r•  ©r›   r™  s     ru   Úset_output_embeddingsz*AlbertForPreTraining.set_output_embeddingsT  s   € Ø#1ˆ×ÑÕ r�   c                 óB   — | j                   j                  j                  S rû   ©rI  r0   r‹   rk  s    ru   rl  z)AlbertForPreTraining.get_input_embeddingsW  ó   € Ø�{‰{×%Ñ%×5Ñ5Ð5r�   ru  ©rx  rV  rž   rÖ   r‚   r}   r×   rŸ   ÚlabelsÚsentence_order_labelrØ   r  r7  c                 ó$  — |�|n| j                   j                  }| j                  |||||||	|
|¬«	      }|dd \  }}| j                  |«      }| j	                  |«      }d}|�u|�st        «       } ||j                  d| j                   j                  «      |j                  d«      «      } ||j                  dd«      |j                  d«      «      }||z   }|s||f|dd z   }|�|f|z   S |S t        ||||j                  |j                  ¬«      S )a˜  
        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]`
        sentence_order_label (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the next sequence prediction (classification) loss. Input should be a sequence pair
            (see `input_ids` docstring) Indices should be in `[0, 1]`. `0` indicates original order (sequence A, then
            sequence B), `1` indicates switched order (sequence B, then sequence A).

        Returns:

        Example:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("albert/albert-base-v2")
        >>> model = AlbertForPreTraining.from_pretrained("albert/albert-base-v2")

        >>> input_ids = torch.tensor(tokenizer.encode("Hello, my dog is cute", add_special_tokens=True)).unsqueeze(0)
        >>> # Batch size 1
        >>> outputs = model(input_ids)

        >>> prediction_logits = outputs.prediction_logits
        >>> sop_logits = outputs.sop_logits
        ```N©rÖ   r‚   r}   r×   rŸ   rØ   r  r7  rC   r~   )r\  r]  r^  rÕ   r>  )re   r|  rI  r/   r“  r   rÊ   rˆ   r[  rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   r¡  r¢  rØ   r  r7  r0  r‡  rˆ  Úprediction_scoresÚ
sop_scoresÚ
total_lossÚloss_fctÚmasked_lm_lossÚsentence_order_lossÚoutputs                         ru   rª   zAlbertForPreTraining.forwardZ  sM  € ðX &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà—+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð *1°°!¨Ñ&ˆ˜à ×,Ñ,¨_Ó=ÐØ×(Ñ(¨Ó7ˆ
àˆ
ØÐÐ"6Ð"BÜ'Ó)ˆHÙ%Ð&7×&<Ñ&<¸RÀÇÁ×AWÑAWÓ&XÐZ`×ZeÑZeÐfhÓZiÓjˆNÙ"*¨:¯?©?¸2¸qÓ+AÐCW×C\ÑC\Ð]_ÓC`Ó"aÐØ'Ð*=Ñ=ˆJáØ'¨Ð4°w¸q¸r°{ÑBˆFØ/9Ð/E�Z�M FÑ*ÐQÈ6ÐQä)ØØ/Ø!Ø!×/Ñ/Ø×)Ñ)ô
ð 	
r�   ©NNNNNNNNNNN)r«   r¬   r­   Ú_tied_weights_keysr#   r†   r	   r½   r—  rœ  r‡   rl  r   r‰  rŠ  r!   r[  rŒ  r   ra   r¯   r°   r÷   r   r   rª   r²   r³   s   @ru   rŽ  rŽ  =  s£  ø„ ð 5Ð6RÐSÐð˜|õ ð( r§y¡yó (ð2°B·I±Ið 2À$ó 2ð6 b§l¡ló 6ñ +Ð+B×+IÑ+IÐJgÓ+hÓiÙÐ+EÐTcÔdð 15Ø6:Ø59Ø37Ø15Ø59Ø-1Ø;?Ø,0Ø/3Ø&*ñN
à˜E×,Ñ,Ñ-ðN
ð ! ×!2Ñ!2Ñ3ðN
ð ! ×!1Ñ!1Ñ2ð	N
ð
 ˜u×/Ñ/Ñ0ðN
ð ˜E×-Ñ-Ñ.ðN
ð   × 1Ñ 1Ñ2ðN
ð ˜×)Ñ)Ñ*ðN
ð ' u×'7Ñ'7Ñ8ðN
ð $ D™>ðN
ð ' t™nðN
ð ˜d‘^ðN
ð 
Ð)¨5Ð0Ñ	1òN
ó eó jôN
r�   rŽ  c                   ód   ‡ — e Zd Zdefˆ fd„Zdej                  dej                  fd„Zdd„Zˆ xZ	S )rS  re   c                 ó  •— t         ‰| �  «        t        j                  |j                  |j
                  ¬«      | _        t        j                  t        j                  |j                  «      «      | _
        t        j                  |j                  |j                  «      | _        t        j                  |j                  |j                  «      | _        t        |j                      | _        | j                  | j                  _
        y )Nr{   )r…   r†   r	   r,   r‰   r�   Ú	Parameterra   r—   rˆ   r@   r½   r¹   rÄ   r–  r   r  r  rš   s     €ru   r†   zAlbertMLMHead.__init__®  s©   ø€ Ü‰ÑÔäŸ™ f×&;Ñ&;À×AVÑAVÔWˆŒÜ—L‘L¤§¡¨V×->Ñ->Ó!?Ó@ˆŒ	Ü—Y‘Y˜v×1Ñ1°6×3HÑ3HÓIˆŒ
Ü—y‘y ×!6Ñ!6¸×8IÑ8IÓJˆŒÜ  ×!2Ñ!2Ñ3ˆŒØ ŸI™Iˆ�‰Õr�   rÕ   r¡   c                 ó’   — | j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }|}|S rû   )rÄ   r  r,   r–  )r›   rÕ   r¥  s      ru   rª   zAlbertMLMHead.forward¸  sF   € ØŸ
™
 =Ó1ˆØŸ™¨Ó6ˆØŸ™ }Ó5ˆØŸ™ ]Ó3ˆà)Ðà Ð r�   c                 óÌ   — | j                   j                  j                  j                  dk(  r| j                  | j                   _        y | j                   j                  | _        y )NÚmeta)r–  r@   r¤   r  rk  s    ru   Ú_tie_weightszAlbertMLMHead._tie_weightsÂ  sC   € à�<‰<×Ñ×#Ñ#×(Ñ(¨FÒ2Ø $§	¡	ˆD�L‰LÕð Ÿ™×)Ñ)ˆD�Ir�   )r¡   N)
r«   r¬   r­   r#   r†   ra   r±   rª   r´  r²   r³   s   @ru   rS  rS  ­  s/   ø„ ð&˜|õ &ð! U§\¡\ð !°e·l±ló !÷*r�   rS  c                   ó\   ‡ — e Zd Zdefˆ fd„Zdej                  dej                  fd„Zˆ xZS )r’  re   c                 óÈ   •— t         ‰| �  «        t        j                  |j                  «      | _        t        j                  |j                  |j                  «      | _	        y rû   )
r…   r†   r	   r‘   Úclassifier_dropout_probr“   r½   r¹   Ú
num_labelsrB   rš   s     €ru   r†   zAlbertSOPHead.__init__Ì  sB   ø€ Ü‰ÑÔä—z‘z &×"@Ñ"@ÓAˆŒÜŸ)™) F×$6Ñ$6¸×8IÑ8IÓJˆ�r�   rˆ  r¡   c                 óJ   — | j                  |«      }| j                  |«      }|S rû   )r“   rB   )r›   rˆ  Údropout_pooled_outputÚlogitss       ru   rª   zAlbertSOPHead.forwardÒ  s%   € Ø $§¡¨]Ó ;ÐØ—‘Ð!6Ó7ˆØˆr�   )	r«   r¬   r­   r#   r†   ra   r±   rª   r²   r³   s   @ru   r’  r’  Ë  s,   ø„ ðK˜|õ Kð U§\¡\ð °e·l±l÷ r�   r’  z4Albert Model with a `language modeling` head on top.c                   óô  ‡ — e Zd ZddgZˆ fd„Zdej                  fd„Zdej                  ddfd„Zdej                  fd	„Z
 eej                  d
«      «       eee¬«      	 	 	 	 	 	 	 	 	 	 ddeej&                     deej(                     deej&                     deej&                     deej(                     deej(                     deej&                     dee   dee   dee   deeef   fd„«       «       Zˆ xZS )ÚAlbertForMaskedLMr�  r�  c                 óˆ   •— t         ‰| �  |«       t        |d¬«      | _        t	        |«      | _        | j                  «        y ©NF)rb  )r…   r†   ra  rI  rS  r/   rh  rš   s     €ru   r†   zAlbertForMaskedLM.__init__ß  s7   ø€ Ü‰Ñ˜Ô ä! &¸EÔBˆŒÜ(¨Ó0ˆÔð 	�‰Õr�   r¡   c                 ó.   — | j                   j                  S rû   r•  rk  s    ru   r—  z'AlbertForMaskedLM.get_output_embeddingsè  r˜  r�   r™  Nc                 ó\   — || j                   _        |j                  | j                   _        y rû   )r/   r–  r@   r›  s     ru   rœ  z'AlbertForMaskedLM.set_output_embeddingsë  s$   € Ø#1ˆ×ÑÔ Ø .× 3Ñ 3ˆ×ÑÕr�   c                 óB   — | j                   j                  j                  S rû   rž  rk  s    ru   rl  z&AlbertForMaskedLM.get_input_embeddingsï  rŸ  r�   ru  r   rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  c                 óš  — |
�|
n| j                   j                  }
| j                  ||||||||	|
¬«	      }|d   }| j                  |«      }d}|�Ft	        «       } ||j                  d| j                   j                  «      |j                  d«      «      }|
s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  ¬«      S )a  
        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]`

        Returns:

        Example:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("albert/albert-base-v2")
        >>> model = AlbertForMaskedLM.from_pretrained("albert/albert-base-v2")

        >>> # add mask_token
        >>> inputs = tokenizer("The capital of [MASK] is Paris.", return_tensors="pt")
        >>> with torch.no_grad():
        ...     logits = model(**inputs).logits

        >>> # retrieve index of [MASK]
        >>> mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(as_tuple=True)[0]
        >>> predicted_token_id = logits[0, mask_token_index].argmax(axis=-1)
        >>> tokenizer.decode(predicted_token_id)
        'france'
        ```

        ```python
        >>> labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]
        >>> labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -100)
        >>> outputs = model(**inputs, labels=labels)
        >>> round(outputs.loss.item(), 2)
        0.81
        ```
        N©	rž   rÖ   r‚   r}   r×   rŸ   rØ   r  r7  r   r~   rC   ©r\  r»  rÕ   r>  )
re   r|  rI  r/   r   rÊ   rˆ   r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r0  Úsequence_outputsr¥  r©  r¨  r«  s                    ru   rª   zAlbertForMaskedLM.forwardò  sÿ   € ðh &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà—+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð # 1™:Ðà ×,Ñ,Ð-=Ó>ÐàˆØÐÜ'Ó)ˆHÙ%Ð&7×&<Ñ&<¸RÀÇÁ×AWÑAWÓ&XÐZ`×ZeÑZeÐfhÓZiÓjˆNáØ'Ð)¨G°A°B¨KÑ7ˆFØ3AÐ3M�^Ð%¨Ñ.ÐYÐSYÐYäØØ$Ø!×/Ñ/Ø×)Ñ)ô	
ð 	
r�   ©
NNNNNNNNNN)r«   r¬   r­   r­  r†   r	   r½   r—  rœ  r‡   rl  r   r‰  rŠ  r!   r   rŒ  r   ra   r¯   r°   r÷   r   r   rª   r²   r³   s   @ru   r½  r½  Ø  s€  ø„ ð
 5Ð6RÐSÐôð( r§y¡yó (ð4°B·I±Ið 4À$ó 4ð6 b§l¡ló 6ñ +Ð+B×+IÑ+IÐJgÓ+hÓiÙ¨>ÈÔXð 15Ø6:Ø59Ø37Ø15Ø59Ø-1Ø,0Ø/3Ø&*ñQ
à˜E×,Ñ,Ñ-ðQ
ð ! ×!2Ñ!2Ñ3ðQ
ð ! ×!1Ñ!1Ñ2ð	Q
ð
 ˜u×/Ñ/Ñ0ðQ
ð ˜E×-Ñ-Ñ.ðQ
ð   × 1Ñ 1Ñ2ðQ
ð ˜×)Ñ)Ñ*ðQ
ð $ D™>ðQ
ð ' t™nðQ
ð ˜d‘^ðQ
ð 
ˆ~˜uÐ$Ñ	%òQ
ó Yó jôQ
r�   r½  zž
    Albert 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 eej                  d«      «       ede	e
dd¬«      	 	 	 	 	 	 	 	 	 	 ddeej                     d	eej                     d
eej                     deej                     deej                     deej                     deej                     dee   dee   dee   dee	ef   fd„«       «       Zˆ xZS )ÚAlbertForSequenceClassificationre   c                 óN  •— t         ‰| �  |«       |j                  | _        || _        t	        |«      | _        t        j                  |j                  «      | _	        t        j                  |j                  | j                  j                  «      | _        | j                  «        y rû   )r…   r†   r¸  re   ra  rI  r	   r‘   r·  r“   r½   r¹   rB   rh  rš   s     €ru   r†   z(AlbertForSequenceClassification.__init__P  st   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒØˆŒä! &Ó)ˆŒÜ—z‘z &×"@Ñ"@ÓAˆŒÜŸ)™) F×$6Ñ$6¸¿¹×8NÑ8NÓOˆŒð 	�‰Õr�   ru  ztextattack/albert-base-v2-imdbz	'LABEL_1'g¸…ëQ¸¾?)rw  rx  rV  Úexpected_outputÚexpected_lossrž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r¡   c                 ó@  — |
�|
n| j                   j                  }
| j                  ||||||||	|
¬«	      }|d   }| j                  |«      }| j	                  |«      }d}|��‡| j                   j
                  €�| j                  dk(  rd| j                   _        nl| j                  dkD  rL|j                  t        j                  k(  s|j                  t        j                  k(  rd| j                   _        nd| j                   _        | j                   j
                  dk(  rIt        «       }| j                  dk(  r& ||j                  «       |j                  «       «      }nŒ |||«      }n‚| j                   j
                  dk(  r=t        «       } ||j                  d| j                  «      |j                  d«      «      }n,| j                   j
                  dk(  rt        «       } |||«      }|
s|f|dd z   }|�|f|z   S |S 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).
        NrÄ  r"   Ú
regressionÚsingle_label_classificationÚmulti_label_classificationr~   rC   rÅ  )re   r|  rI  r“   rB   Úproblem_typer¸  r„   ra   r™   r\   r   Úsqueezer   rÊ   r
   r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r0  rˆ  r»  r\  r¨  r«  s                    ru   rª   z'AlbertForSequenceClassification.forward\  sè  € ð6 &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà—+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð   ™
ˆàŸ™ ]Ó3ˆØ—‘ Ó/ˆàˆØÑØ�{‰{×'Ñ'Ð/Ø—?‘? 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¨FÓ3‘DØ—‘×)Ñ)Ð-JÒJÜ+Ó-�Ù §¡¨B°·±Ó @À&Ç+Á+ÈbÃ/ÓR‘Ø—‘×)Ñ)Ð-IÒIÜ,Ó.�Ù ¨Ó/�áØ�Y ¨¨ Ñ,ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä'ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r�   rÇ  )r«   r¬   r­   r#   r†   r   r‰  rŠ  r   r   rŒ  r   ra   r¯   r°   r÷   r   r   rª   r²   r³   s   @ru   rÉ  rÉ  H  sO  ø„ ð
˜|õ 
ñ +Ð+B×+IÑ+IÐJgÓ+hÓiÙØ3Ø,Ø$Ø#Øôð 15Ø6:Ø59Ø37Ø15Ø59Ø-1Ø,0Ø/3Ø&*ñF
à˜E×,Ñ,Ñ-ðF
ð ! ×!2Ñ!2Ñ3ðF
ð ! ×!1Ñ!1Ñ2ð	F
ð
 ˜u×/Ñ/Ñ0ðF
ð ˜E×-Ñ-Ñ.ðF
ð   × 1Ñ 1Ñ2ðF
ð ˜×)Ñ)Ñ*ðF
ð $ D™>ðF
ð ' t™nðF
ð ˜d‘^ðF
ð 
Ð'¨Ð.Ñ	/òF
óó jôF
r�   rÉ  z¥
    Albert 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defˆ fd„Z eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 ddeej                     deej                     deej                     deej                     d	eej                     d
eej                     deej                     dee   dee   dee   dee
ef   fd„«       «       Zˆ xZS )ÚAlbertForTokenClassificationre   c                 óx  •— t         ‰| �  |«       |j                  | _        t        |d¬«      | _        |j
                  �|j
                  n|j                  }t        j                  |«      | _	        t        j                  |j                  | j                  j                  «      | _        | j                  «        y r¿  )r…   r†   r¸  ra  rI  r·  r’   r	   r‘   r“   r½   r¹   re   rB   rh  )r›   re   r·  rœ   s      €ru   r†   z%AlbertForTokenClassification.__init__µ  s“   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒä! &¸EÔBˆŒð ×-Ñ-Ð9ð ×*Ò*à×+Ñ+ð 	 ô
 —z‘zÐ"9Ó:ˆŒÜŸ)™) F×$6Ñ$6¸¿¹×8NÑ8NÓOˆŒð 	�‰Õr�   ru  rv  rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r¡   c                 ó¨  — |
�|
n| j                   j                  }
| j                  ||||||||	|
¬«	      }|d   }| j                  |«      }| j	                  |«      }d}|�<t        «       } ||j                  d| j                  «      |j                  d«      «      }|
s|f|dd z   }|�|f|z   S |S 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]`.
        Nr¤  r   r~   rC   rÅ  )re   r|  rI  r“   rB   r   rÊ   r¸  r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r0  r‡  r»  r\  r¨  r«  s                    ru   rª   z$AlbertForTokenClassification.forwardÅ  sö   € ð. &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà—+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð " !™*ˆàŸ,™, Ó7ˆØ—‘ Ó1ˆàˆØÐÜ'Ó)ˆHÙ˜FŸK™K¨¨D¯O©OÓ<¸f¿k¹kÈ"»oÓNˆDáØ�Y ¨¨ Ñ,ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä$ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r�   rÇ  )r«   r¬   r­   r#   r†   r   r‰  rŠ  r   r‹  r   rŒ  r   ra   r¯   r°   r÷   r   r   rª   r²   r³   s   @ru   rÔ  rÔ  ­  s<  ø„ ð˜|õ ñ  +Ð+B×+IÑ+IÐJgÓ+hÓiÙØ&Ø)Ø$ôð 15Ø6:Ø59Ø37Ø15Ø59Ø-1Ø,0Ø/3Ø&*ñ2
à˜E×,Ñ,Ñ-ð2
ð ! ×!2Ñ!2Ñ3ð2
ð ! ×!1Ñ!1Ñ2ð	2
ð
 ˜u×/Ñ/Ñ0ð2
ð ˜E×-Ñ-Ñ.ð2
ð   × 1Ñ 1Ñ2ð2
ð ˜×)Ñ)Ñ*ð2
ð $ D™>ð2
ð ' t™nð2
ð ˜d‘^ð2
ð 
Ð$ eÐ+Ñ	,ò2
óó jô2
r�   rÔ  zß
    Albert Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
    layers on top of the hidden-states output to compute `span start logits` and `span end logits`).
    c                   ó¸  ‡ — e Zd Zdefˆ fd„Z eej                  d«      «       ede	e
dddd¬	«      	 	 	 	 	 	 	 	 	 	 	 dd
eej                     deej                     deej                     deej                     deej                     deej                     deej                     deej                     dee   dee   dee   deeef   fd„«       «       Zˆ xZS )ÚAlbertForQuestionAnsweringre   c                 óè   •— t         ‰| �  |«       |j                  | _        t        |d¬«      | _        t        j                  |j                  |j                  «      | _        | j                  «        y r¿  )
r…   r†   r¸  ra  rI  r	   r½   r¹   Ú
qa_outputsrh  rš   s     €ru   r†   z#AlbertForQuestionAnswering.__init__  sU   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒä! &¸EÔBˆŒÜŸ)™) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Õr�   ru  ztwmkn9/albert-base-v2-squad2é   é   z'a nice puppet'gq=
×£p@)rw  rx  rV  Úqa_target_start_indexÚqa_target_end_indexrË  rÌ  rž   rÖ   r‚   r}   r×   rŸ   Ústart_positionsÚend_positionsrØ   r  r7  r¡   c                 ó(  — |�|n| j                   j                  }| j                  |||||||	|
|¬«	      }|d   }| j                  |«      }|j	                  dd¬«      \  }}|j                  d«      j                  «       }|j                  d«      j                  «       }d}|�·|�µt        |j                  «       «      dkD  r|j                  d«      }t        |j                  «       «      dkD  r|j                  d«      }|j                  d«      }|j                  d|«      }|j                  d|«      }t        |¬«      } |||«      } |||«      }||z   dz  }|s||f|dd z   }|�|f|z   S |S t        ||||j                  |j                  ¬	«      S )
a  
        start_positions (`torch.LongTensor` 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 (`torch.LongTensor` 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.
        NrÄ  r   r"   r~   rÐ   )Úignore_indexrC   )r\  Ústart_logitsÚ
end_logitsrÕ   r>  )re   r|  rI  rÚ  rW   rÒ  r  rV   r˜   Úclampr   r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   rß  rà  rØ   r  r7  r0  r‡  r»  rã  rä  r§  Úignored_indexr¨  Ú
start_lossÚend_lossr«  s                          ru   rª   z"AlbertForQuestionAnswering.forward  sÃ  € ðD &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà—+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð " !™*ˆà#Ÿ™¨Ó?ˆØ#)§<¡<°°r <Ó#:Ñ ˆ�jØ#×+Ñ+¨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Ù 
¨MÓ:ˆHØ$ xÑ/°1Ñ4ˆJáØ" JÐ/°'¸!¸"°+Ñ=ˆFØ/9Ð/E�Z�M FÑ*ÐQÈ6ÐQä+ØØ%Ø!Ø!×/Ñ/Ø×)Ñ)ô
ð 	
r�   r¬  )r«   r¬   r­   r#   r†   r   r‰  rŠ  r   r   rŒ  r   ra   r¯   r°   r÷   r   r[  r   rª   r²   r³   s   @ru   rØ  rØ     sn  ø„ ð˜|õ ñ +Ð+B×+IÑ+IÐJgÓ+hÓiÙØ1Ø0Ø$Ø ØØ)Øôð 15Ø6:Ø59Ø37Ø15Ø59Ø6:Ø48Ø,0Ø/3Ø&*ñH
à˜E×,Ñ,Ñ-ðH
ð ! ×!2Ñ!2Ñ3ðH
ð ! ×!1Ñ!1Ñ2ð	H
ð
 ˜u×/Ñ/Ñ0ðH
ð ˜E×-Ñ-Ñ.ðH
ð   × 1Ñ 1Ñ2ðH
ð " %×"2Ñ"2Ñ3ðH
ð   × 0Ñ 0Ñ1ðH
ð $ D™>ðH
ð ' t™nðH
ð ˜d‘^ðH
ð 
Ð)¨5Ð0Ñ	1òH
óó jôH
r�   rØ  z§
    Albert 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defˆ fd„Z eej                  d«      «       ee	e
e¬«      	 	 	 	 	 	 	 	 	 	 ddeej                     deej                     deej                     deej                     d	eej                     d
eej                     deej                     dee   dee   dee   deeef   fd„«       «       Zˆ xZS )ÚAlbertForMultipleChoicere   c                 óö   •— t         ‰| �  |«       t        |«      | _        t	        j
                  |j                  «      | _        t	        j                  |j                  d«      | _
        | j                  «        y )Nr"   )r…   r†   ra  rI  r	   r‘   r·  r“   r½   r¹   rB   rh  rš   s     €ru   r†   z AlbertForMultipleChoice.__init__o  sV   ø€ Ü‰Ñ˜Ô ä! &Ó)ˆŒÜ—z‘z &×"@Ñ"@ÓAˆŒÜŸ)™) F×$6Ñ$6¸Ó:ˆŒð 	�‰Õr�   z(batch_size, num_choices, sequence_lengthrv  rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  r¡   c                 óL  — |
�|
n| j                   j                  }
|�|j                  d   n|j                  d   }|�!|j                  d|j	                  d«      «      nd}|�!|j                  d|j	                  d«      «      nd}|�!|j                  d|j	                  d«      «      nd}|�!|j                  d|j	                  d«      «      nd}|�1|j                  d|j	                  d«      |j	                  d«      «      nd}| j                  ||||||||	|
¬«	      }|d   }| j                  |«      }| j                  |«      }|j                  d|«      }d}|�t        «       } |||«      }|
s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  ¬«      S )aJ  
        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)
        Nr"   r~   rÚ   r¤  rC   rÅ  )re   r|  r^   rÊ   r˜   rI  r“   rB   r   r   rÕ   r>  )r›   rž   rÖ   r‚   r}   r×   rŸ   r¡  rØ   r  r7  Únum_choicesr0  rˆ  r»  Úreshaped_logitsr\  r¨  r«  s                      ru   rª   zAlbertForMultipleChoice.forwardy  sÝ  € ð2 &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆØ,5Ð,A�i—o‘o aÒ(À}×GZÑGZÐ[\ÑG]ˆà>GÐ>S�I—N‘N 2 y§~¡~°bÓ'9Ô:ÐY]ˆ	ØM[ÐMg˜×,Ñ,¨R°×1DÑ1DÀRÓ1HÔIÐmqˆØM[ÐMg˜×,Ñ,¨R°×1DÑ1DÀRÓ1HÔIÐmqˆØGSÐG_�|×(Ñ(¨¨\×->Ñ->¸rÓ-BÔCÐeiˆð Ð(ð ×Ñ˜r =×#5Ñ#5°bÓ#9¸=×;MÑ;MÈbÓ;QÔRàð 	ð
 —+‘+ØØ)Ø)Ø%ØØ'Ø/Ø!5Ø#ð ó 

ˆð   ™
ˆàŸ™ ]Ó3ˆØ#Ÿ™¨}Ó=ˆØ Ÿ+™+ b¨+Ó6ˆàˆØÐÜ'Ó)ˆHÙ˜O¨VÓ4ˆDáØ%Ð'¨'°!°"¨+Ñ5ˆFØ)-Ð)9�T�G˜fÑ$ÐE¸vÐEä(ØØ"Ø!×/Ñ/Ø×)Ñ)ô	
ð 	
r�   rÇ  )r«   r¬   r­   r#   r†   r   r‰  rŠ  r   r‹  r   rŒ  r   ra   r¯   r°   r÷   r   r[  r   rª   r²   r³   s   @ru   rê  rê  g  s<  ø„ ð˜|õ ñ +Ð+B×+IÑ+IÐJtÓ+uÓvÙØ&Ø-Ø$ôð 15Ø6:Ø59Ø37Ø15Ø59Ø-1Ø,0Ø/3Ø&*ñ?
à˜E×,Ñ,Ñ-ð?
ð ! ×!2Ñ!2Ñ3ð?
ð ! ×!1Ñ!1Ñ2ð	?
ð
 ˜u×/Ñ/Ñ0ð?
ð ˜E×-Ñ-Ñ.ð?
ð   × 1Ñ 1Ñ2ð?
ð ˜×)Ñ)Ñ*ð?
ð $ D™>ð?
ð ' t™nð?
ð ˜d‘^ð?
ð 
Ð)¨5Ð0Ñ	1ò?
óó wô?
r�   rê  )	rv   rH  ra  rŽ  r½  rÉ  rÔ  rØ  rê  )Ir®   rÜ   rK   Údataclassesr   Útypingr   r   r   r   r   ra   r	   Útorch.nnr
   r   r   Úactivationsr   Úmodeling_attn_mask_utilsr   Úmodeling_outputsr   r   r   r   r   r   r   Úmodeling_utilsr   Úpytorch_utilsr   r   r   r   Úutilsr   r   r   r   r    r!   Úconfiguration_albertr#   Ú
get_loggerr«   rI   r‹  rŒ  rv   ÚModulerx   rµ   rù   r  r  r!  r2  rH  r[  ÚALBERT_START_DOCSTRINGr‰  ra  rŽ  rS  r’  r½  rÉ  rÔ  rØ  rê  Ú__all__r)  r�   ru   ú<module>rý     s—  ðñ ã Û 	Ý !ß 5Õ 5ã Ý ß AÑ Aå !Ý K÷÷ ñ õ .÷ó ÷÷ õ /ð 
ˆ×	Ñ	˜HÓ	%€à-Ð Ø €ò{ô|A�r—y‘yô AôHms�b—i‘iô msô`3,˜/ô 3,ðn ØñÐ ô&�"—)‘)ô &ôR �r—y‘yô  ôF2
˜Ÿ	™	ô 2
ôj%˜Oô %ð< ô: ó :ó ð:ðBÐ ð /Ð ñd ØfØóôH
Ð'ó H
ó	ðH
ñV ðð óôf
Ð0ó f
óðf
ôR*�B—I‘Iô *ô<
�B—I‘Iô 
ñ Ø:Øóôi
Ð-ó i
ó	ði
ñX ðð óô[
Ð&;ó [
óð[
ñ| ðð óôI
Ð#8ó I
óðI
ñX ðð óô]
Ð!6ó ]
óð]
ñ@ ðð óôP
Ð3ó P
óðP
òf
�r�   