+
    QV-jõ/  ã                   óð  € ^ RI t ^ RIt^ RIHt ^ RIHt ^ RItR]P                  P                  P                  R]P                  P                  P                  R]P                  P                  P                  R]P                  P                  P                  R]P                  P                  P                  R	]P                  P                  P                  R
]P                  P                  P                  R]P                  P                  P                   R]P                  P                  P"                  R]P                  P                  P$                  R]P                  P                  P&                  R]P                  P                  P(                  R]P                  P                  P*                  R]P                  P                  P,                  /tR7R R llt	R7R R llt
R R ltR R ltR R ltR R ltR8R R lltR9R  R! lltR9R" R# lltR:R$ R% lltR:R& R' lltR;R( R) lltR<R* R+ lltR=R, R- lltR. R/ ltR>R0 ltR1 tR2 tR?t]R3 4       t]R4 4       t]R5 4       t]R6 4       t R# )@é    N)Údefaultdict)ÚcontextmanagerÚuniform_Únormal_Ú	constant_Úones_Úzeros_Úeye_Údirac_Úxavier_uniform_Úxavier_normal_Úkaiming_uniform_Úkaiming_normal_Útrunc_normal_Úorthogonal_Úsparse_c          
      óž   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  R,          R\         P                  /# )é   ÚtensorÚaÚbÚ	generatorNÚreturn©ÚtorchÚTensorÚfloatÚ	Generator)Úformats   "Úl/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/transformers/initialization.pyÚ__annotate__r!   *   sF   € ÷ ñ Ü�L‰LðÜ"ðÜ-2ðÜEJÇ_Á_ÐW[ÕE[ðä
‡\�\ñó    c                 óV   € \        V R R4      '       g   \        R,          ! WW#R7      # V # )Ú_is_hf_initializedFr   )r   r   r   ©ÚgetattrÚTORCH_INIT_FUNCTIONS)r   r   r   r   s   &&&&r    r   r   *   s+   € ô �6Ð/°×7Ò7Ü# JÖ/°¸qÔVÐVØ€Mr"   c          
      óž   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  R,          R\         P                  /# )r   r   ÚmeanÚstdr   Nr   r   )r   s   "r    r!   r!   2   sF   € ÷ ñ Ü�L‰LðÜ %ðÜ27ðÜJOÏ/É/Ð\`ÕJ`ðä
