Ë
    ÜÓ^jäâ  ã                   ój  — d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZ dd	lmZmZ dd
lmZ ddl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 m!Z! ddl"m#Z#m$Z$m%Z%  e!jL                  e'«      Z( G d„ dejR                  «      Z* G d„ dejR                  «      Z+ G d„ dejR                  «      Z, G d„ dejR                  «      Z- G d„ de«      Z. G d„ dejR                  «      Z/e G d„ de«      «       Z0e G d„ de0«      «       Z1 G d „ d!ejR                  «      Z2 G d"„ d#ejR                  «      Z3 G d$„ d%ejR                  «      Z4 G d&„ d'ejR                  «      Z5 G d(„ d)ejR                  «      Z6 G d*„ d+e«      Z7 ed,¬-«       G d.„ d/e0«      «       Z8 ed0¬-«       G d1„ d2e0e«      «       Z9g d3¢Z:y)4zPix2Struct modeling fileé    N)Únné   )Úinitialization)ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)ÚGenerationMixin)Úcreate_bidirectional_maskÚcreate_causal_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚ!CausalLMOutputWithCrossAttentionsÚSeq2SeqLMOutputÚSeq2SeqModelOutput)ÚPreTrainedModel)ÚDUMMY_INPUTSÚ
DUMMY_MASKÚauto_docstringÚis_torchdynamo_compilingÚloggingé   )ÚPix2StructConfigÚPix2StructTextConfigÚPix2StructVisionConfigc                   ó&   ‡ — e Zd Zdˆ fd„	Zd„ Zˆ xZS )ÚPix2StructLayerNormc                 óŠ   •— t         ‰| �  «        t        j                  t	        j
                  |«      «      | _        || _        y)zc
        Construct a layernorm module in the T5 style. No bias and no subtraction of mean.
        N)ÚsuperÚ__init__r   Ú	ParameterÚtorchÚonesÚweightÚvariance_epsilon)ÚselfÚhidden_sizeÚepsÚ	__class__s      €ú}/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/pix2struct/modeling_pix2struct.pyr!   zPix2StructLayerNorm.__init__4   s1   ø€ ô 	‰ÑÔÜ—l‘l¤5§:¡:¨kÓ#:Ó;ˆŒØ #ˆÕó    c                 óž  — |j                  t        j                  «      j                  d«      j	                  dd¬«      }|t        j
                  || j                  z   «      z  }| j                  j                  t        j                  t        j                  fv r%|j                  | j                  j                  «      }| j                  |z  S )Né   éÿÿÿÿT)Úkeepdim)Útor#   Úfloat32ÚpowÚmeanÚrsqrtr&   r%   ÚdtypeÚfloat16Úbfloat16)r'   Úhidden_statesÚvariances      r+   ÚforwardzPix2StructLayerNorm.forward<   s›   € ð !×#Ñ#¤E§M¡MÓ2×6Ñ6°qÓ9×>Ñ>¸rÈ4Ð>ÓPˆØ%¬¯©°H¸t×?TÑ?TÑ4TÓ(UÑUˆð �;‰;×Ñ¤§¡´·±Ð ?Ñ?Ø)×,Ñ,¨T¯[©[×->Ñ->Ó?ˆMà�{‰{˜]Ñ*Ð*r,   )g�íµ ÷Æ°>©Ú__name__Ú
__module__Ú__qualname__r!   r;   Ú__classcell__©r*   s   @r+   r   r   3   s   ø„ õ$ö+r,   r   c                   ód   ‡ — e Zd ZdZdeddfˆ fd„Zdej                  dej                  fd„Zˆ xZ	S )ÚPix2StructVisionEmbeddingsa-  
    Construct the embeddings from patch. In `Pix2Struct` the input is different from classic Vision-transformer models.
    Here the input is a sequence of `seq_len` flattened patches that also combines padding patches (tokens). Each patch
    is represented by a vector of `hidden_size` values.
    ÚconfigÚreturnNc                 ó„  •— t         ‰| �  «        t        j                  |j                  |j
                  «      | _        t        j                  |j                  |j
                  «      | _	        t        j                  |j                  |j
                  «      | _
        t        j                  |j                  «      | _        y ©N)r    r!   r   ÚLinearÚpatch_embed_hidden_sizer(   Úpatch_projectionÚ	EmbeddingÚseq_lenÚrow_embedderÚcolumn_embedderÚDropoutÚdropout_rateÚdropout©r'   rD   r*   s     €r+   r!   z#Pix2StructVisionEmbeddings.__init__S   s}   ø€ Ü‰ÑÔÜ "§	¡	¨&×*HÑ*HÈ&×J\ÑJ\Ó ]ˆÔäŸL™L¨¯©¸×9KÑ9KÓLˆÔÜ!Ÿ|™|¨F¯N©N¸F×<NÑ<NÓOˆÔä—z‘z &×"5Ñ"5Ó6ˆ�r,   Úflattened_patchesc                 ó"  — |d d …d d …df   j                  «       }|d d …d d …df   j                  «       }|d d …d d …dd …f   }| j                  |«      }| j                  |«      }| j                  |«      }||z   |z   }| j	                  |«      }|S )Nr   r   r.   )ÚlongrJ   rM   rN   rQ   )r'   rS   Úrow_indicesÚcol_indicesÚ
embeddingsÚrow_embeddingsÚcol_embeddingss          r+   r;   z"Pix2StructVisionEmbeddings.forward\   sŸ   € ð (ªª1¨a¨Ñ0×5Ñ5Ó7ˆØ'ªª1¨a¨Ñ0×5Ñ5Ó7ˆà-ªa²°A±B¨hÑ7Ðà×*Ñ*Ð+<Ó=ˆ
Ø×*Ñ*¨;Ó7ˆØ×-Ñ-¨kÓ:ˆð   .Ñ0°>ÑAˆ
à—\‘\ *Ó-ˆ
àÐr,   )
r=   r>   r?   Ú__doc__r   r!   r#   ÚTensorr;   r@   rA   s   @r+   rC   rC   L   s7   ø„ ñð7Ð/ð 7°Dõ 7ð¨¯©ð ¸%¿,¹,÷ r,   rC   c                   ó,   ‡ — e Zd Zˆ fd„Z	 	 	 dd„Zˆ xZS )ÚPix2StructVisionAttentionc                 ó|  •— t         ‰| �  «        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        | j                  | j                  z  | _	        t        j                  | j                  | j                  d¬«      | _        t        j                  | j                  | j                  d¬«      | _        t        j                  | j                  | j                  d¬«      | _        t        j                  | j                  | j                  d¬«      | _        d| _        y ©NF©Úbias)r    r!   r(   Úd_kvÚkey_value_proj_dimÚnum_attention_headsÚn_headsÚattention_dropoutrQ   Ú	inner_dimr   rH   ÚqueryÚkeyÚvalueÚoutputÚgradient_checkpointingrR   s     €r+   r!   z"Pix2StructVisionAttention.__init__q   sØ   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔØ"(§+¡+ˆÔØ×1Ñ1ˆŒØ×/Ñ/ˆŒØŸ™¨×(?Ñ(?Ñ?ˆŒä—Y‘Y˜t×/Ñ/°·±ÀeÔLˆŒ
Ü—9‘9˜T×-Ñ-¨t¯~©~ÀEÔJˆŒÜ—Y‘Y˜t×/Ñ/°·±ÀeÔLˆŒ
Ü—i‘i §¡°×0@Ñ0@ÀuÔMˆŒà&+ˆÕ#r,   c                 ó(  ‡ ‡— |j                   dd \  Š}ˆˆ fd„} |‰ j                  |«      «      } |‰ j                  |«      «      } |‰ j                  |«      «      }	t	        j
                  ||j                  dd«      «      }
|�€t	        j                  d‰ j                  ||f|
j                  |
j                  ¬«      }‰ j                  r‰ j                  rd|_        |j                  «       dk(  r*||dd…dddd…f   j                  |j                  «      z   }nw|�||j                  |j                  «      z   }nVt!        «       sLt	        j"                  ‰|f|j                  |j                  ¬«      }||j                  |j                  «      z   }d|z
  }|j%                  |dk(  t	        j&                  |
j                  «      j(                  «      }|
|z  }
t	        j*                  |
t	        j,                  t	        j&                  |
j                  «      j(                  «      «      }
t.        j0                  j3                  |
dt        j4                  ¬	«      j7                  |
«      }t.        j0                  j9                  |‰ j8                  ‰ j                  ¬
«      }t	        j
                  ||	«      }|j                  dd«      j;                  «       j=                  ‰d‰ j>                  «      }‰ jA                  |«      }|f|fz   }|r||fz   }|S )z&
        Self-attention block
        Nr.   c                 ó�   •— | j                  «       j                  ‰d‰j                  ‰j                  «      j	                  dd«      S )Ú
