
    fTh                         % S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKJrJrJrJrJr  S SKrS SKJs  Jr  S SKJr  S SKJrJrJrJrJr  S SKJr  S SKJ r   S SK!J"r"  SS	K#J$r$  SS
K%J&r&J'r'J(r(J)r)  SSK*J+r+J,r,  SSK-J.r.  SSK/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrC  SSKDJErEJFrF  \F" 5       (       a  S SKGJHrH  \$R                  " \J5      rK\R                  R                  SS5      R                  5       \E;   rO SxS\P\+   S\\\Q\R\Q   4      S\R\Q   4S jjrS/ SQrTSS/rU/ rV\T HA  rW\X" \W\Y5      (       a  \VR                  \S" Sy0 \WD65        M*  \VR                  \S" \W5      5        MC     / SQr[\\" \]" \^" \V\[-   5      5      5      r_Sq`S ra SzS jrbS rcS rdS  reS! rfS" rgS{S# jrhS$ riSS%.S& jrjS' rkS( rlS|SS%.S) jjrmS|SS%.S* jjrnSSS+.S, jroSS%.S- jrpS. rqSS%.S/ jrrSS%.S0 jrsSSSS1.S2 jrtSSSS1.S3 jruS4 rvS5 rwSSS6.S7 jrxSS%.S8 jryS9 rzSSS:.S; jr{S< r|SxS= jr}S> r~S? rS@ rSA rSxSB jrSxSC jrSD rSE rSF rS}SG jr S~SH jrSI rSJ rSK rSL r0 \R,                  GR                  \a_\R,                  GR                  GR                  \b_\R,                  GR                   \c_\R,                  GR"                  \d_\R,                  GR$                  \e_\GR&                  \f_\R,                  GR                  GR&                  \h_\R,                  GR(                  \g_\GR*                  \i_\GR,                  \j_\GR.                  \k_\GR0                  \l_\GR2                  \m_\GR4                  \n_\GR6                  \o_\GR8                  \p_\GR:                  GR8                  \q_0 \GR<                  \r_\GR>                  \s_\GR@                  \t_\GR:                  GR@                  \u_\GRB                  \v_\GR:                  GRD                  \w_\GRF                  \x_\GRH                  \}_\GRJ                  \~_\GR:                  GRJ                  \_\GRL                  \y_\GR:                  GRL                  \z_\GRN                  \{_\GR:                  GRN                  \|_\R,                  GRP                  \_\R,                  GRR                  \_\GRT                  \_E\GR:                  GRT                  \\GRV                  \\GR:                  GRV                  \\GRX                  \\R,                  GR                  GRZ                  \\R,                  GR\                  \\R,                  GR^                  \\R,                  GR`                  \\GRb                  \0	Er\Y\\4   \SM'   \\\R,                  GR                  GRh                  '    " SN SO\5      r " SP SQ\5      r " SR SS\5      r " ST SU\5      r SxSV\SW\\SX   \SY   \SZ   4   S[\\\/\4      S\4S\ jjr " S] S^\P5      rS_\S\\\\4   4S` jrSa rSb\P\&   S\\/\4   4Sc jr\" Sd\&40 \" \&5      Se9r\" Sf\'40 \" \'5      Se9r\" Sg\(40 \" \(5      Se9r\" Sh\)40 \" \)5      Se9rSSi\Sj\Sk\\R\      4Sl jjr " Sm Sn\5      rSo\GR                  Sp\R\Q   4Sq jrSSs jrSSt jrSS\4SoSrSp\\R\Q      Su\Sv\P\   S\4
Sw jjrg)    N)AnyCallableLiteralOptionalUnion)nn)GraphGraphModuleNodeProxyTracer)compatibility)is_fx_tracingParameterProxy   )logging)CacheDynamicCache	SinkCacheStaticCache)PretrainedConfigPreTrainedModel)
get_values),MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES MODEL_FOR_BACKBONE_MAPPING_NAMES!MODEL_FOR_CAUSAL_LM_MAPPING_NAMESMODEL_FOR_CTC_MAPPING_NAMES3MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMESMODEL_FOR_IMAGE_MAPPING_NAMES-MODEL_FOR_MASKED_IMAGE_MODELING_MAPPING_NAMES!MODEL_FOR_MASKED_LM_MAPPING_NAMES'MODEL_FOR_MULTIPLE_CHOICE_MAPPING_NAMES0MODEL_FOR_NEXT_SENTENCE_PREDICTION_MAPPING_NAMES#MODEL_FOR_PRETRAINING_MAPPING_NAMES*MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES-MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES/MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES(MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES6MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMESMODEL_MAPPING_NAMES   )ENV_VARS_TRUE_VALUESis_peft_available)	PeftModelFX_DEBUG_MODE 
model_namesupported_tasksreturnc                    0 S[         _S[        _S[        _S[        _S[        _S[
        _S[        _S[        _S	[        _S
[        _S[        _S[        _S[        _S[        _S[        _S[        _S[         _["        [$        [&        S.EnUc  UR)                  5       n[+        U[,        5      (       a  U/n/ nU H1  nX$   R/                  U S 5      nU(       d  M   UR1                  U5        M3     U$ )Ndefaultpretrainingznext-sentence-predictionz	masked-lmz	causal-lmz
seq2seq-lmzspeech-seq2seqzmultiple-choicezdocument-question-answeringzquestion-answeringzsequence-classificationztoken-classificationzmasked-image-modelingzimage-classificationzzero-shot-image-classificationctczaudio-classification)zsemantic-segmentationbackbonezimage-feature-extraction)r.   r&   r%   r#   r   r)   r+   r$   r   r'   r*   r,   r"   r    r-   r   r   r(   r   r!   keys
isinstancestrgetappend)r5   r6   task_mappingmodel_class_namestask
class_names         M/var/www/auris/envauris/lib/python3.13/site-packages/transformers/utils/fx.py%_generate_supported_model_class_namesrG   L   s^   &: 	#$T 	6	
 	6 	B 	B 	B 	&'Z 	H 	"#R 	 L 	 !N 	 L 	)*`  	*!" 	 L#$ "O4$A)L. &++-/3''*+!'++J=
:$$Z0  
     )5altclipalbertbartbertbitnet
blenderbotzblenderbot-smallbloomclipconvnextdebertaz
deberta-v2dinov2
distilbertz
donut-swinelectragpt2gpt_neogptjhierahubertijepalayoutlmllamacoherelxmertm2m_100marianmbartmegatron-bertmistralmixtral
mobilebertmt5nezhaoptpegasusplbartqwen2	qwen2_moeqwen3	qwen3_moeresnetroberta	segformerspeech_to_textspeech_to_text_2swint5trocrvitxglmwav2vec2r]   ri   )CLIPTextModelCLIPTextModelWithProjectionCLIPVisionModelCLIPVisionModelWithProjectionAltCLIPTextModelAltCLIPVisionModelGitVisionModelGPT2DoubleHeadsModelSpeech2Text2DecoderTrOCRDecoderPeftModelForCausalLMPeftModelForSeq2SeqLMc                     [         R                  " / UR                  QU R                  R                  S   P7SU R                  R                  S.6$ Nmeta)devicedtype)torchemptyshapeweightr   selfinputs     rF   torch_nn_embeddingr      s@    ;;ccT[[%6%6r%:c6QUQ\Q\QbQbccrH   Fc                 |    [         R                  " / U R                  QUR                  S   P7SUR                  S.6$ r   )r   r   r   r   )r   r   padding_idxmax_norm	norm_typescale_grad_by_freqsparses          rF   torch_nn_functional_embeddingr      s3     ;;YYV\\"%5YfFLLYYrH   c                     U$ N r   s     rF   torch_nn_layernormr          LrH   c                     U$ r   r   r   s     rF   torch_nn_groupnormr      r   rH   c                 b    [         R                  " UR                  S S U R                  4-   SS9$ )Nr   r   r   )r   r   r   out_featuresr   s     rF   torch_nn_linearr      s,    ;;u{{3B'4+<+<*>>vNNrH   c                     U $ r   r   xs    rF   
torch_relur          HrH   c                     U$ r   r   )r   r   s     rF   torch_nn_relur      r   rH   c                 *    U(       d  [        S5      eU $ )Nz>Don't support in-place functional.relu for MetaTensor analysis
ValueError)r   inplaces     rF   torch_nn_functional_relur      s    YZZHrH   c                 `    U R                  SS9UR                  SS9-   UR                  SS9-   $ Nr   r   to)	conditionr   ys      rF   torch_wherer      s5     <<v<&V)<<qtt6t?RRRrH   outc                "    Ub  [        S5      eU $ )Nz2Don't support in-place abs for MetaTensor analysisr   )r   r   s     rF   	torch_absr      s    
MNNLrH   c                     [        U 5      nSnUS:X  a  SnU S   nOUS:X  a  U u  pEOU u  pEn[        U[        5      (       a  [        U5      n[        U[        5      (       a  [        U5      n[        U[        5      (       a  [        U5      nUR	                  SU5      nUR	                  S5      n[
        R                  " XT-
  U-  USS9$ )Nr/   r   r   stepr   r   r   r   )lenr>   floatintr@   r   r   )argskwargsnr   startendr   s          rF   torch_aranger      s    D	ADAv1g	
a
sD%E
#uC$4y::fd#DJJwE;;,E&IIrH   c                      [        U 5      n [        U 5      S:  a  SU S'   OSUS'   [        U5      nUR                  SS 5        [        R
                  " U 0 UDSS0D6$ )Nr/   
fill_valuer   r   )listr   dictpopr   full)r   r   kwargs_without_devices      rF   
torch_fullr     s]    :D
4y1}Q | Lh-::tD4DVDDrH   c                0  ^ Tc  Uc  SmTc  Ub  UmTS:  a  U S   R                  5       T-   mU  Vs/ s H  oDR                  PM     nn[        US   5      n[        U4S jU 5       5      nUS T U/-   UTS-   S  -   n[        R
                  " USS9$ s  snf )Nr   c              3   ,   >#    U  H	  oT   v   M     g 7fr   r   ).0r   dims     rF   	<genexpr>torch_cat.<locals>.<genexpr>&  s     :6%:6s   r/   r   r   )r   r   r   sumr   r   )	tensorsr   axisr   tshapesr   concatenated_dimfinal_shapes	    `       rF   	torch_catr     s    
{t|
{t'
Qwajnn$&'w!ggwF'OE:6::+!1 22U3795EEK;;{622	 (s   Bc                    Uc  Uc  SnUc  Ub  UnUS:  a  U S   R                  5       S-   U-   n[        U S   R                  5      nUR                  U[	        U 5      5        [
        R                  " USS9$ Nr   r/   r   r   )r   r   r   insertr   r   r   )r   r   r   r   r   s        rF   torch_stackr   +  sw    
{t|
{t'
Qwajnn"S(!!"E	LLc'l#;;uV,,rH   )alphar   c                b   [        U [        R                  5      (       d  [        R                  " USS9$ [        U[        R                  5      (       d  [        R                  " U SS9$ [	        U R                  5       UR                  5       5      n[        U R                  5      S/X@R                  5       -
  -  -   n[        UR                  5      S/XAR                  5       -
  -  -   n/ n[        U5       H"  nUR                  [	        XX   Xh   5      5        M$     [        R                  " USS9$ )Nr   r   r/   )r>   r   Tensor
empty_likemaxr   r   r   rangerA   r   )	r   otherr   r   
max_lengthinput_shapeother_shaper   is	            rF   	torch_addr   7  s    eU\\**f55eU\\**f55UYY[%))+.Ju{{#qcZ))+-E&FFKu{{#qcZ))+-E&FFKE:S89 ;;uV,,rH   c                    [        XUS9$ )Nr   )r   )r   r   r   s      rF   	torch_mulr   E  s    Us++rH   c                     [        X5      $ r   )r   )r   r   s     rF   torch_tensor_mulr   I  s    T!!rH   c                   U R                  5       nUR                  5       nS nUS:X  a
  US:X  a  S nGOUS:X  a*  US:X  a$  U R                  S5      UR                  S5      4nGObUS:X  a  US:X  a  UR                  S5      4nGOBUS:X  a  US:X  a  U R                  S5      4nGO"[        U R                  5       UR                  5       5      n[        U R                  5      n[        UR                  5      nUS:X  a  S/U-   nUS:X  a  UR                  S5        S/Xc-
  -  [        U R                  5      -   nS/Xd-
  -  [        UR                  5      -   n/ n[        U5       H"  n	UR                  [        Xy   X   5      5        M$     US   US'   US   US'   US:X  a  UR                  S5        US:X  a  UR                  S5        Uc  [        R                  " SSS9$ [        R                  " US	S06$ )
Nr/   r   r   r           r   r   r   )r   sizer   r   r   rA   r   r   r   tensorr   )
r   r   r   d1d2r   r   shape1shape2r   s
             rF   torch_matmulr   M  s   	B	BE	Qw27	qR1WA

1.	qR1WA 	qR1WA eiik2
ekk"ekk"7S6\F7MM!)D,==)D,==z"ALLVY	23 #2Jb	2Jb	7IIbM7IIbM}||C//;;-f--rH   c                    Ub  [        S5      eU R                  u  p4nUR                  u    pg[        R                  " X4USS9$ )Nz2Don't support in-place bmm for MetaTensor analysisr   r   )r   r   r   r   )r   mat2r   
batch_sizer   m_ps           rF   	torch_bmmr  q  sA    
MNN{{J1jjGAq;;za77rH   betar   r   c                4    Ub  [        S5      e[        X5      $ )Nz6Don't support in-place baddbmm for MetaTensor analysis)r   r  )r   batch1batch2r  r   r   s         rF   torch_baddbmmr
  y  s    
QRRV$$rH   c          	          [        XX#XES9$ )Nr  )r
  )r   r  r	  r  r   r   s         rF   torch_tensor_baddbmmr    s    vOOrH   c                 `    S U 5       n[         R                  " U /UQ76 R                  S5      $ )Nc              3   L   #    U  H  n[         R                  " US S9v   M     g7f)cpur   N)r   r   )r   operands     rF   r   torch_einsum.<locals>.<genexpr>  s     YPXW))'%@PXs   "$r   )r   einsumr   )equationoperandsconcrete_operandss      rF   torch_einsumr    s.    YPXY<<5#4588@@rH   c                     [        U R                  5      n[        U5       H  u  p4X#==   U-  ss'   M     [        R                  " USS9$ r   )r   r   	enumerater   r   )r   sizesr   r   r   s        rF   torch_tensor_repeatr    s=    E% A !;;uV,,rH   )r   output_sizec                    [        U5      nUS:X  a  Ub  UOUS   R                  5       /nO[        US   R                  5      nU c  US:  a  US   n O[        U5      /nSn US   n[	        U[
        5      (       d  [        R                  " U5      S:X  a  X@==   [        U5      -  ss'   OUb  UOUR                  5       X@'   [        R                  " USS06$ )Nr/   r   r   r   r   )	r   r   r   r   r>   r   r   numelr   )r   r  r   num_argsr   repeatss         rF   torch_repeat_interleaver     s    4yH1} + 7T!W[[]KT!W]]#;!|1gUq'gs##u{{7';q'@J#g,&J(3(?W[[]EJ;;-f--rH   c                r    [        U R                  5      n[        U5      XA'   [        R                  " USS06$ Nr   r   )r   r   r   r   r   )r   r   indexr   r   s        rF   torch_index_selectr$    s/    EUEJ;;-f--rH   c                     [        XU5      $ r   )r$  r   r   r#  s      rF   torch_tensor_index_selectr'    s    d//rH   )sparse_gradr   c                z    [        U R                  5      nUR                  U   XQ'   [        R                  " USS06$ r"  )r   r   r   r   )r   r   r#  r(  r   r   s         rF   torch_gatherr*    s4    ES!EJ;;-f--rH   c                     [        XU5      $ r   )r*  r&  s      rF   torch_tensor_gatherr,    s    5))rH   c                     U $ r   r   )r   shiftsdimss      rF   
torch_rollr0    r   rH   c                     U $ r   r   )r   r/  s     rF   
torch_flipr2    r   rH   c                     U $ r   r   )r   r/  s     rF   torch_tensor_flipr4    s    KrH   c                    UR                   S   nS nU R                  nUS:X  a  SnUS:X  a  [        UR                   5      nUcq  [        UR                   5      n[        R                  " USUS   -  -   U R
                  S   U R                  S   S-
  -  -
  S-
  U R                  S   -  S-   5      nXSS'   U R                  US'   [        R                  " US	S
9$ )Nr   validr   r   samer   r   r/   r   r   r   r   paddingr   mathfloordilationkernel_sizestrideout_channelsr   r   )r   r   l_inr   r:  l_outs         rF   torch_nn_conv1drC    s    ;;r?DEllG'&U[[!}U[[!

A
N"T]]1%59I9I!9Lq9P%QQTUUY]YdYdefYggjkk
 b	!!E"I;;uV,,rH   c                 j   UR                   SS  u  p#S nU R                  nUS:X  a  SnUS:X  a  [        UR                   5      nUc  [        UR                   5      n[        R                  " USUS   -  -   U R
                  S   U R                  S   S-
  -  -
  S-
  U R                  S   -  S-   5      n[        R                  " USUS   -  -   U R
                  S   U R                  S   S-
  -  -
  S-
  U R                  S   -  S-   5      nXg/USS & U R                  US'   [        R                  " US	S
9$ )Nr   r6  r7  r8  r   r   r/   r   r   r9  )r   r   h_inw_inr   r:  h_outw_outs           rF   torch_nn_conv2drJ    sG   RS!JDEllG'&U[[!}U[[!

A
N"T]]1%59I9I!9Lq9P%QQTUUY]YdYdefYggjkk
 

A
N"T]]1%59I9I!9Lq9P%QQTUUY]YdYdefYggjkk
 ^bc
!!E"I;;uV,,rH   c                    [        U R                  5      nUb3  US:  a  U R                  5       U-   nX!   S:X  a  UR                  U5        O&/ nU H  nUS:X  a  M  UR	                  U5        M     Un[
        R                  " USS9$ r   )r   r   r   r   rA   r   r   )r   r   r   	new_shape	dim_values        rF   torch_squeezerN    s    E
7))+#C:?IIcN	IA~Y'  ;;uV,,rH   c                     [        X5      $ r   )rN  r   r   s     rF   torch_tensor_squeezerQ    s    ##rH   c                     [        U R                  5      nUS:  a  U R                  5       S-   U-   nUR                  US5        [        R
                  " USS9$ r   )r   r   r   r   r   r   )r   r   r   s      rF   torch_unsqueezerS     sJ    E
QwiikAo#	LLa;;uV,,rH   c                     [        X5      $ r   )rS  rP  s     rF   torch_tensor_unsqueezerU    s    4%%rH   c                     [         R                  " [         R                  " U SS940 UD6n[        U[         R                  5      (       a  UR                  S5      $ [        [        US 5      5      $ )Nr  r   r   c                 $    U R                  S5      $ Nr   r   r   s    rF   <lambda>*torch_unique_consecutive.<locals>.<lambda>  s    144<rH   )r   unique_consecutive
zeros_liker>   r   r   tuplemap)r   r   outputs      rF   torch_unique_consecutiver`    sW    %%e&6&6uU&KVvVF&%,,''yy  S!7899rH   c                     US:  a  [        S5      e[        U R                  5      U/-   n[        R                  " USS9$ )Nr   zEDon't support automatic num_classes inference for MetaTensor analysisr   r   )r   r   r   r   r   )r   num_classesr   s      rF   torch_nn_functional_one_hotrc    s;    Q`aa+.E;;uV,,rH   c                     U R                   S   nUR                   S   n[        R                  " / U R                   S S QUPUP7SS9$ )Nr   r   r   r   )r   r   r   )	querykeyvalue	attn_mask	dropout_p	is_causalscaletarget_lengthhead_dims	            rF   0torch_nn_functional_scaled_dot_product_attentionrn    sJ     KKOM{{2H;;CSb)C=C(CFSSrH   c                 j    U R                   S:X  a  UR                  nOSn[        R                  " USS9$ Nnone)r/   r   r   	reductionr   r   r   r   r   targetr   s       rF   torch_nn_mselossrv  #  -    ~~;;uV,,rH   c                 j    U R                   S:X  a  UR                  nOSn[        R                  " USS9$ rp  rr  rt  s       rF   torch_nn_crossentropylossry  +  rw  rH   c                 j    U R                   S:X  a  UR                  nOSn[        R                  " USS9$ rp  rr  rt  s       rF   torch_nn_bcewithlogitslossr{  3  rw  rH   c                 H   S n[        U [        R                  5      (       ak  [        U[        5      (       a  [        [	        X!5      5      nOU" U5      n[
        R                  " [        R                  " U SS9U5      R                  S5      $ [
        R                  " X5      $ )Nc                 H   [        U [        R                  5      (       a  [        R                  " U SS9nUR                  [        R
                  [        R                  [        R                  [        R                  4;   a  UR                  [        R                  5      nU$ U $ )Nr  r   )r>   r   r   	ones_liker   float16float32float64int32r   int64)r   concretes     rF   to_concrete%operator_getitem.<locals>.to_concrete<  sd    a&&q7H~~%--u{{![[#;;u{{3OrH   r  r   r   )	r>   r   r   r]  r^  operatorgetitemr   r   )abr  s      rF   operator_getitemr  ;  s{     !U\\""ac+)*AAA 0 05 A1EHHPPA!!rH   _MANUAL_META_OVERRIDESc                   v   ^  \ rS rSrSrS r\S 5       r\S 5       rU 4S jr	U 4S jr
S rS	 rU 4S
 jrSrU =r$ )HFProxyi  zA
Proxy that uses metadata to handle data-dependent control-flow.
c                     Xl         g r   	_metadata)r   metadatas     rF   install_metadataHFProxy.install_metadata  s    !rH   c                 @    U R                   R                  SSU 40 5      $ )Ncall_methodr   )tracercreate_proxyr   s    rF   r   HFProxy.shape  s    {{''vwKKrH   c                     [        U S5      $ )Nr   )MetaDeviceAttributer  s    rF   r   HFProxy.device  s     #422rH   c                    > [        U S5      (       a"  U R                  b  [        U R                  5      $ [        TU ]  5       $ Nr  )hasattrr  r   super__len__r   	__class__s    rF   r  HFProxy.__len__  s5    4%%$..*Dt~~&&w  rH   c                 t   > [        U S5      (       a  U R                  b  U R                  $ [        TU ]  5       $ r  )r  r  r  __bool__r  s    rF   r  HFProxy.__bool__  s1    4%%$..*D>>!w!!rH   c                 F    US:X  a  U R                  U5      $ [        X5      $ r  )__getattribute__HFAttribute)r   ks     rF   __getattr__HFProxy.__getattr__  s(    ((++ 4##rH   c                 ^    U R                   R                  S[        R                  XU40 5      $ Ncall_function)r  r  r  setitem)r   indicesvaluess      rF   __setitem__HFProxy.__setitem__  s*    {{''9I9ID[aKbdfggrH   c                 z   > [        U S5      (       a  U R                  b  XR                  ;   $ [        TU ]  U5      $ r  )r  r  r  __contains__)r   rf  r  s     rF   r  HFProxy.__contains__  s6    4%%$..*D..((w#C((rH   r  )__name__
__module____qualname____firstlineno____doc__r  propertyr   r   r  r  r  r  r  __static_attributes____classcell__r  s   @rF   r  r    sV    " L L 3 3
!
"
$h) )rH   r  c                   8    \ rS rSrS\4S jr\S 5       rS rSr	g)r  i  attrc                     Xl         X l        UR                  U l        S U l        [	        U R                   S5      (       a0  U R                  [        U R                   R                  U5      5        g g r  )rootr  r  _noder  r  getattrr  )r   r  r  s      rF   __init__HFAttribute.__init__  sS    		kk
499k**!!'$))*=*=t"DE +rH   c                     U R                   cQ  U R                  R                  S[        R                  U R
                  U R                  40 5      R                  U l         U R                   $ r  )r  r  r  builtinsr  r  r  noder  s    rF   r  HFAttribute.node  sT     ::11/8CSCSVZV_V_aeajajUkmopuuDJzzrH   c                 n    U R                   R                  SU R                  U R                  4U-   U5      $ )Nr  )r  r  r  r  )r   r   r   s      rF   __call__HFAttribute.__call__  s.    {{''tyy499,QUBUW]^^rH   )r  r  r  r  N)
r  r  r  r  r?   r  r  r  r  r  r   rH   rF   r  r    s*    F3 F  _rH   r  c                       \ rS rSrSrg)r  i  r   N)r  r  r  r  r  r   rH   rF   r  r    s    rH   r  c                   <    \ rS rSrSrS\\   4S jr\S 5       r	Sr
g)HFCacheProxyi  zH
Proxy that represents an instance of `transformers.cache_utils.Cache`.
orig_cache_clsc                     Xl         g r   _orig_cache_cls)r   r  s     rF   install_orig_cache_cls#HFCacheProxy.install_orig_cache_cls  s    -rH   c                     [        U S5      (       d  [        S5      eU R                  R                  U R                     $ )Nr  z?The original Cache class must be installed to the HFCacheProxy.)r  RuntimeErrorr  _CLASSES_TO_PATCHr  r  s    rF   r  HFCacheProxy.__class__  s7    t.//`aa{{,,T-A-ABBrH   r  N)r  r  r  r  r  typer   r  r  r  r  r   rH   rF   r  r    s-    .T%[ . C CrH   r  functionop_typer  r  get_attrproxy_factory_fnc                 N   ^ ^^ [         R                  " T 5      U UU4S j5       nU$ )Nc                    >^ [        5       (       d  T" U 0 UD6$ / mU4S jn[        R                  R                  R	                  X5        [        R                  R                  R	                  X5        [        T5      S:  a_  TS   R                  nTS:X  a  TnO5TS:X  a  TR                  nO"TS:X  a  TR                  nO[        ST S35      eUR                  TX@UTS9$ T" U 0 UD6$ )	Nc                 T   > [        U [        5      (       a  TR                  U 5        g g r   )r>   r   rA   )r  found_proxiess    rF   check_proxy4create_wrapper.<locals>.wrapper.<locals>.check_proxy  s#    !U##$$Q' $rH   r   r  r  r  zop_type z not supported.r  )
r   r   fxr  map_aggregater   r  r  r   r  )	r   r   r  r  ru  r  r  r  r  s	        @rF   wrappercreate_wrapper.<locals>.wrapper  s    T,V,,	( 	##D6##F8}!"1%,,F/)!M)!**J&!** 8G9O!DEE&&wfWg&hhT,V,,rH   )	functoolswraps)r  r  r  r  s   ``` rF   create_wrapperr    s'    
 __X- -6 NrH   c                   l   ^  \ rS rSrSr S
S\S\\S4   S\\\	4   S\
\\/\4      4U 4S jjjrS	rU =r$ )HFProxyableClassMetai  zO
Metaclass that creates a class with its main methods wrapped to be proxyable.
namebases.attrsr  c                 `  > [         TU ]  XX#5      n [        U 5       H  n[        XS 5      nUc  M  US:X  a  SnOWUR	                  S5      (       a  S nO>[
        R                  " U5      (       a  SnO [
        R                  " U5      (       a  SnOS nUc  My  [        X[        XgUS95        M     U $ )Nr  r  __r  r  )
r  __new__dirr  
startswithinspectismethod
isfunctionsetattrr  )	clsr  r  r  r  	attr_namer  r  r  s	           rF   r  HFProxyableClassMeta.__new__  s     goc6SI340D|J&)%%d++!!$'')##D))'"tWg(hi "  
rH   r   r   )r  r  r  r  r  r?   r]  r  r   r   r   r   r   r   r  r  r  r  s   @rF   r  r    s_     ?C T3Y CH~	
 #8TFEM#:; rH   r  ru  c                      [        U S5      nX4$ )zg
Wraps `target` to be proxyable. Used for tensor creators like `torch.ones`, `torch.arange` and so on.
r  )r  )ru  r  s     rF   gen_constructor_wrapperr    s     V_5G?rH   c                    [        U [        5      (       a  g[        U [        R                  R                  5      (       a@  [        U [
        5      (       a  [        U S5      (       d  [        SU  35      eU R                  $ U $ )z\Returns the underlying metadata for HFProxies, and behaves like the identity for the others.r   r  zNo metadata was found for )	r>   r  r   r  r   r  r  r  r  )vs    rF   _proxies_to_metasr  "  sc    !())!UXX^^$$1g&&71k+B+B!;A3?@@{{HrH   r  c                 0   ^  S[         S[        4U 4S jjnU$ )Nr   r7   c                    > [        [        [        5      (       d  [        S5      e[	        U [        5      nUR                  T5        U$ )NzJCannot create HFCacheProxy because there is no HFTracer currently tracing.)r>   _CURRENT_TRACERHFTracerr  r  r  )r   cache_proxyr  s     rF   cache_proxy_factory_fn=create_cache_proxy_factory_fn.<locals>.cache_proxy_factory_fn.  s<    /844kll"1o6**>:rH   )r   r  )r  r  s   ` rF   create_cache_proxy_factory_fnr  -  s    $ <  "!rH   ProxyableCacher  ProxyableDynamicCacheProxyableSinkCacheProxyableStaticCachelowhighforbidden_valuesc                     Uc  / n[         R                  " X5      nX2;   a  [         R                  " X5      nX2;   a  M  U$ r   )randomrandint)r  r  r  rg  s       rF   _generate_random_intr  Q  s=    NN3%E

#s) 
#LrH   c                     ^  \ rS rSr% SrSr\\S'   Sr\\S'   / SQr	\
\\\\\\\0r\" 5       (       d  \4O\\4r\4S4U 4S jjrS	S
S\S\\   S\\   S\\\R<                  4   4
S jrS+U 4S jjr S r!S\S\"S\\\"4   4S jr#U 4S jr$S r%\&RN                  S\(\RR                  RT                  \+S\"4   4   4S j5       r,   S,S\(\RR                  RT                  \+S\"4   4   S\-\\\"4      S\-\\\"4      S\S\.4
U 4S jjjr/S\)RT                  S\4S  jr0S\)RT                  S\4S! jr1S\)RT                  S\4U 4S" jjr2S#\RR                  RT                  S$\S\4U 4S% jjr3\4" SS&9S'S(S\"4S) j5       r5S*r6U =r7$ )-r  iZ  z
Tracer that is able to symbolically trace models from the library. To do that, it uses the HFProxy instead of the
regular PyTorch torch.fx.Proxy.
Tproxy_buffer_attributesallow_insert_stateless_mods)arangezerosonesr   	full_likeeyer   r   clampfinfotrilr   c                     > [         TU ]  XS9  g )N)autowrap_modulesautowrap_functions)r  r  )r   r'  r(  r  s      rF   r  HFTracer.__init__y  s    *:brH   modelr   
input_namer   input_namesr7   c           	      4  ^^ [        USUR                  5      R                  nUR                  m0 nSnUS;   Ga  US   nU/ [	        [
        5      Q[	        [        5      Q[	        [        5      Q[	        [        5      Q[	        [        5      Q;   a)  [        R                  " U[        R                  TS9US'   U$ U/ [	        [        5      Q[	        [        5      QSP;   aP  [        R                  " U[        R                  TS9US'   [        R                  " U[        R                  TS9US	'   U$ U[	        [        5      ;   Ga-  [!        UR"                  S
5      (       a  UR"                  R$                  c  ['        S5      eUR"                  R$                  S:X  a(  XR"                  R(                  4n	[        R*                  n
OUR"                  R$                  S:X  a  U4n	[        R                  n
OeUR"                  R$                  S:X  a(  XR"                  R(                  4n	[        R*                  n
O#['        SUR"                  R$                   S35      e[        R                  " XTS.6US'   U$ U/ [	        [,        5      Q[	        [.        5      Q[	        [0        5      Q[	        [2        5      Q[	        [4        5      Q[	        [6        5      QSPSPSP;   a)  [        R                  " U[        R                  TS9US'   U$ U/ [	        [8        5      Q;   a)  [        R                  " U[        R*                  TS9US'   U$ [;        SU SU S35      eSU;   Ga  US   n[        UR"                  SS5      nUc  [!        UR"                  S5      (       a!  UR"                  R<                  R>                  nOP[!        UR"                  S5      (       a!  UR"                  R@                  R>                  nO[C        5       [C        5       4n[        UR"                  SS5      n[E        U[F        RH                  RJ                  5      (       d  X4nUu  p[        R                  " XX[        R*                  TS9Xb'   U$ SU;   a.  [        R                  " / UQSP7[        RL                  TS.6Xb'   U$ S U;   aB  [        R                  " / UQUR"                  RN                  P7[        RL                  TS.6Xb'   U$ S!U;   a  US   n[        UR"                  S"S5      b1  UR"                  RP                  S#:w  a  UR"                  RR                  nOUR"                  RT                  n[W        U5      S:X  a  XS$   US%   U4nOXS$   U4n[        R                  " U[        RL                  TS9Xb'   U$ S&U;   a@  [        R                  " UUR"                  RX                  /-   [        RL                  TS9Xb'   U$ S'U;   a@  [        R                  " UUR"                  RZ                  /-   [        RL                  TS9Xb'   U$ S(U;   a)  [        R                  " U[        RL                  TS.6Xb'   U$ S)U;   a8  Uu  nn[C        S*S+S,9n[        R                  " UU[        RL                  TS9Xb'   U$ S-U;   a>  S.U;   a  US   US$   U-   /nOUn[        R                  " U[        R                  TS9Xb'   U$ S/U;   a(  [        R                  " U[        R                  TS9Xb'   U$ S.U;   a  UR"                  RP                  [\        ;  a#  [;        S0UR"                  RP                   S135      eUR"                  R^                  nUR"                  RT                  UR"                  R^                  -  nUS   UUU4m[a        UU4S2 j[c        UR"                  Rd                  5       5       5      nUXb'   U$ X1R"                  RT                  /-   n[        R                  " U[        RL                  TS9Xb'   U$ )3z4Generates dummy input for model inference recording.class_for_deserialization   )labelsstart_positionsend_positionsr   r   r0  XLNetForQuestionAnsweringr1  r2  problem_typeNzCould not retrieve the problem type for the sequence classification task, please set model.config.problem_type to one of the following values: "regression", "single_label_classification", or "multi_label_classification".
regressionsingle_label_classificationmulti_label_classificationzExpected model.config.problem_type to be either: "regression", "single_label_classification", or "multi_label_classification", but "z" was provided.r   r   r   z!Generating the dummy input named z for z is not supported yet.pixel_values
image_sizevision_configencodernum_channels   bbox   input_featuresinputs_embedsembedding_sizerc   r/   r   visual_feats
visual_posinputsinput_valuesi'  i N  r  r  maskpast_key_valuesidszMSymbolic trace with past_key_values input is not supported yet for the model ze. Please open an issue or a PR in Transformers repository if you would like to see the support added.c              3      >#    U  HM  n[         R                  " T[         R                  TS 9[         R                  " T[         R                  TS 94v   MO     g7f)r   N)r   randr   )r   r   cache_shaper   s     rF   r   1HFTracer._generate_dummy_input.<locals>.<genexpr>  sF      
 ?A JJ{%++fMJJ{%++fM ?s   AA)3r  r  r  r   r   r%   r$   r    r   r   r   r  longr'   r   r*   r  configr4  r   
num_labelsr  r&   r,   r   r#   r)   r(   r   NotImplementedErrorr:  r9  r;  r  r>   collectionsabcIterabler   input_feat_per_channel
model_typerB  hidden_sizer   visual_feat_dimvisual_pos_dim"_FX_SUPPORTED_MODELS_WITH_KV_CACHEnum_attention_headsr]  r   num_hidden_layers)r   r*  r+  r   r,  model_class_nameinputs_dictkv_cache_lengthr   labels_shapelabels_dtyper9  r<  heightwidthrB  embedding_shaper  
seq_length
mask_shape	num_headsrm  pkvshape_with_hidden_sizerM  r   s                           @@rF   _generate_dummy_inputHFTracer._generate_dummy_input|  s
    #5*EuW``
 GGqJ $LM$CD$ HI$ <=	$
 HI$  ).JejjY_(`H%j i " &FG&OP& ,& 
 27Zuzzbh1i-./4{{:UZZ`f/gO,\ [ "Z0_%``u||^<<@Y@Y@a$Z  <<,,<$.0G0G#HL#(==L\\..2OO$.=L#(::L\\..2NN$.0G0G#HL#(==L$CCH<<C\C\B]]ln  ).\^d(eH%n k " 
&?@
&HI
& =>
& =>	
&
 HI
& IJ
& '
& '
& (
& 
 ).ETZ([H%T S "%Oz2M'N%OO(-EW](^H%P M *7
|5IYHZZpq  z)qJ |TBJ!5<<99!&!;!;!F!FJU\\955!&!5!5!@!@J"6"8:N:P!QJ #5<<CLj+//*B*BCC(5
&MF&+kk&u}}U['K#f a z!&+kk&^5&^!&^5;;W]&^K#^ ] +&+kk '';;'CH;;W]'K#Z U 
*qJ &6=ILL++>!&!<!<!&!9!95zQ#-Qxq>"R $.Qx"H&+kk/]c&dK#p o z)&+kkLL00 kk'K#l ] Z'&+kkLL// kk'K#Z K #&+kk5TZ&[K#H G z)!MJ-%eDJ&+kk*jPUP[P[dj&kK#> = z! K/#Aha?(BC
"
&+kk*EJJW]&^K#0 / j &+kk%uzzRX&YK#, + *,||&&.PP)cdidpdpd{d{c|  }b  c  88I||//5<<3S3SSH 8YJK 
 u||==> C '*K#
  &+ll.F.F-G%G"&+kk2HPUP[P[dj&kK#rH   c           	        > [         TU ]  XX4XVU5      nUS:X  a/  X R                  ;   a   UR                  U R                  U   5        U$ X R                  ;   a  SU;   a  SUS'    [
        R                  R                  R                  U[        5      n	[
        R                  R                  R                  U[        5      n
SnSU l
        SU l        US:X  aM  [        R                  X"5      nU" U	0 U
D6n[        U[
        R                  5      (       a  UR!                  SS9nGO%US:X  a7  [#        U	S   R$                  U5      n[        R                  X5      nU" U	0 U
D6nOUS	:X  av  ['        U S
5      (       d  [)        U  S35      eU R*                  R-                  U5      n[/        U5      nU[        ;   a  [        U   " U/U	Q70 U
D6nOU R0                  " U	0 U
D6nOlUS:X  ad  U R*                  nUR3                  S5      nU H  n[#        UU5      nM     [        U[
        R                  5      (       a  UR!                  SS9nOUnOSnU(       a1  [        U[4        5      (       d  [7        S5      eUR                  W5        SU l
        SU l        U$ ! [8         a4  n[:        (       a  [<        R>                  " SU SU SU 35         S nANIS nAff = f)Nplaceholderr   r   Tr  r   r  r   call_moduleorig_forwardz/ does not have an attribute called orig_forwardr  .Fz"Don't support composite output yetzCould not compute metadata for z target z: ) r  r  	meta_argsr  orig_fnsr   r  r  r  r  _disable_module_getattr_disable_call_moduler  r@   r>   r   r   r  r  r  AttributeErrorr  get_submoduler  rp  splitr   r   	Exception_IS_IN_DEBUG_MODEwarningswarn)r   kindru  r   r   r  	type_exprr  rv
args_metaskwargs_metasshould_install_metadatameta_targetmeta_outmethodmodmod_typeattr_itratomsatomer  s                        rF   r  HFTracer.create_proxy+  s   W!$dO_`= V~~%=v 67I]]" 6!#)x .	]44T;LMJ 88==66v?PQL&*#+/D((,D%&488H&
ClCh55'{{&{9H& A!8!8&A488H&
ClC&t^44(D61`)abbii--f59555h?ajaT`aH#00*MMH#99S)!D&x6H "h55'{{&{9H'H*/'&!"e,,$%IJJ##H- (-$$)!	  	]   ?vXfXUWXYWZ[\	]s   $HJ 
K*K		Kc                   ^  [        T SS5      (       a  U$ U 4S jn[        U[        R                  R                  5      (       a'  U" UT R
                  R                  5       U5      nUb  U$ T R                  (       aF  [        U[        R                  5      (       a'  U" UT R
                  R                  5       U5      nUb  U$ U$ )Nrt  Fc                   >^ ^ U H  u  mnT UL d  M  TU;  ah  0 nS[         R                  " TR                  5      R                  ;   a  TR                  (       d  S OU UU4S jUS'   TR                  " STS0 40 UD6nXRT'   UT   s  $    g )Nr  c                     > [        TU TT5      $ r   r   )r  attr_valr   r   s    rF   rY  LHFTracer._module_getattr.<locals>.maybe_get_proxy_for_attr.<locals>.<lambda>  s    nT4QRT\6]rH   r  r   )r  	signaturer  
parametersparam_shapes_constant)r  collection_to_searchparameter_proxy_cacher  r   	val_proxyr   r   s   `     @rF   maybe_get_proxy_for_attr:HFTracer._module_getattr.<locals>.maybe_get_proxy_for_attrv  s    0DAq1}$99%'F1W5F5FtGXGX5Y5d5dd ,0+E+E %))] !''9 :
 )-(9(9*aR(ZSY(ZI7@!44Q77 1 rH   )
r  r>   r   r   	Parameterr  named_parametersr  r   named_buffers)r   r  r  r  r  maybe_parameter_proxymaybe_buffer_proxys   `      rF   _module_getattrHFTracer._module_getattrq  s    42E::O  (EHH$6$677(@dii88:<Q)% )400++
8U\\0R0R%=dii5579N&" &1--OrH   r  r  r  c                 &    U R                  XU5      $ r   )r  )r   r  r  r  s       rF   r  HFTracer.getattr  s    ##D4IJJrH   c                 d   > [        U SS5      (       a  U" U0 UD6$ X l        [        TU ]  XX45      $ )Nru  F)r  rp  r  ro  )r   r  forwardr   r   r  s        rF   ro  HFTracer.call_module  s;    4/77D+F++#w"1t<<rH   c                     [        X5      $ r   )r  )r   r  s     rF   proxyHFTracer.proxy  s    t""rH   r  .c           
   #     #    U R                    Vs0 s H  o"[        [        [        U5      5      _M     snU l        [        5       U l        U R                  R                  5        H3  u  nu  pE[        [        X45        U R                  R                  U5        M5     / n[        R                  " U5      n[        R                  R                  5        H  u  p8Ub  XLa  M  UR                  S5      (       d  M&  U R                  R                  5        HM  u  pUR                   R                  5        H*  u  pXL d  M  UR#                  XU	45        [        XU
5        M,     MO     M     S v   U R                  R                  5        H  u  nu  p[        [        X55        M     0 U l        [        5       U l        U H  u  pn	[        XU	5        M     g s  snf 7f)Ntransformers)_TORCH_METHODS_TO_PATCHr  r  r   patched_torch_methodssetrs  itemsr  addr  	getmodulesysmodulesr  r  __dict__rA   )r   r  ru  r  r  origpatchedmodule_of_modelr  orig_clspatched_clsr  r  r  s                 rF   patch_for_tracingHFTracer.patch_for_tracing  s     SWRnRn&
Rn+GE6,BCCRn&
" %)%?%?%E%E%G!D/7E4)MMd# &H
 !++D1**,ID*s/I??>22)-)?)?)E)E)G%'*||'9'9';OI''AB< (< *H - 	  $99??AOD)1E4&  B%'"(/$CHCH- )0?&
s   G#GDG<BGconcrete_argsdummy_inputs6complete_concrete_args_with_inputs_not_in_dummy_inputsc           
        > [         R                  " [        U[        R                  R
                  5      (       a  UR                  OU5      nUc  0 nUb  U(       a  UR                  R                  5        HU  nUR                  U;   a  M  UR                  [         R                  R                  L d  M>  [        SUR                   S35      e   UR                  UR                  R                  5        Vs0 s H>  nUR                  U;  d  M  UR                  U;  d  M'  UR                  UR                  _M@     sn5        UR                  R                  5       UR                  5       -
  n[!        5       n	[!        5       n
X/nUR"                  R$                  ['        [(        5      ;   a  [!        SSS9nUR+                  SU5        Ub  [-        U5      O0 nU H{  nX;   a  M
  [        XR.                  5      (       d)  [1        U5      R2                  R5                  S5      (       a!  UR                  U R7                  XXS	95        Mn  [9        S
U S35      e   S n[:        R<                  " X5      nUR                  R                  5        HQ  nUR>                  [         R                  R@                  :X  d  M-  UR                  U;  d  M?  0 USUR                   3'   MS     UU l!        U q"U RG                  U5          [H        TU ]  XS9U l&        Sq" SSS5        U RL                  RN                   H  nURP                  S:X  a  URR                  U;   a  SUl*        [        RV                  Ul        OU/n[X        RZ                  " 5       nU(       aE  UR]                  S5      nSUU'   U[_        UR`                  R                  5       5      -  nU(       a  ME  [c        UR                  5       5       H  nU RL                  Re                  U5        M      URP                  S:X  d  M  SUl        M     U RL                  $ s  snf ! Sq"f = f! , (       d  f       GN9= f)a  
Traces `root` and returns the corresponding FX `torch.fx.Graph` representation. `root` can either be a
`torch.nn.Module` instance or a Python callable. Note that after this call, `self.root` may be different from
the `root` passed in here. For example, when a free function is passed to `trace()`, we will create a
`torch.nn.Module` instance to use as the root and add embedded constants to.

Args:
    root (`torch.nn.Module` or  `Callable`):
        Either a `torch.nn.Module`` or a function to be traced through. If root is not a
        [`~transformers.PreTrainedModel`], then `dummy_inputs` must be passed, otherwise tracing will fail.
    concrete_args (`Dict[str, Any], *optional*):
        Concrete arguments that should not be treated as Proxies
    dummy_inputs (`Dict[str, Any]`, *optional*):
        The dummy inputs needed to handle data-dependent control-flow if `root` is not a
        [`~transformers.PreTrainedModel`]. It can also be used when `root` is a
        [`~transformers.PreTrainedModel`] to specify custom dummy inputs for a subset or all the model inputs.
    complete_concrete_args_with_inputs_not_in_dummy_inputs (`bool`, *optional*, defaults to `True`):
        If `True`, and `dummy_inputs` is specified, every argument that `root` can take that is not in
        `dummy_inputs` and not in `concrete_args` will be added to `concrete_args`, otherwise does nothing.

Returns:
    `torch.fx.Graph`:
        A FX `torch.fx.Graph` representing the semantics of the passed-in `root`.

Nz6You need to specify a default value for the parameter rq  r   r/  rG  r/   )_deserialize_graph_module_CodeOnlyModule)r,  zCould not generate input named z8 for because root is not a transformers.PreTrainedModel.c                 f    [        U [        R                  5      (       a  U R                  S5      $ U $ rX  )r>   r   r   r   )rg  s    rF   to_metaHFTracer.trace.<locals>.to_meta  s'    %..xx''LrH   **r  rn  r   r   r_  )3r  r  r>   r   r   Moduler  r  r  r  r9   r  r   r   updater=   r  r  r  r   r$   r   r   supported_archsr  r  r  rk  r  pytreetree_mapr}  VAR_KEYWORDrr  r
  r  r  tracegraphnodesopru  r   r   rS  OrderedDictr   r   usersreversed
erase_node)r   r  r  r  r  sigparamr  r,  r   sequence_lengthr   num_choicesrE  r+  r  concrete_metasr  to_visit	to_deleter   userr  s                         rF   r  HFTracer.trace  s   @ 
40Q0QW[\ M#(^..0::-==G$5$5$;$;;$']^c^h^h]iij%kll	 1
    !^^2244l2 &78vv]7R &AFFAII%4 nn))+m.@.@.BB *+
.0->>""j1X&YY.11=KLLK('3'?l#R%J# $ 4 455d9P9P9[9[@: : d8858jk"5j\ B5 5  &	
  9^^**,EzzW..:::uzzQ\?\46EJJ<01 - ( ##D)'"W]4]M
"&	 * JJ$$Dww-';;+- "DI !&DI !%vH + 7 7 9I"$LLO'+	! D$88 #(
 !))9 :

--d3 !;
 ww(" 	/ %2 zzch #'	 *)s6   6P7P7 P7:Q<P<Q<Q  Q
Qr  c                 V    [        S UR                  R                  5        5       5      $ )z
Whether the module was instantiated with Proxies. If that is the case, such module cannot be a leaf module
because its attributes are input-dependent.
c              3   B   #    U  H  n[        U[        5      v   M     g 7fr   )r>   r   )r   r  s     rF   r   KHFTracer._stateless_mod_instanciation_depends_on_proxies.<locals>.<genexpr>L  s     M7Lt:dE**7Ls   )anyr  r  )r   r  s     rF   /_stateless_mod_instanciation_depends_on_proxies8HFTracer._stateless_mod_instanciation_depends_on_proxiesG  s"    
 Ms||7J7J7LMMMrH   c                    U R                  U5      (       a  gSnUR                  R                  R                  5       nU SU 3nSn[	        U R
                  U5      (       aE  [        U R
                  U5      UL a  SnO)U SU 3nUS-  n[	        U R
                  U5      (       a  ME  U(       d  U R
                  R                  XA5        U$ )zR
Helper method which tries to insert a module that was not declared as submodule.
r4   r   r  FTr/   )r  r  r  lowerr  r  r  
add_module)r   r  idxmod_namepathalready_inserteds         rF   _insert_module_as_submodule$HFTracer._insert_module_as_submoduleN  s     ??DD==))//11SE" dii&&tyy$'3.#' Zq&D1HC dii&&  II  +rH   c                 6  >  [         TU ]  U5      $ ! [         a|  nU R                  (       ad  [	        [        UR                  5       5      5      S:X  a>  [	        [        UR                  5       5      5      S:X  a  U R                  U5      nUs SnA$ UeSnAff = f)a7  
Helper method to find the qualified name of `mod` in the Module hierarchy of `root`. For example, if `root` has
a submodule named `foo`, which has a submodule named `bar`, passing `bar` into this function will return the
string "foo.bar".

Args:
    mod (str): The `Module` to retrieve the qualified name for.
r   N)	r  path_of_module	NameErrorr  r   r   r  buffersr  )r   r  r  r  r  s       rF   r  HFTracer.path_of_modulef  s    	7)#.. 	//CS^^=M8N4OST4TY\]abebmbmbo]pYquvYv77<G		s!    
BA/BBBBr  module_qualified_namec                 \   > U R                  U5      (       + =(       a    [        TU ]	  X5      $ r   )r  r  is_leaf_module)r   r  r  r  s      rF   r  HFTracer.is_leaf_modulew  s0    HHKK 
QVQXQgR
 	
rH   )is_backward_compatibleobjr   c                     [        US5      " 5       nUR                  R                  R                  S5      (       a  UR                  $ U$ )zCalled when a proxy object is has the keys() method called.
This is what happens when ** is called on a proxy. This should return an iterator if ** is supposed to work in
your custom tracer.
r=   r  )r  r  ru  r  r  )r   r  	attributes      rF   r=   HFTracer.keys|  s>      V,.	88??%%d++&&&rH   )ru  rt  r  rr  rs  rp  r  )NNN)NNT)8r  r  r  r  r  r  bool__annotations__r  r  r   r  r   r  r   r  r   r  r  r1   r   r2   r  r;  r  r?   r   r   r   r   r   rk  r  r  r   r  ro  r  
contextlibcontextmanagerr   r   r  r   r  r   r	   r  r  r  r  r  r   r=   r  r  r  s   @rF   r  r  Z  sO    %)T((,, 	~+%)	 1B0C0C(/[dIeO)-B cm&m47m@DS	mX\]`Xam	c5<<	 m^CL#LKC K3 KtCQTH~ K=# ".eEHHOOXc3h=O,O&P ". ".N 3715GK}EHHOOXc3h%778}  S#X/} tCH~.	}
 AE} 
} }~N299 NQU Nryy S 0"))  "
 
 
PT 

 $/ C  0rH   r  r*  r,  c                    [         R                  " U R                  5      n[        U5      [        UR                  R                  5       5      ::  d_  [        U5      S:X  a  US   OSR                  U5      nSR                  UR                  R                  5       5      n[        SU SU 35      eUR                  R                  5        Vs0 s H+  oUR                  U;  d  M  UR                  UR                  _M-     sn$ s  snf )Nr/   r   , z(The model does not have input(s) named: z&, expected a subset of the following: )r  r  r  r  r  r=   r   joinr   r  r  r9   )r*  r,  r  formatted_input_namesformatted_allowed_input_namesr  s         rF   get_concrete_argsr    s    


EMM
*CCNN$7$7$9 ::25k2Ba2GATYYWbMc(,		#..2E2E2G(H%67L6M N-.0
 	

 (+~~'<'<'>\'>!&&P[B[AFFAII'>\\\s   D#Dr   c                 <    U R                   R                  [        ;   $ r   )r  r  _SUPPORTED_MODELS)r*  s    rF   is_model_supportedr    s    ??##'888rH   c                     [        U 5      (       d:  SR                  [        5      n[        SU R                  R
                   SU 35      eg )Nr  zModel z) is not supported yet, supported models: )r  r   r  rR  r  r  )r*  supported_model_namess     rF   check_if_model_is_supportedr	    sM    e$$ $		*; <!U__--..WXmWno
 	
 %rH   disable_check
tracer_clsc                 ^   Uc  U R                   R                  5       n[        U5      n[        X5      nU(       d  [	        U 5        SU;   a1  [        U R                  SS5      (       d  [        R                  S5        SU;  aB  [        U R                  SS5      (       a&  [        R                  S5        SU R                  l	        U" 5       nUR                  XS9n[        R                  R                  X5      nU R                  Ul        U R                  Ul        U R                   Ul        U$ )a  
Performs symbolic tracing on the model.

Args:
    model ([`PretrainedModel`]):
        The model to trace.
    input_names (`List[str]`, *optional*):
        The names of the inputs of the traced model. If unset, model.dummy_inputs.keys() are used instead.
    disable_check (`bool`, *optional*, defaults to `False`):
        If `True`, no check is done before trying to trace the model, this is mostly usesul for debugging purposes.
    tracer_cls (`Type[HFTracer]`, *optional*, defaults to `HFTracer`):
        The tracer class to use for instantiating the tracer. If unset, `HFTracer` is used instead.

Returns:
    `torch.fx.GraphModule`: A GraphModule constructed by recording operations seen while tracing the model.

Example:

    ```python
    from transformers.utils.fx import symbolic_trace

    traced_model = symbolic_trace(model, input_names=["input_ids", "attention_mask", "token_type_ids"])
    ```
rI  	use_cacheFz|`past_key_values` were specified as input names, but model.config.use_cache = False, this might lead to unexpected behavior.z`past_key_values` were not specified as input names, but model.config.use_cache = True. Setting model.config.use_cache = False.r  )r  r=   r   r  r	  r  rP  loggerwarningr  r  r   r  r
   r  r.  r   )r*  r,  r
  r  r  r  traced_graphtraceds           rF   symbolic_tracer    s    < ((--/{#K%e9M#E*K'kSX0Y0Y#	
 +kSX0Y0Y.	
 "' \F<<<CLXX!!%6FLLFM (-F$LLFMMrH   r   r   )NNg       @FF)F)NN)r   )Nr   FN)
      N)r*  r   )r  rS  r  r  r  r;  r  osr  r  r{  typingr   r   r   r   r   r   torch.utils._pytreeutils_pytreer  r   torch.fxr	   r
   r   r   r   torch.fx._compatibilityr   torch.fx._symbolic_tracer   torch.fx.proxyr   r4   r   cache_utilsr   r   r   r   modeling_utilsr   r   models.autor   models.auto.modeling_autor   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   import_utilsr0   r1   peftr2   
get_loggerr  r  environr@   upperrz  r  r?   r   rG   (_REGULAR_SUPPORTED_MODEL_NAMES_AND_TASKSr[  _REGULAR_SUPPORTED_MODELSitemr>   r   extend_SPECIAL_SUPPORTED_MODELSr]  sortedr  r  r
  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r   r$  r'  r*  r,  r0  r2  r4  rC  rJ  rN  rQ  rS  rU  r`  rc  rn  rv  ry  r{  r  	Embedding
functional	embedding	LayerNorm	GroupNormLinearreluReLUwhereabsr  r   catstackr  mulr   matmulbmmbaddbmmr  repeatrepeat_interleaverollflipindex_selectgatherConv1dConv2dsqueeze	unsqueezer[  one_hotMSELossCrossEntropyLossBCEWithLogitsLossr  r  r  scaled_dot_product_attentionr  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r	  r  r  r   rH   rF   <module>rL     s.          	  
  : :  $ $  < < 1 2 )  E E > $     ,  
		H	%JJNN?B7==?CWW 
 8<&%&&eCcN34& 
#Y&R7, (r '.u%5 " 4D$!(()N)VQU)VW!(()Nt)TU	 5   &%>AZ%Z![\] d
 ejZOS ! J*	E34 3	-T 	- &'D - $( ," '+ !.H #' 8 23! % 89t PA- (, .( 26 .0 49d .*-$-*-"$-&:- NRT---"&,4	HH*,4	HH!!#@,4 
HH*,4 
HH*	,4
 
HHOO_,4 
JJ
,4 
HH6,4 
HHMM=,4 
KK,4 
IIy,4 
LL,,4 
JJ
,4 
IIy,4 
KK,4 
IIy,4  
IIy!,4" 
LL&#,4$ 
LL,%,4& 
IIy',4( 
MM=),4* 
LL.+,4, 
LL,-,4. 
LL,/,40 
41,42 
JJ
3,44 
JJ
5,46 
LL(7,48 
*9,4: 
LL8;,4< 
LL,=,4> 
LL,?,4@ 
HHOO_A,4B 
HHOO_C,4D 
MM=E,4F 
LL.	OO_	LL2	6	HH!<	HH&	HH8	HH :&W,4 Xx/0 ,^ 5 uxx**GG H
))e ))X_' _,	+ 	C7 C$ ;?!!7?+W]-CWZEXXY! x67! 	!H4 @H x7I1J 	"$u+ 	"(D6S_K_B` 	" &uh5RSX5Y -O2<@	  *L29=	  ,N2;?	 c c (SWX[S\J] kv k\]RYY ]T#Y ]9
 (,!)	>>$s)$> > X	>
 >rH   