‡\�\ñr"   c                 óV   € \        V R R4      '       g   \        R,          ! WW#R7      # V # )r$   Fr   )r)   r*   r   r%   )r   r)   r*   r   s   &&&&r    r   r   2   s+   € ô �6Ð/°×7Ò7Ü# IÖ.¨vÀcÔ_Ð_Ø€Mr"   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   r   Úvalr   )r   r   r   )r   s   "r    r!   r!   :   s)   € ÷ ñ ”e—l‘lð ¬ð ´5·<±<ñ r"   c                 óT   € \        V R R4      '       g   \        R,          ! WR7      # V # )r$   Fr   )r-   r%   )r   r-   s   &&r    r   r   :   s'   € Ü�6Ð/°×7Ò7Ü# KÖ0°ÔAÐAØ€Mr"   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# ©r   r   r   ©r   r   )r   s   "r    r!   r!   @   s"   € ÷ ñ ”%—,‘,ð ¤5§<¡<ñ r"   c                 óR   € \        V R R4      '       g   \        R,          ! V 4      # V # )r$   Fr   r%   ©r   s   &r    r   r   @   s'   € Ü�6Ð/°×7Ò7Ü# GÖ,¨VÓ4Ð4Ø€Mr"   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r0   r1   )r   s   "r    r!   r!   F   s"   € ÷ ñ ”5—<‘<ð ¤E§L¡Lñ r"   c                 óR   € \        V R R4      '       g   \        R,          ! V 4      # V # )r$   Fr	   r%   r3   s   &r    r	   r	   F   s'   € Ü�6Ð/°×7Ò7Ü# HÖ-¨fÓ5Ð5Ø€Mr"   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# r0   r1   )r   s   "r    r!   r!   L   s"   € ÷ ñ ”—‘ð ¤%§,¡,ñ r"   c                 óR   € \        V R R4      '       g   \        R,          ! V 4      # V # )r$   Fr
   r%   r3   s   &r    r
   r
   L   s'   € Ü�6Ð/°×7Ò7Ü# FÖ+¨FÓ3Ð3Ø€Mr"   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   r   Úgroupsr   )r   r   Úint)r   s   "r    r!   r!   R   s)   € ÷ ñ ”5—<‘<ð ¬ð ´U·\±\ñ r"   c                 óT   € \        V R R4      '       g   \        R,          ! WR7      # V # )r$   Fr   )r9   r%   )r   r9   s   &&r    r   r   R   s'   € Ü�6Ð/°×7Ò7Ü# HÖ-¨fÔDÐDØ€Mr"   c                ó’   € V ^8„  d   QhR\         P                  R\        R\         P                  R,          R\         P                  /# ©r   r   Úgainr   Nr   r   )r   s   "r    r!   r!   X   s=   € ÷ ñ œEŸL™Lð ´ð ÌÏÉÐZ^ÕH^ð Ôjo×jvÑjvñ r"   c                 óV   € \        V R R4      '       g   \        R,          ! WVR7      # V # )r$   Fr   ©r>   r   r%   ©r   r>   r   s   &&&r    r   r   X   s+   € Ü�6Ð/°×7Ò7Ü#Ð$5Ö6°vÐT]Ô^Ð^Ø€Mr"   c                ó’   € V ^8„  d   QhR\         P                  R\        R\         P                  R,          R\         P                  /# r=   r   )r   s   "r    r!   r!   ^   s=   € ÷ ñ œ5Ÿ<™<ð ¬uð ÄuÇÁÐY]ÕG]ð Ôin×iuÑiuñ r"   c                 óV   € \        V R R4      '       g   \        R,          ! WVR7      # V # )r$   Fr   r@   r%   rA   s   &&&r    r   r   ^   s+   € Ü�6Ð/°×7Ò7Ü#Ð$4Ö5°fÐS\Ô]Ð]Ø€Mr"   c                óª   € V ^8„  d   QhR\         P                  R\        R\        R\        R\         P                  R,          R\         P                  /# ©r   r   r   ÚmodeÚnonlinearityr   Nr   ©r   r   r   Ústrr   )r   s   "r    r!   r!   d   óU   € ÷ ñ Ü�L‰Lðäðô ðô ð	ô
 �‰ Õ%ðô ‡\�\ñr"   c                 óX   € \        V R R4      '       g   \        R,          ! WW#VR7      # V # )r$   Fr   ©r   rF   rG   r   r%   ©r   r   rF   rG   r   s   &&&&&r    r   r   d   s5   € ô �6Ð/°×7Ò7Ü#Ð$6Ö7Ø˜dÈô
ð 	
ð €Mr"   c                óª   € V ^8„  d   QhR\         P                  R\        R\        R\        R\         P                  R,          R\         P                  /# rE   rH   )r   s   "r    r!   r!   r   rJ   r"   c                 óX   € \        V R R4      '       g   \        R,          ! WW#VR7      # V # )r$   Fr   rL   r%   rM   s   &&&&&r    r   r   r   s5   € ô �6Ð/°×7Ò7Ü#Ð$5Ö6Ø˜dÈô
ð 	
ð €Mr"   c                ó¶   € V ^8„  d   QhR\         P                  R\        R\        R\        R\        R\         P                  R,          R\         P                  /# )	r   r   r)   r*   r   r   r   Nr   r   )r   s   "r    r!   r!   €   s_   € ÷ 
ñ 
Ü�L‰Lð
ä
ð
ô 
ð
ô ð	
ô
 ð