projectionr/   r   r.   )Ú
contiguousÚviewrf   rd   Ú	transpose)ÚstatesÚ
batch_sizer'   s    €€r+   Úto_projection_shapez>Pix2StructVisionAttention.forward.<locals>.to_projection_shapeŽ   s<   ø€ à×$Ñ$Ó&×+Ñ+¨J¸¸D¿L¹LÈ$×JaÑJaÓb×lÑlÐmnÐpqÓrÐrr,   r   r   ©Údevicer6   Tr/   )Údimr6   ©ÚpÚtraining)!Úshaperi   rj   rk   r#   Úmatmulrs   Úzerosrf   rx   r6   rm   r|   Úrequires_gradry   r1   r   r$   Úmasked_fillÚfinfoÚminÚmaxÚtensorr   Ú
functionalÚsoftmaxr2   Útype_asrQ   rq   rr   rh   rl   )r'   r9   Úattention_maskÚposition_biasÚoutput_attentionsÚ
seq_lengthrv   Úquery_statesÚ
key_statesÚvalue_statesÚscoresÚposition_bias_maskedÚattn_weightsÚattn_outputÚoutputsru   s   `              @r+   r;   z!Pix2StructVisionAttention.forward€   s©  ù€ ð "/×!4Ñ!4°R°aÐ!8Ñˆ
�Jõ	sñ +¨4¯:©:°mÓ+DÓEˆñ )¨¯©°-Ó)@ÓAˆ
Ù*¨4¯:©:°mÓ+DÓEˆô —‘˜l¨J×,@Ñ,@ÀÀAÓ,FÓGˆàÑ Ü!ŸK™KØ�D—L‘L *¨jÐ9À&Ç-Á-ÐW]×WcÑWcôˆMð ×*Ò*¨t¯}ª}Ø.2�Ô+à×!Ñ!Ó# qÒ(Ø -°ºqÀ$ÈÊaÐ?OÑ0P×0SÑ0SÐTa×ThÑThÓ0iÑ i‘ØÐ+à -°×0AÑ0AÀ-×BVÑBVÓ0WÑ W‘Ü-Ô/Ü!&§¡Ø Ð,°]×5IÑ5IÐQ^×QdÑQdô"�ð !.°×0AÑ0AÀ-×BVÑBVÓ0WÑ W�à Ñ-ˆMà,×8Ñ8¸È!Ñ9KÌUÏ[É[ÐY_×YeÑYeÓMf×MjÑMjÓkÐØÐ&Ñ&ˆÜ—‘˜6¤5§<¡<´·±¸F¿L¹LÓ0I×0MÑ0MÓ#NÓOˆô —}‘}×,Ñ,¨V¸Ä5Ç=Á=Ð,ÓQ×YÑYÐZ`Óaˆô —}‘}×,Ñ,¨\¸T¿\¹\ÐTX×TaÑTaÐ,Óbˆä—l‘l <°Ó>ˆð "×+Ñ+¨A¨qÓ1×<Ñ<Ó>×CÑCÀJÐPRÐTX×TbÑTbÓcˆà—k‘k +Ó.ˆà�. MÐ#3Ñ3ˆáØ  Ñ/ˆGØˆr,   )NNFr<   rA   s   @r+   r^   r^   p   s   ø„ ô,ð$ ØØ÷Gr,   r^   c                   ó*   ‡ — e Zd Zdefˆ fd„Zd„ Zˆ xZS )ÚPix2StructVisionMlprD   c                 óÀ  •— t         ‰| �  «        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j
                  |j                  d¬«      | _        t        j                  |j                  «      | _        t        |j                     | _        y r`   ©r    r!   r   rH   r(   Úd_ffÚwi_0Úwi_1ÚworO   rP   rQ   r   Údense_act_fnÚactrR   s     €r+   r!   zPix2StructVisionMlp.__init__Ì   ó�   ø€ Ü‰ÑÔÜ—I‘I˜f×0Ñ0°&·+±+ÀEÔJˆŒ	Ü—I‘I˜f×0Ñ0°&·+±+ÀEÔJˆŒ	Ü—)‘)˜FŸK™K¨×);Ñ);À%ÔHˆŒÜ—z‘z &×"5Ñ"5Ó6ˆŒÜ˜&×-Ñ-Ñ.ˆ�r,   c                 ó,  — | j                  | j                  |«      «      }| j                  |«      }||z  }| j                  |«      }t	        | j
                  j                  t        j                  «      r�|j                  | j
                  j                  j                  k7  r`| j
                  j                  j                  t        j                  k7  r/|j                  | j
                  j                  j                  «      }| j                  |«      }|S rG   ©rž   rš   r›   rQ   Ú
isinstancerœ   r%   r#   r\   r6   Úint8r1   ©r'   r9   Úhidden_geluÚhidden_linears       r+   r;   zPix2StructVisionMlp.forwardÔ   ó¿   € Ø—h‘h˜tŸy™y¨Ó7Ó8ˆØŸ	™	 -Ó0ˆØ# mÑ3ˆØŸ™ ]Ó3ˆô �t—w‘w—~‘~¤u§|¡|Ô4Ø×#Ñ# t§w¡w§~¡~×';Ñ';Ò;Ø—‘—‘×$Ñ$¬¯
©
Ò2à)×,Ñ,¨T¯W©W¯^©^×-AÑ-AÓBˆMàŸ™ Ó.ˆØÐr,   )r=   r>   r?   r   r!   r;   r@   rA   s   @r+   r–   r–   Ë   s   ø„ ð/Ð5õ /ör,   r–   c                   óÆ   ‡ — e Zd Zdeddfˆ fd„Z	 	 d	dej                  dej                  dz  dedeej                  ej                  f   eej                     z  fd„Z	ˆ xZ
S )
ÚPix2StructVisionLayerrD   rE   Nc                 ó*  •— t         ‰| �  «        |j                  | _        d| _        t	        |«      | _        t        |«      | _        t        |j                  |j                  ¬«      | _        t        |j                  |j                  ¬«      | _        y )Nr   ©r)   )r    r!   Úchunk_size_feed_forwardÚseq_len_dimr^   Ú	attentionr–   Úmlpr   r(   Úlayer_norm_epsÚpre_mlp_layer_normÚpre_attention_layer_normrR   s     €r+   r!   zPix2StructVisionLayer.__init__é   ss   ø€ Ü‰ÑÔØ'-×'EÑ'EˆÔ$ØˆÔÜ2°6Ó:ˆŒÜ& vÓ.ˆŒÜ"5°f×6HÑ6HÈf×NcÑNcÔ"dˆÔÜ(;¸F×<NÑ<NÐTZ×TiÑTiÔ(jˆÕ%r,   r9   r‰   r‹   c                 óÈ   — |}| j                  |«      }| j                  |||¬«      }|d   }|dd  }||z   }| j                  |«      }| j                  |«      |z   }|f|z   }|S )N)r‰   r‹   r   r   )r²   r®   r±   r¯   )	r'   r9   r‰   r‹   ÚresidualÚself_attention_outputsÚattention_outputr”   Úlayer_outputs	            r+   r;   zPix2StructVisionLayer.forwardò   s“   € ð !ˆð ×5Ñ5°mÓDˆà!%§¡ØØ)Ø/ð "0ó "
Ðð
 2°!Ñ4ÐØ(¨¨Ð,ˆð )¨8Ñ3ˆð ×.Ñ.¨}Ó=ˆØ—x‘x Ó-°Ñ=ˆà�/ GÑ+ˆàˆr,   ©NF)r=   r>   r?   r   r!   r#   r\   ÚboolÚtupler;   r@   rA   s   @r+   r©   r©   è   sz   ø„ ðkÐ/ð k°Dõ kð /3Ø"'ñ	à—|‘|ðð Ÿ™ tÑ+ðð  ð	ð
 