ô �‰ Õ%ð
ô ‡\�\ñ
r"   c           	      óX   € \        V R R4      '       g   \        R,          ! WW#WER7      # V # )r$   Fr   )r)   r*   r   r   r   r%   )r   r)   r*   r   r   r   s   &&&&&&r    r   r   €   s.   € ô �6Ð/°×7Ò7Ü# OÖ4°VÈCÐXYÔoÐoØ€Mr"   c                ó’   € V ^8„  d   QhR\         P                  R\        R\         P                  R,          R\         P                  /# r=   r   )r   s   "r    r!   r!   �   sA   € ÷ ñ Ü�L‰Lðä
ðô �‰ Õ%ðô ‡\�\ñ	r"   c                 óV   € \        V R R4      '       g   \        R,          ! WVR7      # V # )r$   Fr   r@   r%   rA   s   &&&r    r   r   �   s,   € ô
 �6Ð/°×7Ò7Ü# MÖ2°6ÐPYÔZÐZØ€Mr"   c          
      óž   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  R,          R\         P                  /# )r   r   Úsparsityr*   r   Nr   r   )r   s   "r    r!   r!   —   sF   € ÷ ñ Ü�L‰LðÜ$)ðÜ05ðÜINÏÉÐ[_ÕI_ðä
‡\�\ñr"   c                 óV   € \        V R R4      '       g   \        R,          ! WW#R7      # V # )r$   Fr   )rU   r*   r   r%   )r   rU   r*   r   s   &&&&r    r   r   —   s+   € ô �6Ð/°×7Ò7Ü# IÖ.¨vÈcÔgÐgØ€Mr"   c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r   r   Úotherr   r1   )r   s   "r    r!   r!   Ÿ   s-   € ÷ ñ ”%—,‘,ð ¤u§|¡|ð ¼¿¹ñ r"   c                 óÆ   € \        V R R4      '       g:   \        P                  ! 4       ;_uu_ 4        V P                  V4      uuRRR4       # V #   + '       g   i     T # ; i)r$   FN)r&   r   Úno_gradÚcopy_)r   rX   s   &&r    r[   r[   Ÿ   sB   € Ü�6Ð/°×7Ò7Ü�]Š]�_�_Ø—<‘< Ó&÷ Š_à€M÷ Ž_à€Mús   ±AÁA 	c                 óö  € \         P                  P                  P                  V 4      w  r4VR 8X  d   TpM VR8X  d   TpMVR8X  d   W4,           ^,          pRX,          pVR8X  d+   \	        V \
        P                  ! V4      R,          R7       R
# VR8X  d$   \        V \
        P                  ! V4      R7       R
# VR8X  d-   \
        P                  ! ^V,          4      p\        W) V4       R
# \        R	V 24      h)Úfan_inÚfan_outÚfan_avgç      ð?Útruncated_normalg�©Û¶ä%ì?)r*   ÚnormalÚuniformzinvalid distribution N)
r   ÚnnÚinitÚ_calculate_fan_in_and_fan_outr   ÚmathÚsqrtr   r   Ú
ValueError)r   rF   Údistributionr]   r^   ÚdenomÚvarianceÚbounds   &&&     r    Ú_variance_scalingrn   ¦   sÊ   € Ü—h‘h—m‘m×AÑAÀ&ÓI�O€FØˆxÔØ‰Ø	�Ô	Ø‰Ø	�Ô	ØÕ! QÕ&ˆà�U�{€HàÐ)Ô)Ü�f¤$§)¢)¨HÓ"5Ð8KÕ"K×LØ	˜Ô	!Ü�œDŸIšI hÓ/×0Ø	˜Ô	"Ü—	’	˜!˜h�,Ó'ˆÜ�˜ Ö'äÐ0°°Ð?Ó@Ð@r"   c                 óH   € \        V R R4      '       g   \        V RRR7       V # )r$   Fr]   ra   ©rF   rj   ©r&   rn   r3   s   &r    Úlecun_normal_rr   ¼   s$   € Ü�6Ð/°×7Ò7Ü˜& xÐ>PÕQØ€Mr"   c                 óH   € \        V R R4      '       g   \        V RRR7       V # )r$   Fr]   rb   rp   rq   r3   s   &r    Údefault_flax_embed_init_rt   Â   s#   € Ü�6Ð/°×7Ò7Ü˜& x¸hÕGØ€Mr"   c            	   #  óh  "  € \        \        4      p  \         FŽ  pV\        P                  9   g   K  \        P                  V,          p\
        P                  4        FE  p\        W#4      '       g   K  \        W#4      W,          V&   \        W#\        4       V,          4       KG  	  K�  	  Rx € V P                  4        F*  w  r$VP                  4        F  w  r5\        W#V4       K  	  K,  	  R#   T P                  4        F*  w  r$TP                  4        F  w  r5\        Y#T4       K  	  K,  	  i ; i5i)av  
Guard the `torch.nn.init` primitive functions to behave exactly like the functions in this file, i.e. be
protected against the `_is_hf_initialized` flag to avoid re-init if the param was already loaded.

Usually, all models are using the init from `transformers` which are already guarded, but just to make extra sure
and for remote code, we also use this context manager.
N)r   ÚdictÚTORCH_MODULES_TO_PATCHÚsysÚmodulesr'   ÚkeysÚhasattrr&   ÚsetattrÚglobalsÚitems)Ú	originalsÚmodule_nameÚmoduleÚ	func_nameÚ	functionsÚfuncs         r    Úguard_torch_init_functionsr…   Û   sä   é € ô œDÓ!€Ið1ç1ˆKØœcŸk™kÖ)ÜŸ™ [Õ1�Ü!5×!:Ñ!:Ö!<�IÜ˜v×1Ô1Ü7>¸vÓ7Q˜	Õ)¨)Ñ4Ü ´7³9¸YÕ3GÖHó "=ñ 2ó 	ð "+§¡Ö!2ÑˆFØ#,§?¡?Ö#4‘�	Ü˜¨4Ö0ó $5ó "3ø §¡Ö!2ÑˆFØ#,§?¡?Ö#4‘�	Ü˜¨4Ö0ó $5ò "3üs)   ‚D2“C/ ³<C/ Á4;C/ Â/A D2Ã/A D/Ä/D2c            	   #  óš  "  € ^RI Hp  R p\        \        4      p \         F  pV\
        P                  9   g   K  \
        P                  V,          p\        P                  4        F6  p\        WE4      '       g   K  \        WE4      W$,          V&   \        WEV4       K8  	  K�  	  V P                  pWn        Rx € VP                  4        F*  w  rGVP                  4        F  w  rX\        WEV4       K  	  K,  	  W`n        R#   TP                  4        F*  w  rGTP                  4        F  w  rX\        YET4       K  	  K,  	  XT n        i ; i5i)aS  
Disable weight initialization both at the torch-level, and at the transformers-level (`init_weights`).
This is used to speed-up initializing an empty model with deepspeed, as we do not initialize the model on meta device
with deepspeed, but we still don't need to run expensive weight initializations as we are loading params afterwards.
©ÚPreTrainedModelc                  ó   € R # ©N© ©ÚargsÚkwargss   *,r    Ú
empty_funcÚ#no_init_weights.<locals>.empty_funcÿ   ó   € Ùr"   N)Úmodeling_utilsrˆ   r   rv   rw   rx   ry   r'   rz   r{   r&   r|   Úinit_weightsr~   )	rˆ   r�   r   r€   r�   r‚   Úoriginal_init_weightsrƒ   r„   s	            r    Úno_init_weightsr•   ö   s  é € õ 0òô œDÓ!€Ið=ç1ˆKØœcŸk™kÖ)ÜŸ™ [Õ1�Ü!5×!:Ñ!:Ö!<�IÜ˜v×1Ô1Ü7>¸vÓ7Q˜	Õ)¨)Ñ4Ü °:Ö>ó "=ñ 2ð !0× <Ñ <ÐØ'1Ô$ãð "+§¡Ö!2ÑˆFØ#,§?¡?Ö#4‘�	Ü˜¨4Ö0ó $5ñ "3ð (=Ö$øð	 "+§¡Ö!2ÑˆFØ#,§?¡?Ö#4‘�	Ü˜¨4Ö0ó $5ñ "3ð (=ˆÕ$üs)   ‚EœD ¼<D Á=>D Â;AEÄAEÅEc               #  ór   "  € ^RI Hp  R p V P                  pWn        Rx € W n        R#   XT n        i ; i5i)a  
Disable weight tying during loading with `from_pretrained`. This is needed as we want to have access to ALL
weights in the state_dict during `from_pretrained`, and otherwise tying them would remove them from it, as it's
called in `post_init` when instantiating.
r‡   c                  ó   € R # rŠ   r‹   rŒ   s   *,r    r�   Ú"no_tie_weights.<locals>.empty_func$  r‘   r"   N)r’   rˆ   Útie_weights)rˆ   r�   Úoriginal_tie_weightss      r    Úno_tie_weightsr›     s:   é € õ 0òð;Ø.×:Ñ:ÐØ&0Ô#ãð ';Ö#øÐ&:ˆÕ#üs   ‚
7�+ £7«	4´7c               #  ó’   a"  € \         P                  oV3R lp V \         n         Rx € S\         n        R#   S\         n        i ; i5i)av  
During meta-device model initialisation, ``torch.linspace`` produces meta
tensors that have no data.  Custom models loaded from the Hub (remote code)
often call ``.item()`` on these tensors to compute scalar hyperparameters
(e.g. stochastic-depth / drop-path schedules).  Native transformers models
already pass ``device="cpu"`` explicitly for such calls (see e.g.
``modeling_swin.py``, ``modeling_pvt_v2.py``), but remote-code models
written before v5 do not.

This context manager patches ``torch.linspace`` to default to
``device="cpu"`` when no explicit device is requested, matching the best
practice already used throughout transformers.  Calls that supply an
explicit ``device`` argument (e.g. ``device=self.logits.device``) are left
untouched.  ``torch.arange`` is intentionally NOT patched because it is
used in RoPE computations where the device must match model parameters.
c                  ó8   <€ VP                  R R4       S! V / VB # )ÚdeviceÚcpu)Ú
setdefault)r�   rŽ   Úoriginal_linspaces   *,€r    Ú_safe_linspaceÚ5meta_device_safe_creation_ops.<locals>._safe_linspaceE  s#   ø€ Ø×Ñ˜( EÔ*Ù  $Ð1¨&Ñ1Ð1r"   N)r   Úlinspace)r¢   r¡   s    @r    Úmeta_device_safe_creation_opsr¥   1  s7   øé € ô$ Ÿ™Ðõ2ð $„E„Nð+Ûà*ŒŽøÐ*Œ�üs   ƒ"A¦7 ªA·AÁA)ç        r`   N)é   )r`   N)r   r]   Ú
leaky_reluN)r¦   r`   g       Àg       @N)r§   N)g{®Gáz„?N)r]   rb   )
ztorch.nn.initztorch.nn.modules.activationztorch.nn.modules.transformerztorch.nn.modules.linearztorch.nn.modules.lossztorch.nn.modules.batchnormztorch.nn.modules.convztorch.nn.modules.normalizationztorch.nn.modules.rnnztorch.nn.modules.sparse)!rg   rx   Úcollectionsr   Ú
contextlibr   r   rd   re   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r'   r[   rn   rr   rt   rw   r…   r•   r›   r¥   r‹   r"   r    Ú<module>r«      sÞ  ðó Û 
Ý #Ý %ã ð �—‘—‘×&Ñ&Øˆu�x‰x�}‰}×$Ñ$Ø�—‘—‘×(Ñ(ØˆU�X‰X�]‰]× Ñ Øˆe�h‰h�m‰m×"Ñ"Ø
ˆE�H‰H�M‰M×ÑØˆe�h‰h�m‰m×"Ñ"Ø�u—x‘x—}‘}×4Ñ4Ø�e—h‘h—m‘m×2Ñ2Ø˜Ÿ™Ÿ™×6Ñ6Ø�u—x‘x—}‘}×4Ñ4Ø�U—X‘X—]‘]×0Ñ0Ø�5—8‘8—=‘=×,Ñ,Øˆu�x‰x�}‰}×$Ñ$ðÐ ÷$÷õõõõ÷÷÷÷÷÷
÷÷õôAò,òðÐ ð ñ1ó ð1ð4 ñ!=ó ð!=ðH ñ;ó ð;ð* ñ+ó ò+r"   