ˆu�|‰|˜UŸ\™\Ð)Ñ	*¨U°5·<±<Ñ-@Ñ	@÷r,   r©   c                   ó†   ‡ — e Zd Zdeddfˆ fd„Z	 	 	 	 ddej                  dej                  dz  deded	edee	z  fd
„Z
ˆ xZS )ÚPix2StructVisionEncoderrD   rE   Nc                 óÐ   •— t         ‰| �  «        || _        t        j                  t        |j                  «      D �cg c]  }t        |«      ‘Œ c}«      | _        d| _	        y c c}w r¸   )
r    r!   rD   r   Ú
ModuleListÚrangeÚnum_hidden_layersr©   Úlayerrm   )r'   rD   Ú_r*   s      €r+   r!   z Pix2StructVisionEncoder.__init__  sP   ø€ Ü‰ÑÔØˆŒÜ—]‘]Ì5ÐQW×QiÑQiÓKjÖ#kÀaÔ$9¸&Õ$AÒ#kÓlˆŒ
Ø&+ˆÕ#ùò $ls   ½A#r9   r‰   r‹   Úoutput_hidden_statesÚreturn_dictc                 óô   — |rdnd }|rdnd }t        | j                  «      D ](  \  }}	|r||fz   } |	|||«      }
|
d   }|sŒ ||
d   fz   }Œ* |r||fz   }|st        d„ |||fD «       «      S t        |||¬«      S )N© r   r   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wrG   rÆ   ©Ú.0Úvs     r+   ú	<genexpr>z2Pix2StructVisionEncoder.forward.<locals>.<genexpr>2  s   è ø€ Òm˜qÐ_`Ñ_lœÑmùs   ‚Š©Úlast_hidden_stater9   Ú
attentions)Ú	enumeraterÁ   rº   r   )r'   r9   r‰   r‹   rÃ   rÄ   Úall_hidden_statesÚall_self_attentionsÚiÚlayer_moduleÚlayer_outputss              r+   r;   zPix2StructVisionEncoder.forward  s¼   € ñ #7™B¸DÐÙ$5™b¸4Ðä(¨¯©Ó4ò 		P‰OˆAˆ|Ù#Ø$5¸Ð8HÑ$HÐ!á(¨¸ÐHYÓZˆMà)¨!Ñ,ˆMâ Ø&9¸]È1Ñ=MÐ<OÑ&OÑ#ð		Pñ  Ø 1°]Ð4DÑ DÐáÜÑm ]Ð4EÐGZÐ$[ÔmÓmÐmÜØ+Ø+Ø*ô
ð 	
r,   )NFFT)r=   r>   r?   r   r!   r#   r\   r¹   rº   r   r;   r@   rA   s   @r+   r¼   r¼     sv   ø„ ð,Ð5ð ,¸$õ ,ð /3Ø"'Ø%*Ø ñ
à—|‘|ð
ð Ÿ™ tÑ+ð
ð  ð	
ð
 #ð
ð ð
ð 
�Ñ	 ÷
r,   r¼   c                   óp   ‡ — e Zd ZU eed<   dZdZed„ «       Z e	j                  «       ˆ fd„«       Zd„ Zˆ xZS )ÚPix2StructPreTrainedModelrD   )ÚimageÚtextFc                 óv   — t        j                  t        «      }t        j                  t        «      }|||dœ}|S )N)Údecoder_input_idsÚ	input_idsÚdecoder_attention_mask)r#   r…   r   r   )r'   rÛ   Ú
input_maskÚdummy_inputss       r+   rÞ   z&Pix2StructPreTrainedModel.dummy_inputsA  s6   € ä—L‘L¤Ó.ˆ	Ü—\‘\¤*Ó-ˆ
à!*Ø"Ø&0ñ
ˆð
 Ðr,   c                 óp  •— t         ‰| �  |«       | j                  j                  }t	        |t
        «      r$t        j                  |j                  |dz  «       yt	        |t        «      �r8t	        | j                  t        «      r | j                  j                  j                  n| j                  j                  }t	        | j                  t        «      r | j                  j                  j                  n| j                  j                  }t        j                  |j                  j                  d||dz  z  ¬«       t!        |j                  d«      r?|j                  j"                  �)t        j$                  |j                  j"                  «       t        j                  |j&                  j                  d||dz  z  ¬«       t!        |j&                  d«      r?|j&                  j"                  �)t        j$                  |j&                  j"                  «       t        j                  |j(                  j                  d||dz  z  ¬«       t!        |j(                  d«      rA|j(                  j"                  �*t        j$                  |j(                  j"                  «       yyyt	        |t*        «      �rþt	        | j                  t        «      r | j                  j                  j                  n| j                  j                  }t	        | j                  t        «      r | j                  j                  j,                  n| j                  j                  }t	        | j                  t        «      r | j                  j                  j.                  n| j                  j.                  }t        j                  |j0                  j                  d|||z  dz  z  ¬«       t        j                  |j2                  j                  d||dz  z  ¬«       t        j                  |j4                  j                  d||dz  z  ¬«       t        j                  |j6                  j                  d|||z  dz  z  ¬«       |j8                  r3t        j                  |j:                  j                  d||dz  z  ¬«       yyt	        |t<        j>                  «      rÊt	        | j                  t        «      r | j                  j                  j                  n| j                  j                  }t        j                  |j                  d||dz  z  ¬«       |j@                  �EtC        |j                  dd«      s-t        j$                  |j                  |j@                     «       yyyt	        |tD        «      rƒt	        | j                  t        «      r | j                  j                  j                  n| j                  j                  }t        j                  |jF                  j                  d||dz  z  ¬«       yt	        |t<        jH                  t<        jJ                  f«      rct        jL                  |j                  d| j                  jN                  ¬«       |j"                  � t        j$                  |j"                  «       yyy)	zInitialize the weightsç      ð?g        g      à¿)r4   Ústdrb   NÚ_is_hf_initializedF)(r    Ú_init_weightsrD   Úinitializer_factorr¢   r   ÚinitÚ	constant_r%   Ú Pix2StructTextDenseGatedActDenser   Útext_configr(   r™   Únormal_rš   Úhasattrrb   Úzeros_r›   rœ   ÚPix2StructTextAttentionrc   Ú	num_headsri   rj   rk   rl   Úhas_relative_attention_biasÚrelative_attention_biasr   rK   Úpadding_idxÚgetattrÚPix2StructTextModelÚlm_headrH   ÚConv2dÚtrunc_normal_Úinitializer_range)r'   ÚmoduleÚfactorr(   r™   rd   rf   r*   s          €r+   rã   z'Pix2StructPreTrainedModel._init_weightsL  s¼  ø€ ô 	‰Ñ˜fÔ%Ø—‘×/Ñ/ˆÜ�fÔ1Ô2Ü�N‰N˜6Ÿ=™=¨&°3©,Õ7Ü˜Ô @ÕAô ˜dŸk™kÔ+;Ô<ð —‘×'Ñ'×3Ò3à—[‘[×,Ñ,ð ô
 4>¸d¿k¹kÔK[Ô3\�4—;‘;×*Ñ*×/Ò/Ðbf×bmÑbm×brÑbrˆDä�L‰L˜Ÿ™×+Ñ+°#¸6ÀkÐVZÑEZÑ;[Õ\Ü�v—{‘{ FÔ+°·±×0@Ñ0@Ð0LÜ—‘˜FŸK™K×,Ñ,Ô-Ü�L‰L˜Ÿ™×+Ñ+°#¸6ÀkÐVZÑEZÑ;[Õ\Ü�v—{‘{ FÔ+°·±×0@Ñ0@Ð0LÜ—‘˜FŸK™K×,Ñ,Ô-Ü�L‰L˜Ÿ™×)Ñ)°¸ÀDÈTÁ>Ñ9RÕSÜ�v—y‘y &Ô)¨f¯i©i¯n©nÐ.HÜ—‘˜FŸI™IŸN™NÕ+ð /IÐ)ä˜Ô 7Õ8ô ˜dŸk™kÔ+;Ô<ð —‘×'Ñ'×3Ò3à—[‘[×,Ñ,ð ô 1;¸4¿;¹;ÔHXÔ0Y�—‘×'Ñ'×,Ò,Ð_c×_jÑ_j×_vÑ_vð ô
 ˜dŸk™kÔ+;Ô<ð —‘×'Ñ'×1Ò1à—[‘[×*Ñ*ð ô �L‰L˜Ÿ™×,Ñ,°3¸FÀ{ÐUgÑGgÐlpÑFpÑ<qÕrÜ�L‰L˜Ÿ™×*Ñ*°¸&ÀKÐQUÑDUÑ:VÕWÜ�L‰L˜Ÿ™×,Ñ,°3¸FÀkÐSWÑFWÑ<XÕYÜ�L‰L˜Ÿ™×-Ñ-°C¸VÈÐRdÑHdÐimÑGmÑ=nÕoØ×1Ò1Ü—‘˜V×;Ñ;×BÑBÈÐRXÐ]hÐmqÑ\qÑRrÖsð 2ä˜¤§¡Ô-ô ˜dŸk™kÔ+;Ô<ð —‘×'Ñ'×3Ò3à—[‘[×,Ñ,ð ô �L‰L˜Ÿ™¨S°fÀÐQUÑ@UÑ6VÕWà×!Ñ!Ð-´g¸f¿m¹mÐMaÐchÔ6iÜ—‘˜FŸM™M¨&×*<Ñ*<Ñ=Õ>ð 7jÐ-ä˜Ô 3Ô4ô ˜dŸk™kÔ+;Ô<ð —‘×'Ñ'×3Ò3à—[‘[×,Ñ,ð ô �L‰L˜Ÿ™×.Ñ.°S¸fÈÐY]ÑH]Ñ>^Ö_Ü˜¤§¡¬B¯I©IÐ 6Ô7Ü×Ñ˜vŸ}™}°3¸D¿K¹K×<YÑ<YÕZØ�{‰{Ð&Ü—‘˜FŸK™KÕ(ð 'ð 8r,   c                 ó8  — | j                   j                  }| j                   j                  }|€t        d«      ‚|j	                  |j
                  «      }|dd d…f   j                  «       |ddd …f<   ||d<   |€t        d«      ‚|j                  |dk(  |«       |S )Nzšself.model.config.decoder_start_token_id has to be defined. In Pix2Struct it is usually set to the pad_token_id. See Pix2Struct docs for more information..r/   r   ).r   z1self.model.config.pad_token_id has to be defined.éœÿÿÿ)rD   Údecoder_start_token_idÚpad_token_idÚ
ValueErrorÚ	new_zerosr}   ÚcloneÚmasked_fill_)r'   rÛ   rû   rü   Úshifted_input_idss        r+   Ú_shift_rightz&Pix2StructPreTrainedModel._shift_right’  s°   € Ø!%§¡×!CÑ!CÐØ—{‘{×/Ñ/ˆà!Ð)Üð<óð ð
 &×/Ñ/°	·±Ó@ÐØ%.¨s°C°R°C¨xÑ%8×%>Ñ%>Ó%@Ð˜#˜q™r˜'Ñ"Ø$:Ð˜&Ñ!àÐÜÐPÓQÐQà×&Ñ&Ð'8¸DÑ'@À,ÔOà Ð r,   )r=   r>   r?   r   Ú__annotations__Úinput_modalitiesÚ_can_compile_fullgraphÚpropertyrÞ   r#   Úno_gradrã   r  r@   rA   s   @r+   rÖ   rÖ   :  sK   ø… àÓØ(Ðà"Ðàñó ðð €U‡]�]ƒ_óB)ó ðB)öJ!r,   rÖ   c                   óÊ   ‡ — e Zd ZU eed<   dZdZdZdgZdefˆ fd„Z	d„ Z
e	 	 	 	 	 ddej                  dz  d	ej                  dz  d
edz  dedz  dedz  deez  fd„«       Zˆ xZS )ÚPix2StructVisionModelrD   rS   )r×   Tr©   c                 óÞ   •— t         ‰| �  |«       || _        t        |«      | _        t        |«      | _        t        |j                  |j                  ¬«      | _
        | j                  «        y ©Nr«   )r    r!   rD   rC   rX   r¼   Úencoderr   r(   r°   Ú	layernormÚ	post_initrR   s     €r+   r!   zPix2StructVisionModel.__init__°  sU   ø€ Ü‰Ñ˜Ô ØˆŒä4°VÓ<ˆŒÜ.¨vÓ6ˆŒä,¨V×-?Ñ-?ÀV×EZÑEZÔ[ˆŒð 	�‰Õr,   c                 ó.   — | j                   j                  S rG   )rX   rJ   ©r'   s    r+   Úget_input_embeddingsz*Pix2StructVisionModel.get_input_embeddings¼  s   € Ø�‰×/Ñ/Ð/r,   Nr‰   r‹   rÃ   rÄ   rE   c                 óÚ  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|€t	        d«      ‚|€#|j                  d¬«      dk7  j                  «       }| j                  |«      }| j                  |||||¬«      }|d   }	| j                  |	«      }	|s|	f}
|
|dd z   S t        |	|j                  |j                  ¬«      S )	a  
        flattened_patches (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_channels x patch_height x patch_width)`):
            Flattened and padded pixel values. These values can be obtained using [`AutoImageProcessor`]. See
            [`Pix2StructVisionImageProcessor.__call__`] for details. Check the [original
            paper](https://huggingface.co/papers/2210.03347) (figure 5) for more details.

        Example:

        ```python
        >>> import httpx
        >>> from io import BytesIO
        >>> from PIL import Image
        >>> from transformers import AutoProcessor, Pix2StructVisionModel

        >>> image_processor = AutoProcessor.from_pretrained("google/pix2struct-textcaps-base")
        >>> model = Pix2StructVisionModel.from_pretrained("google/pix2struct-textcaps-base")

        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> inputs = image_processor(images=image, return_tensors="pt")
        >>> with torch.no_grad():
        ...     outputs = model(**inputs)

        >>> last_hidden_states = outputs.last_hidden_state
        >>> list(last_hidden_states.shape)
        [1, 2048, 768]
        ```
        Nz%You have to specify flattened_patchesr/   ©ry   r   )r‰   r‹   rÃ   rÄ   r   rÌ   )rD   r‹   rÃ   rÄ   rý   ÚsumÚfloatrX   r  r  r   r9   rÎ   )r'   rS   r‰   r‹   rÃ   rÄ   ÚkwargsÚembedding_outputÚencoder_outputsÚsequence_outputÚhead_outputss              r+   r;   zPix2StructVisionModel.forward¿  s  € ðP 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàÐ$ÜÐDÓEÐEàÐ!à/×3Ñ3¸Ð3Ó;¸qÑ@×GÑGÓIˆNàŸ?™?Ð+<Ó=ÐàŸ,™,ØØ)Ø/Ø!5Ø#ð 'ó 
ˆð *¨!Ñ,ˆØŸ.™.¨Ó9ˆáØ+Ð-ˆLØ /°!°"Ð"5Ñ5Ð5äØ-Ø)×7Ñ7Ø&×1Ñ1ô
ð 	
r,   )NNNNN)r=   r>   r?   r   r  Úmain_input_namer  Úsupports_gradient_checkpointingÚ_no_split_modulesr!   r  r   r#   r\   r¹   rº   r   r;   r@   rA   s   @r+   r	  r	  ¨  sÀ   ø… à"Ó"Ø)€OØ!ÐØ&*Ð#Ø0Ð1Ðð
Ð5õ 
ò0ð ð 26Ø.2Ø)-Ø,0Ø#'ñH
à Ÿ<™<¨$Ñ.ðH
ð Ÿ™ tÑ+ðH
ð   $™;ð	H
ð
 # T™kðH
ð ˜D‘[ðH
ð 
Ð+Ñ	+òH
ó ôH
r,   r	  c                   ó*   ‡ — e Zd Zdefˆ fd„Zd„ Zˆ xZS )rç   rD   c                 óÀ  •— t         ‰| �  «        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j
                  |j                  d¬«      | _        t        j                  |j                  «      | _        t        |j                     | _        y r`   r˜   rR   s     €r+   r!   z)Pix2StructTextDenseGatedActDense.__init__  rŸ   r,   c                 ó,  — | j                  | j                  |«      «      }| j                  |«      }||z  }| j                  |«      }t	        | j
                  j                  t        j                  «      r�|j                  | j
                  j                  j                  k7  r`| j
                  j                  j                  t        j                  k7  r/|j                  | j
                  j                  j                  «      }| j                  |«      }|S rG   r¡   r¤   s       r+   r;   z(Pix2StructTextDenseGatedActDense.forward  r§   r,   ©r=   r>   r?   r   r!   r;   r@   rA   s   @r+   rç   rç     s   ø„ ð/Ð3õ /ör,   rç   c                   ó*   ‡ — e Zd Zdefˆ fd„Zd„ Zˆ xZS )ÚPix2StructTextLayerFFrD   c                 óÖ   •— t         ‰| �  «        t        |«      | _        t	        |j
                  |j                  ¬«      | _        t        j                  |j                  «      | _        y r  )r    r!   rç   ÚDenseReluDenser   r(   Úlayer_norm_epsilonÚ
layer_normr   rO   rP   rQ   rR   s     €r+   r!   zPix2StructTextLayerFF.__init__*  sK   ø€ Ü‰ÑÔÜ>¸vÓFˆÔä-¨f×.@Ñ.@Àf×F_ÑF_Ô`ˆŒÜ—z‘z &×"5Ñ"5Ó6ˆ�r,   c                 ór   — | j                  |«      }| j                  |«      }|| j                  |«      z   }|S rG   )r'  r%  rQ   )r'   r9   Úforwarded_statess      r+   r;   zPix2StructTextLayerFF.forward2  s=   € ØŸ?™?¨=Ó9ÐØ×.Ñ.Ð/?Ó@ÐØ%¨¯©Ð5EÓ(FÑFˆØÐr,   r!  rA   s   @r+   r#  r#  )  s   ø„ ð7Ð3õ 7ör,   r#  c                   ó\   ‡ — e Zd Zddededz  fˆ fd„Zed	d„«       Zd
d„Z	 	 	 	 	 dd„Z	ˆ xZ
S )rì   NrD   Ú	layer_idxc                 ó°  •— t         ‰| �  «        || _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _	        |j                  | _        | j                  | j                  z  | _        || _        |€-t        j                  d| j                   j"                  › d�«       t%        j&                  | j
                  | j
                  d¬«      | _        t%        j&                  | j
                  | j
                  d¬«      | _        t%        j&                  | j
                  | j
                  d¬«      | _        t%        j&                  | j
                  | j
                  d¬«      | _        | j                  r/t%        j0                  | j                  | j                  «      | _        d| _        y )NzInstantiating a decoder z³ without passing `layer_idx` is not recommended and will to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` when creating this class.Fra   )r    r!   rî   Úrelative_attention_num_bucketsÚrelative_attention_max_distancer(   rc   rd   rí   rf   rP   rQ   rh   r+  ÚloggerÚwarning_oncer*   r=   r   rH   ri   rj   rk   rl   rK   rï   rm   ©r'   rD   rî   r+  r*   s       €r+   r!   z Pix2StructTextAttention.__init__:  sg  ø€ Ü‰ÑÔØ+FˆÔ(Ø.4×.SÑ.SˆÔ+Ø/5×/UÑ/UˆÔ,Ø!×-Ñ-ˆÔØ"(§+¡+ˆÔØ×'Ñ'ˆŒØ×*Ñ*ˆŒØŸ™¨×(?Ñ(?Ñ?ˆŒØ"ˆŒØÐÜ×ÑØ*¨4¯>©>×+BÑ+BÐ*Cð D,ð ,ôô —Y‘Y˜t×/Ñ/°×1AÑ1AÈÔNˆŒ
Ü—9‘9˜T×-Ñ-¨t×/?Ñ/?ÀeÔLˆŒÜ—Y‘Y˜t×/Ñ/°×1AÑ1AÈÔNˆŒ
Ü—i‘i × 0Ñ 0°$×2BÑ2BÈÔOˆŒà×+Ò+Ü+-¯<©<¸×8[Ñ8[Ð]a×]iÑ]iÓ+jˆDÔ(à&+ˆÕ#r,   c                 óT  — d}|rC|dz  }|| dkD  j                  t        j                  «      |z  z  }t        j                  | «      } n*t        j                  | t        j
                  | «      «       } |dz  }| |k  }|t        j                  | j                  «       |z  «      t        j                  ||z  «      z  ||z
  z  j                  t        j                  «      z   }t        j                  |t        j                  ||dz
  «      «      }|t        j                  || |«      z  }|S )aÒ  
        Adapted from Mesh Tensorflow:
        https://github.com/tensorflow/mesh/blob/0cb87fe07da627bf0b7e60475d59f95ed6b5be3d/mesh_tensorflow/transformer/transformer_layers.py#L593

        Translate relative position to a bucket number for relative attention. The relative position is defined as
        memory_position - query_position, i.e. the distance in tokens from the attending position to the attended-to
        position. If bidirectional=False, then positive relative positions are invalid. We use smaller buckets for
        small absolute relative_position and larger buckets for larger absolute relative_positions. All relative
        positions >=max_distance map to the same bucket. All relative positions <=-max_distance map to the same bucket.
        This should allow for more graceful generalization to longer sequences than the model has been trained on

        Args:
            relative_position: an int32 Tensor
            bidirectional: a boolean - whether the attention is bidirectional
            num_buckets: an integer
            max_distance: an integer

        Returns:
            a Tensor with the same shape as relative_position, containing int32 values in the range [0, num_buckets)
        r   r.   r   )r1   r#   rU   Úabsrƒ   Ú
zeros_likeÚlogr  ÚmathÚ	full_likeÚwhere)Úrelative_positionÚbidirectionalÚnum_bucketsÚmax_distanceÚrelative_bucketsÚ	max_exactÚis_smallÚrelative_position_if_larges           r+   Ú_relative_position_bucketz1Pix2StructTextAttention._relative_position_bucketV  s(  € ð. ÐÙØ˜AÑˆKØÐ!2°QÑ!6× :Ñ :¼5¿:¹:Ó FÈÑ TÑTÐÜ %§	¡	Ð*;Ó <Ñä!&§¡Ð+<¼e×>NÑ>NÐO`Ó>aÓ!bÐ bÐð   1Ñ$ˆ	Ø$ yÑ0ˆð &/Ü�I‰IÐ'×-Ñ-Ó/°)Ñ;Ó<Ü�h‰h�| iÑ/Ó0ñ1à˜YÑ&ñ(÷ ‰"ŒU�Z‰Z‹.ñ	&Ð"ô
 &+§Y¡YØ&¬¯©Ð8RÐT_ÐbcÑTcÓ(dó&
Ð"ð 	œEŸK™K¨Ð2CÐE_Ó`Ñ`ÐØÐr,   c                 óÆ  — |€ | j                   j                  j                  }t        j                  |t        j
                  |¬«      dd…df   |z   }t        j                  |t        j
                  |¬«      ddd…f   }||z
  }| j                  |d| j                  | j                  ¬«      }| j                  |«      }	|	j                  g d¢«      j                  d«      }	|	S )z%Compute binned relative position biasN)r6   rx   F)r:  r;  r<  )r.   r   r   r   )rï   r%   rx   r#   ÚarangerU   rA  r-  r.  ÚpermuteÚ	unsqueeze)
r'   Úquery_lengthÚ
key_lengthrx   Úpast_seen_tokensÚcontext_positionÚmemory_positionr9  Úrelative_position_bucketÚvaluess
             r+   Úcompute_biasz$Pix2StructTextAttention.compute_biasˆ  sÕ   € àˆ>Ø×1Ñ1×8Ñ8×?Ñ?ˆFÜ Ÿ<™<¨¼E¿J¹JÈvÔVÒWXÐZ^ÐW^Ñ_ÐbrÑrÐÜŸ,™, z¼¿¹ÈFÔSÐTXÒZ[ÐT[Ñ\ˆØ+Ð.>Ñ>ÐØ#'×#AÑ#AØØØ×;Ñ;Ø×=Ñ=ð	 $Bó $
Ð ð ×-Ñ-Ð.FÓGˆØ—‘¢	Ó*×4Ñ4°QÓ7ˆØˆr,   c                 óà  — |j                   dd \  }}	|�|j                  | j                  «      nd}
t        |
t        j
                  «      r|
j                  «       n|
}
|du}| j                  |«      }|j                  |d| j                  | j                  «      j                  dd«      }|�Qt        |t        «      rA|j                  j                  | j                  «      }|r|j                  }n|j                   }n|}|r|n|}|rK|rIrG|j"                  | j                     j$                  }|j"                  | j                     j&                  }nÏ| j)                  |«      }| j+                  |«      }|j                  |d| j                  | j                  «      j                  dd«      }|j                  |d| j                  | j                  «      j                  dd«      }|�;|j-                  ||| j                  «      \  }}|rd|j                  | j                  <   t	        j.                  ||j                  dd«      «      }|€¹|j                   d   }| j0                  sZt	        j2                  d| j                  |	|f|j4                  |j6                  ¬	«      }| j8                  r3| j:                  r'd|_        n| j?                  |	||j4                  |
¬
«      }|�#|dd…dd…dd…d|j                   d   …f   }||z   }|}||z  }t@        jB                  jE                  |jG                  «       d¬«      jI                  |«      }t@        jB                  jK                  || jJ                  | j:                  ¬«      }t	        j.                  ||«      }|j                  dd«      jM                  «       }|j                  |d| jN                  «      }| jQ                  |«      }||f}|r||fz   }|S )z€
        Self-attention (if key_value_states is None) or attention over source sentence (provided by key_value_states).
        Nr.   r   r/   r   Tr   éþÿÿÿrw   )rx   rH  r  rz   ))r}   Úget_seq_lengthr+  r¢   r#   r\   rÿ   ri   rr   rf   rd   rs   r	   Ú
is_updatedÚgetÚcross_attention_cacheÚself_attention_cacheÚlayersÚkeysrL  rj   rk   Úupdater~   rî   r   rx   r6   rm   r|   r€   rM  r   r†   r‡   r  rˆ   rQ   rq   rh   rl   )r'   r9   ÚmaskÚkey_value_statesrŠ   Úpast_key_valuesr‹   r  ru   rŒ   rH  Úis_cross_attentionr�   rQ  Úcurr_past_key_valuesÚcurrent_statesrŽ   r�   r�   rG  Úcausal_maskr‘   r’   r“   r”   s                            r+   r;   zPix2StructTextAttention.forwardš  s�  € ð "/×!4Ñ!4°R°aÐ!8Ñˆ
�JØM\ÐMh˜?×9Ñ9¸$¿.¹.ÔIÐnoÐä7AÐBRÔTY×T`ÑT`Ô7aÐ+×1Ñ1Ô3ÐgwÐð .°TÐ9Ðà—z‘z -Ó0ˆØ#×(Ñ(¨°R¸¿¹Àt×G^ÑG^Ó_×iÑiÐjkÐmnÓoˆð Ð&¬:°oÔGZÔ+[Ø(×3Ñ3×7Ñ7¸¿¹ÓGˆJÙ!à'6×'LÑ'LÑ$à'6×'KÑ'KÑ$à#2Ð á-?Ñ)À]ˆÙ¡/±jà-×4Ñ4°T·^±^ÑD×IÑIˆJØ/×6Ñ6°t·~±~ÑF×MÑM‰LàŸ™ .Ó1ˆJØŸ:™: nÓ5ˆLØ#Ÿ™¨°R¸¿¹Àt×G^ÑG^Ó_×iÑiÐjkÐmnÓoˆJØ'×,Ñ,¨Z¸¸T¿\¹\È4×KbÑKbÓc×mÑmÐnoÐqrÓsˆLàÐ*Ø+?×+FÑ+FÀzÐS_Ðae×aoÑaoÓ+pÑ(�
˜Lá%ØAE�O×.Ñ.¨t¯~©~Ñ>ô —‘˜l¨J×,@Ñ,@ÀÀAÓ,FÓGˆàÐ Ø#×)Ñ)¨"Ñ-ˆJØ×3Ò3Ü %§¡Ø˜Ÿ™ j°*Ð=ÀfÇmÁmÐ[a×[gÑ[gô!�ð ×.Ò.°4·=²=Ø26�MÕ/à $× 1Ñ 1Ø 
°6·=±=ÐScð !2ó !�ð ÐØ"¢1¢aªÐ,B¨j×.>Ñ.>¸rÑ.BÐ,BÐ#BÑC�Ø -°Ñ ;�à,ÐØÐ&Ñ&ˆô —}‘}×,Ñ,¨V¯\©\«^ÀÐ,ÓD×LÑLÈVÓTˆÜ—}‘}×,Ñ,¨\¸T¿\¹\ÐTX×TaÑTaÐ,Óbˆä—l‘l <°Ó>ˆà!×+Ñ+¨A¨qÓ1×<Ñ<Ó>ˆØ!×&Ñ& z°2°t·~±~ÓFˆØ—k‘k +Ó.ˆà Ð.ˆáØ  Ñ/ˆGØˆr,   ©FN)Té    é€   )Nr   )NNNNF)r=   r>   r?   r   Úintr!   ÚstaticmethodrA  rM  r;   r@   rA   s   @r+   rì   rì   9  sO   ø„ ñ,Ð3ð ,ÐcfÐimÑcmõ ,ð8 ò- ó ð- ó`ð* ØØØØ÷[r,   rì   c                   ó>   ‡ — e Zd Zddedz  fˆ fd„Z	 	 	 	 	 dd„Zˆ xZS )Ú Pix2StructTextLayerSelfAttentionNr+  c                 óÜ   •— t         ‰| �  «        t        |||¬«      | _        t	        |j
                  |j                  ¬«      | _        t        j                  |j                  «      | _        y )N©rî   r+  r«   ©r    r!   rì   r®   r   r(   r&  r'  r   rO   rP   rQ   r1  s       €r+   r!   z)Pix2StructTextLayerSelfAttention.__init__ú  sU   ø€ Ü‰ÑÔÜ0ØÐ0KÐW`ô
ˆŒô .¨f×.@Ñ.@Àf×F_ÑF_Ô`ˆŒÜ—z‘z &×"5Ñ"5Ó6ˆ�r,   c                 ó–   — | j                  |«      }| j                  ||||||¬«      }	|| j                  |	d   «      z   }|f|	dd  z   }
|
S )N)rX  rŠ   rZ  Ú	use_cacher‹   r   r   ©r'  r®   rQ   )r'   r9   r‰   rŠ   rZ  rj  r‹   r  Únormed_hidden_statesr¶   r”   s              r+   r;   z(Pix2StructTextLayerSelfAttention.forward  sn   € ð  $Ÿ™¨}Ó=ÐØŸ>™>Ø ØØ'Ø+ØØ/ð *ó 
Ðð &¨¯©Ð5EÀaÑ5HÓ(IÑIˆØ Ð"Ð%5°a°bÐ%9Ñ9ˆØˆr,   r_  )NNNFF©r=   r>   r?   rb  r!   r;   r@   rA   s   @r+   re  re  ù  s*   ø„ ñ7ÈSÐSWÉZõ 7ð ØØØØ÷r,   re  c                   ó<   ‡ — e Zd Zddedz  fˆ fd„Z	 	 	 	 dd„Zˆ xZS )Ú!Pix2StructTextLayerCrossAttentionNr+  c                 óÜ   •— t         ‰| �  «        t        |d|¬«      | _        t	        |j
                  |j                  ¬«      | _        t        j                  |j                  «      | _        y )NFrg  r«   rh  )r'   rD   r+  r*   s      €r+   r!   z*Pix2StructTextLayerCrossAttention.__init__  sP   ø€ Ü‰ÑÔÜ0°ÐUZÐfoÔpˆŒÜ-¨f×.@Ñ.@Àf×F_ÑF_Ô`ˆŒÜ—z‘z &×"5Ñ"5Ó6ˆ�r,   c                 ó–   — | j                  |«      }| j                  ||||||¬«      }	|| j                  |	d   «      z   }
|
f|	dd  z   }|S )N)rX  rY  rŠ   rZ  r‹   r   r   rk  )r'   r9   rY  r‰   rŠ   rZ  r‹   r  rl  r¶   r·   r”   s               r+   r;   z)Pix2StructTextLayerCrossAttention.forward"  sm   € ð  $Ÿ™¨}Ó=ÐØŸ>™>Ø ØØ-Ø'Ø+Ø/ð *ó 
Ðð % t§|¡|Ð4DÀQÑ4GÓ'HÑHˆØ�/Ð$4°Q°RÐ$8Ñ8ˆØˆr,   rG   )NNNFrm  rA   s   @r+   ro  ro    s&   ø„ ñ7¨#°©*õ 7ð ØØØ÷r,   ro  c                   óF   ‡ — e Zd Zddedz  fˆ fd„Z	 	 	 	 	 	 	 	 	 dd„Zˆ xZS )ÚPix2StructTextBlockNr+  c                 óŒ   •— t         ‰| �  «        t        |||¬«      | _        t	        ||¬«      | _        t        |«      | _        y )Nrg  )r+  )r    r!   re  Úself_attentionro  Úencoder_decoder_attentionr#  r¯   r1  s       €r+   r!   zPix2StructTextBlock.__init__;  sH   ø€ Ü‰ÑÔä>ØØ(CØô
ˆÔô *KØØô*
ˆÔ&ô
 )¨Ó0ˆ�r,   c                 óè  — | j                  ||||||	¬«      }|d   }|dd  }|j                  t        j                  k(  rht        j                  |«      j                  «       rEt        j                  |j                  «      j                  dz
  }t        j                  || |¬«      }|d u}|r©| j                  ||||||	¬«      }|d   }|j                  t        j                  k(  rht        j                  |«      j                  «       rEt        j                  |j                  «      j                  dz
  }t        j                  || |¬«      }||dd  z   }| j                  |«      }|j                  t        j                  k(  rht        j                  |«      j                  «       rEt        j                  |j                  «      j                  dz
  }t        j                  || |¬«      }|f}||z   S )N)r‰   rŠ   rZ  rj  r‹   r   r   iè  )rƒ   r„   )rY  r‰   rŠ   rZ  r‹   )ru  r6   r#   r7   ÚisinfÚanyr‚   r„   Úclamprv  r¯   )r'   r9   r‰   rŠ   Úencoder_hidden_statesÚencoder_attention_maskÚencoder_decoder_position_biasrZ  rj  r‹   rÄ   r  rµ   Úattention_outputsÚclamp_valueÚdo_cross_attentionÚcross_attention_outputsr”   s                     r+   r;   zPix2StructTextBlock.forwardK  sÓ  € ð "&×!4Ñ!4ØØ)Ø'Ø+ØØ/ð "5ó "
Ðð /¨qÑ1ˆØ2°1°2Ð6Ðð ×Ñ¤%§-¡-Ò/´E·K±KÀÓ4N×4RÑ4RÔ4TÜŸ+™+ m×&9Ñ&9Ó:×>Ñ>ÀÑEˆKÜ!ŸK™K¨¸K¸<È[ÔYˆMà2¸$Ð>ÐÙØ&*×&DÑ&DØØ!6Ø5Ø;Ø /Ø"3ð 'Eó 'Ð#ð 4°AÑ6ˆMð ×"Ñ"¤e§m¡mÒ3¼¿¹ÀMÓ8R×8VÑ8VÔ8XÜ#Ÿk™k¨-×*=Ñ*=Ó>×BÑBÀTÑI�Ü %§¡¨MÀ¸|ÐQ\Ô ]�ð !2Ð4KÈAÈBÐ4OÑ OÐð Ÿ™ Ó/ˆð ×Ñ¤%§-¡-Ò/´E·K±KÀÓ4N×4RÑ4RÔ4TÜŸ+™+ m×&9Ñ&9Ó:×>Ñ>ÀÑEˆKÜ!ŸK™K¨¸K¸<È[ÔYˆMà Ð"ˆàÐ*Ñ*Ð*r,   r_  )	NNNNNNFFTrm  rA   s   @r+   rs  rs  :  s6   ø„ ñ1ÈSÐSWÉZõ 1ð& ØØ"Ø#Ø&*ØØØØ÷<+r,   rs  z3
    The standalone text decoder of Pix2Struct
    )Úcustom_introc                   ó~  ‡ — e Zd ZU eed<   dZdgZddiZdZˆ fd„Z	d„ Z
e	 	 	 	 	 	 	 	 	 	 	 dd
ej                  d	z  dej                  d	z  dej                  d	z  dej                  d	z  dej                  d	z  ded	z  ded	z  ded	z  ded	z  dej                  d	z  ded	z  deej                  df   ez  fd„«       Zˆ xZS )rò   rD   )rØ   rs  zlm_head.weightzembed_tokens.weightTc                 óV  •— t         ‰| �  |«       t        j                  |j                  |j
                  «      | _        t        j                  t        |j                  «      D �cg c]  }t        |t        |dk(  «      |¬«      ‘Œ c}«      | _        t        |j
                  |j                  ¬«      | _        t        j                   |j"                  «      | _        t        j&                  |j
                  |j                  d¬«      | _        | j+                  «        d| _        y c c}w )Nr   rg  r«   Fra   )r    r!   r   rK   Ú
vocab_sizer(   Úembed_tokensr¾   r¿   Ú
num_layersrs  r¹   rÁ   r   r&  Úfinal_layer_normrO   rP   rQ   rH   ró   r  rm   )r'   rD   rÒ   r*   s      €r+   r!   zPix2StructTextModel.__init__–  sá   ø€ Ü‰Ñ˜Ô ÜŸL™L¨×):Ñ):¸F×<NÑ<NÓOˆÔä—]‘]ô ˜v×0Ñ0Ó1öàô $ FÌÈQÐRSÉVËÐ`aÖbòó
ˆŒ
ô !4°F×4FÑ4FÈF×LeÑLeÔ fˆÔÜ—z‘z &×"5Ñ"5Ó6ˆŒä—y‘y ×!3Ñ!3°V×5FÑ5FÈUÔSˆŒð 	�‰ÔØ&+ˆÕ#ùòs   Á&!D&c                 ó   — || _         y rG   )r†  ©r'   Únew_embeddingss     r+   Úset_input_embeddingsz(Pix2StructTextModel.set_input_embeddings©  s
   € Ø*ˆÕr,   NrÛ   r‰   r{  r|  Úinputs_embedsrZ  rj  r‹   rÃ   ÚlabelsrÄ   rE   .c                 ó²  — |�|n| j                   j                  }|�|n| j                   j                  }|	�|	n| j                   j                  }	|�|n| j                   j                  }| j
                  r%| j                  r|rt        j                  d«       d}|�|�t        d«      ‚|�&|j                  «       }|j                  d|d   «      }n!|�|j                  «       dd }nt        d«      ‚|€$| j                  €J d«       ‚| j                  |«      }|\  }}|rc|€a| j                   j                  r5t        t        | j                   ¬«      t        | j                   ¬«      «      }nt        | j                   ¬«      }|€9|�|j!                  «       |z   n|}t#        j$                  |||j&                  ¬	«      }| j                   j(                  rt+        | j                   |||¬
«      }nX|dd…dddd…f   }|j-                  |j.                  ¬«      }d|z
  t#        j0                  |j.                  «      j2                  z  }|�t5        | j                   |||¬«      }|	rdnd}|rdnd}|rdnd}d}d}| j7                  |«      }t9        | j:                  «      D ]K  \  }}|	r||fz   } ||||||||||¬«	      }|d   }|d   }|�	||rdnd   }|sŒ7||d   fz   }|€ŒC||d   fz   }ŒM | j=                  |«      }| j7                  |«      }| j?                  |«      }|	r||fz   }d}|
�…|
j-                  |j&                  «      }
tA        jB                  dd¬«      } ||jE                  «       j                  d|j                  d«      «      |
jE                  «       j                  d«      «      }|stG        d„ ||||||fD «       «      S tI        ||||||¬«      S )aU  
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. Pix2StructText is a model with relative position
            embeddings so you should be able to pad the inputs on both the right and the left.

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

            [What are input IDs?](../glossary#input-ids)

            To know more on how to prepare `input_ids` for pretraining take a look a [Pix2StructText
            Training](./t5#training).

        Example:

        ```python
        >>> from transformers import AutoProcessor, Pix2StructTextModel

        >>> processor = AutoProcessor.from_pretrained("google/pix2struct-textcaps-base")
        >>> model = Pix2StructTextModel.from_pretrained("google/pix2struct-textcaps-base")

        >>> inputs = processor(text="Hello, my dog is cute", return_tensors="pt")
        >>> outputs = model(**inputs)
        >>> loss = outputs.loss
        ```
        NzZ`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...FzTYou cannot specify both decoder_input_ids and decoder_inputs_embeds at the same timer/   zEYou have to specify either decoder_input_ids or decoder_inputs_embedsz<You have to initialize the model with valid token embeddings)rD   )rx   )rD   r�  r‰   rZ  )r6   rà   )rD   r�  r‰   r{  rÆ   )rZ  rj  r‹   r   r   r   r.   é   rú   r4   )Úignore_indexÚ	reductionc              3   ó$   K  — | ]  }|�|–— Œ
 y ­wrG   rÆ   rÈ   s     r+   rË   z.Pix2StructTextModel.forward.<locals>.<genexpr>N  s   è ø€ ò àð �=ô ñùs   ‚)ÚlossÚlogitsrZ  r9   rÎ   Úcross_attentions)%rD   rj  r‹   rÃ   rÄ   rm   r|   r/  Úwarningrý   Úsizerr   r†  Úis_encoder_decoderr	   r   rP  r#   r$   rx   Ú
is_decoderr   r1   r6   r‚   rƒ   r   rQ   rÏ   rÁ   rˆ  ró   r   ÚCrossEntropyLossrq   rº   r   )r'   rÛ   r‰   r{  r|  r�  rZ  rj  r‹   rÃ   rŽ  rÄ   r  Úinput_shaperu   rŒ   Úmask_seq_lengthr^  rÐ   Úall_attentionsÚall_cross_attentionsrŠ   r}  r9   rÒ   rÓ   rÔ   r•  r”  Úloss_fcts                                 r+   r;   zPix2StructTextModel.forward¬  s7  € ðT "+Ð!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø1BÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆà×&Ò&¨4¯=ª=¹YÜ�N‰NØlôð ˆIàÐ  ]Ð%>ÜÐsÓtÐtØÐ"Ø#Ÿ.™.Ó*ˆKØ!Ÿ™ r¨;°r©?Ó;‰IØÐ&Ø'×,Ñ,Ó.¨s°Ð3‰KäÐdÓeÐeàÐ Ø×$Ñ$Ð0ÐpÐ2pÓpÐ0Ø ×-Ñ-¨iÓ8ˆMà!,Ñˆ
�Já˜Ð0Ø�{‰{×-Ò-Ü"5Ü ¨¯©Ô4´lÈ$Ï+É+Ô6Vó#‘ô #/°d·k±kÔ"B�àÐ!ð BQÐA\�×.Ñ.Ó0°:Ò=Ðblð ô #ŸZ™Z¨
°OÈM×L`ÑL`ÔaˆNà�;‰;×!Ò!Ü,Ø—{‘{Ø+Ø-Ø /ô	‰Kð )ª¨D°$ºÐ)9Ñ:ˆKØ%Ÿ.™.¨}×/BÑ/B˜.ÓCˆKØ Ñ,´·±¸M×<OÑ<OÓ0P×0TÑ0TÑTˆKà!Ð-Ü%>Ø—{‘{Ø+Ø5Ø&;ô	&Ð"ñ #7™B¸DÐÙ0™°dˆÙ&7™r¸dÐØˆØ(,Ð%àŸ™ ]Ó3ˆä(¨¯©Ó4ò 	V‰OˆAˆ|Ù#Ø$5¸Ð8HÑ$HÐ!á(ØØØØ%Ø&Ø-Ø /Ø#Ø"3ô
ˆMð *¨!Ñ,ˆMð
 *¨!Ñ,ˆMØ$Ð0Ø0=ÑCT¹aÐZ[Ñ0\Ð-â Ø!/°=ÀÑ3CÐ2EÑ!E�Ø(Ñ4Ø+?À=ÐQRÑCSÐBUÑ+UÑ(ð9	Vð< ×-Ñ-¨mÓ<ˆØŸ™ ]Ó3ˆà—‘˜mÓ,ˆñ  Ø 1°]Ð4DÑ DÐàˆØÐà—Y‘Y˜vŸ}™}Ó-ˆFÜ×*Ñ*¸ÈÔOˆHá˜F×-Ñ-Ó/×4Ñ4°R¸¿¹ÀR»ÓIÈ6×K\ÑK\ÓK^×KcÑKcÐdfÓKgÓhˆDáÜñ ð ØØ#Ø%Ø"Ø(ðôó ð ô 1ØØØ+Ø+Ø%Ø1ô
ð 	
r,   )NNNNNNNNNNN)r=   r>   r?   r   r  r  r  Ú_tied_weights_keysr  r!   rŒ  r   r#   Ú
LongTensorÚFloatTensorr   r¹   rº   r   r;   r@   rA   s   @r+   rò   rò   Š  s]  ø… ð !Ó Ø ÐØ.Ð/ÐØ*Ð,AÐBÐØ&*Ð#ô,ò&+ð ð .2Ø37Ø:>Ø;?Ø15Ø(,Ø!%Ø)-Ø,0Ø*.Ø#'ñt
à×#Ñ# dÑ*ðt
ð ×)Ñ)¨DÑ0ðt
ð  %×0Ñ0°4Ñ7ð	t
ð
 !&× 1Ñ 1°DÑ 8ðt
ð ×'Ñ'¨$Ñ.ðt
ð  ™ðt
ð ˜$‘;ðt
ð   $™;ðt
ð # T™kðt
ð × Ñ  4Ñ'ðt
ð ˜D‘[ðt
ð 
ˆu× Ñ  #Ð%Ñ	&Ð)JÑ	Jòt
ó ôt
r,   rò   zr
    A conditional generation model with a language modeling head. Can be used for sequence generation tasks.
    c                   óÆ  ‡ — e Zd ZU eed<   dZdefˆ fd„Zd„ Zd„ Zde	j                  fd„Zd„ Ze	 	 	 	 	 	 	 	 	 	 	 	 ddej                  d	z  d
ej                  d	z  dej                   d	z  dej"                  d	z  deeej                        d	z  ded	z  dej                   d	z  dej(                  d	z  ded	z  ded	z  ded	z  ded	z  deej                     ez  fd„«       Zˆ xZS )Ú"Pix2StructForConditionalGenerationrD   rS   c                 óÎ   •— t         ‰| �  |«       t        |j                  «      | _        t        |j                  «      | _        |j                  | _        | j                  «        y rG   )
r    r!   r	  Úvision_configr  rò   rè   ÚdecoderÚis_vqar  rR   s     €r+   r!   z+Pix2StructForConditionalGeneration.__init__m  sK   ø€ Ü‰Ñ˜Ô ä,¨V×-AÑ-AÓBˆŒÜ*¨6×+=Ñ+=Ó>ˆŒà—m‘mˆŒð 	�‰Õr,   c                 ó6   — | j                   j                  «       S rG   )r¨  r  r  s    r+   r  z7Pix2StructForConditionalGeneration.get_input_embeddingsx  s   € Ø�|‰|×0Ñ0Ó2Ð2r,   c                 ó:   — | j                   j                  |«       y rG   )r¨  rŒ  rŠ  s     r+   rŒ  z7Pix2StructForConditionalGeneration.set_input_embeddings{  s   € Ø�‰×)Ñ)¨.Õ9r,   rE   c                 ó6   — | j                   j                  «       S rG   )r¨  Úget_output_embeddingsr  s    r+   r­  z8Pix2StructForConditionalGeneration.get_output_embeddings~  s   € Ø�|‰|×1Ñ1Ó3Ð3r,   c                 ó:   — | j                   j                  |«       y rG   )r¨  Úset_output_embeddingsrŠ  s     r+   r¯  z8Pix2StructForConditionalGeneration.set_output_embeddings�  s   € Ø�‰×*Ñ*¨>Õ:r,   Nr‰   rÚ   rÜ   r  rZ  rŽ  Údecoder_inputs_embedsrj  r‹   rÃ   rÄ   c                 ó  — |	�|	n| j                   j                  j                  }	|�|n| j                   j                  }|€| j	                  |||
||¬«      }nI|rGt        |t        «      s7t        |d   t        |«      dkD  r|d   ndt        |«      dkD  r|d   nd¬«      }|d   }|�U|€S|€Q| j                  |«      }|�|n2|j                  | j                   j                  «      j                  «       }d|dd…df<   | j                  |||||||	|
|||¬«      }|s||z   S t        |j                  |j                  |j                   |j"                  |j$                  |j&                  |j(                  |j"                  |j$                  ¬«	      S )	a”  
        flattened_patches (`torch.FloatTensor` of shape `(batch_size, seq_length, hidden_size)`):
            Flattened pixel patches. the `hidden_size` is obtained by the following formula: `hidden_size` =
            `num_channels` * `patch_size` * `patch_size`

            The process of flattening the pixel patches is done by `Pix2StructProcessor`.
        decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Indices of decoder input sequence tokens in the vocabulary.

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

            [What are decoder input IDs?](../glossary#decoder-input-ids)

            Pix2StructText uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If
            `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
            `past_key_values`).

            To know more on how to prepare `decoder_input_ids` for pretraining take a look at [Pix2StructText
            Training](./t5#training).
        decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
            be used by default.
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the masked language modeling loss for the decoder.

        Example:

        Inference:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, Pix2StructForConditionalGeneration

        >>> processor = AutoProcessor.from_pretrained("google/pix2struct-textcaps-base")
        >>> model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-textcaps-base")

        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> inputs = processor(images=image, return_tensors="pt")

        >>> # autoregressive generation
        >>> generated_ids = model.generate(**inputs, max_new_tokens=50)
        >>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
        >>> print(generated_text)
        A stop sign is on a street corner.

        >>> # conditional generation
        >>> text = "A picture of"
        >>> inputs = processor(text=text, images=image, return_tensors="pt", add_special_tokens=False)

        >>> generated_ids = model.generate(**inputs, max_new_tokens=50)
        >>> generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
        >>> print(generated_text)
        A picture of a stop sign with a red stop sign
        ```

        Training:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, Pix2StructForConditionalGeneration

        >>> processor = AutoProcessor.from_pretrained("google/pix2struct-base")
        >>> model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-base")

        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))
        >>> text = "A stop sign is on the street corner."

        >>> inputs = processor(images=image, return_tensors="pt")
        >>> labels = processor(text=text, return_tensors="pt").input_ids

        >>> # forward pass
        >>> outputs = model(**inputs, labels=labels)
        >>> loss = outputs.loss
        >>> print(f"{loss.item():.5f}")
        5.94282
        ```N)rS   r‰   r‹   rÃ   rÄ   r   r   r.   rÌ   )rÛ   r‰   r�  rZ  r{  r|  rj  r‹   rÃ   rŽ  rÄ   )	r”  r•  rZ  Údecoder_hidden_statesÚdecoder_attentionsr–  Úencoder_last_hidden_stater{  Úencoder_attentions)rD   rè   rj  rÄ   r  r¢   r   Úlenr  Únerü   r  r¨  r   r”  r•  rZ  r9   rÎ   r–  rÍ   )r'   rS   r‰   rÚ   rÜ   r  rZ  rŽ  r°  rj  r‹   rÃ   rÄ   r  r9   Údecoder_outputss                   r+   r;   z*Pix2StructForConditionalGeneration.forward„  sÅ  € ðN "+Ð!6‘I¸D¿K¹K×<SÑ<S×<]Ñ<]ˆ	Ø%0Ð%<‘kÀ$Ç+Á+×BYÑBYˆð Ð"Ø"Ÿl™lØ"3Ø-Ø"3Ø%9Ø'ð +ó ‰Oñ ¤¨O¼_Ô!MÜ-Ø"1°!Ñ"4Ü47¸Ó4HÈ1Ò4L˜o¨aÒ0ÐRVÜ14°_Ó1EÈÒ1I˜?¨1Ò-ÈtôˆOð (¨Ñ*ˆàÐÐ"3Ð";Ð@UÐ@]à $× 1Ñ 1°&Ó 9Ðð *Ð5ñ 'à&×)Ñ)¨$¯+©+×*BÑ*BÓC×IÑIÓKð #ð ,-Ð"¢1 a 4Ñ(ð Ÿ,™,Ø'Ø1Ø/Ø+Ø"/Ø#1ØØ/Ø!5ØØ#ð 'ó 
ˆñ Ø" _Ñ4Ð4äØ ×%Ñ%Ø"×)Ñ)Ø+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô

ð 
	
r,   )NNNNNNNNNNNN)r=   r>   r?   r   r  r  r!   r  rŒ  r   ÚModuler­  r¯  r   r#   r£  r¢  Ú
BoolTensorrº   r   r\   r¹   r   r;   r@   rA   s   @r+   r¥  r¥  d  s  ø… ð ÓØ)€Oð	Ð/õ 	ò3ò:ð4 r§y¡yó 4ò;ð ð 7;Ø37Ø59Ø:>ØBFØ(,Ø*.Ø59Ø!%Ø)-Ø,0Ø#'ñb
à ×,Ñ,¨tÑ3ðb
ð ×)Ñ)¨DÑ0ðb
ð !×+Ñ+¨dÑ2ð	b
ð
 !&× 0Ñ 0°4Ñ 7ðb
ð ˜u U×%6Ñ%6Ñ7Ñ8¸4Ñ?ðb
ð  ™ðb
ð × Ñ  4Ñ'ðb
ð  %Ÿ|™|¨dÑ2ðb
ð ˜$‘;ðb
ð   $™;ðb
ð # T™kðb
ð ˜D‘[ðb
ð 
ˆu× Ñ Ñ	!Ð$6Ñ	6òb
ó ôb
r,   r¥  )rÖ   r¥  r	  rò   );r[   r6  r#   r   Ú r   rå   Úactivationsr   Úcache_utilsr   r   r	   Ú
generationr
   Úmasking_utilsr   r   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   r   Úmodeling_utilsr   Úutilsr   r   r   r   r   Úconfiguration_pix2structr   r   r   Ú
get_loggerr=   r/  r¹  r   rC   r^   r–   r©   r¼   rÖ   r	  rç   r#  rì   re  ro  rs  rò   r¥  Ú__all__rÆ   r,   r+   ú<module>rÇ     sÁ  ðñ ã ã Ý å &Ý !ß CÑ CÝ )ß JÝ 9÷õ õ .÷õ ÷ eÑ dð 
ˆ×	Ñ	˜HÓ	%€ô+˜"Ÿ)™)ô +ô2! §¡ô !ôHW §	¡	ô Wôv˜"Ÿ)™)ô ô:&Ð6ô &ôR&
˜bŸi™iô &
ðR ôj! ó j!ó ðj!ðZ ô_
Ð5ó _
ó ð_
ôF r§y¡yô ô:˜BŸI™Iô ô |˜bŸi™iô |ô@ r§y¡yô ôD¨¯	©	ô ô>M+Ð4ô M+ñ` ðôô
R
Ð3ó R
óð
R
ñj ðôô
~
Ð)BÀOó ~
óð
~
òB�r,   