ó
    qyüi1'  ã            
       ó„  • S SK r S SKrS SKrS SKrS SKJrJr  S SKJr  S SK	J
r
  \R                  " S5      rS\S\4S jrS$S	\\   S\4S
 jjrS\\\
4   S\\\
4   4S jr\R                  " S5      rS\S\4S jrS rS rSSSSSSSSS.rS rS%S jr\ " S S5      5       r S&S\S \S!\S"\ R:                  S-  4S# jjrg)'é    N)ÚOrderedDictÚdefaultdict)Ú	dataclass)ÚAnyz(?<=\.)(\d+)(?=\.|$)ÚkeyÚreturnc                 ó.   • [         R                  SU 5      $ )zBReplace every dot-delimited integer with '*' to get the structure.Ú*)Ú	_DIGIT_RXÚsub)r   s    Ú^/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/utils/loading_report.pyÚ_pattern_ofr      s   € ä�=‰=˜˜cÓ"Ð"ó    Úvaluesc                 óÈ   • [        U 5      S:X  a  [        U S   5      $ [        U 5      n [        U 5      U:”  a  U S    SU S    3$ SR                  [	        [        U 5      5      $ )zEFormat a list of ints as single number, {a, ..., b}, or first...last.é   r   z...éÿÿÿÿz, )ÚlenÚstrÚsortedÚjoinÚmap)r   Úcutoffs     r   Ú_fmt_indicesr      s`   € ä
ˆ6ƒ{�aÓÜ�6˜!‘9‹~ÐÜ�F‹^€FÜ
ˆ6ƒ{�VÓØ˜‘)�˜C  r¡
˜|Ð,Ð,Ø�9‰9”Sœ˜fÓ%Ó&Ð&r   Úmappingc           	      ó¢  • Sn[        U [        5      (       d  U  Vs0 s H  o"U_M     n nSn[        [        5      nU R	                  5        H—  u  pE[
        R                  U5      n[        U5      n[        U5       HP  u  p‰[        X7   5      U::  a  X7   R                  [        5       5        X7   U   R                  [        U	5      5        MR     X7   R                  U5        M™     0 n
UR	                  5        H¬  u  p{USS US   p\UR                  S5      nUS   n[        S[        U5      5       Hk  nUS-
  [        U5      :  aJ  XÈS-
     (       a>  [!        [#        XÈS-
     5      5      n[        XÈS-
     5      S:”  a  USU-   S	-   -  nO
Xï-  nOUS-  nXíU   -  nMm     XZU'   M®     [%        U
5      nU(       a  UR'                  5       $ U$ s  snf )
z¨
Merge keys like 'layers.0.x', 'layers.1.x' into 'layers.{0, 1}.x'
BUT only merge together keys that have the exact same value.
Returns a new dict {merged_key: value}.
FTNr   r
   r   r   Ú{Ú})Ú
isinstanceÚdictr   ÚlistÚitemsr   Úfindallr   Ú	enumerater   ÚappendÚsetÚaddÚintÚsplitÚranger   r   r   Úkeys)r   Únot_mappingÚkÚbucketr   ÚvalÚdigsÚpattÚiÚdÚ	out_itemsr   ÚsetsÚpartsÚfinalÚinsertÚouts                    r   Úupdate_key_namer:   )   s¶  € ð €KÜ�gœt×$Ñ$Ù!(Ó)¢˜A�a’4¡ˆÐ)Øˆä.9¼$Ó.?€FØ—M‘M–O‰ˆÜ× Ñ  Ó%ˆÜ˜3ÓˆÜ˜d–O‰DˆAÜ�6‘<Ó  AÓ%Ø‘×#Ñ#¤C£EÔ*Ø‰L˜‰O×Ñ¤ A£Ö'ñ $ð 	‰×Ñ˜CÖ ñ $ð €IØŸ™ž‰ˆØ˜3˜B�K ¨¡ˆcØ—
‘
˜3“ˆØ�a‘ˆÜ�qœ#˜e›*Ö%ˆAØ�1‰u”s˜4“yÓ  T¨a©%§[Ü%¤f¨T°a±%©[Ó&9Ó:�Ü�t ™E‘{Ó# aÓ'Ø˜S 6™\¨CÑ/Ñ/‘Eà‘O‘Eà˜‘�Ø˜1‘XÑŠEñ &ð �%Óñ 'ô  �iÓ
 €CÞØ�x‰x‹zÐØ€JùòC *s   œGz\x1b\[[0-9;]*mÚsc                 ó@   • [         R                  S[        U 5      5      $ )NÚ )Ú_ansi_rer   r   )r;   s    r   Ú_strip_ansir?   Y   s   € Ü�<‰<˜œC ›FÓ#Ð#r   c           	      ój   • [        U 5      n[        SU[        [        U5      5      -
  5      nUSU-  -   $ )Nr   Ú )r   Úmaxr   r?   )ÚtextÚwidthÚtÚpads       r   Ú_padrG   ]   s3   € ÜˆD‹	€AÜ
ˆa�œœ[¨›^Ó,Ñ,Ó
-€CØˆs�S‰y‰=Ðr   c           
      ó–  • U (       a  [        [        U/U -   6 5      OU/nU Vs/ s H  n[        S U 5       5      PM     nnSR                  S [        X5       5       5      nSR                  S U 5       5      nU  Vs/ s H$  nSR                  S [        Xt5       5       5      PM&     nnSR                  XV/U-   5      $ s  snf s  snf )Nc              3   óJ   #   • U  H  n[        [        U5      5      v •  M     g 7f©N)r   r?   )Ú.0Úxs     r   Ú	<genexpr>Ú_make_table.<locals>.<genexpr>f   s   é € Ð3ªs¨!”#”k !“n×%Ð%ªsùs   ‚!#z | c              3   ó<   #   • U  H  u  p[        X5      v •  M     g 7frJ   ©rG   )rK   ÚhÚws      r   rM   rN   g   s   é € ÐIÒ4H©D¨AœT !ŸZ˜ZÒ4Hùó   ‚z-+-c              3   ó,   #   • U  H
  nS U-  v •  M     g7f)Ú-N© )rK   rR   s     r   rM   rN   h   s   é € Ð2ª6 a˜# ž'ª6ùs   ‚c              3   ó<   #   • U  H  u  p[        X5      v •  M     g 7frJ   rP   )rK   ÚcrR   s      r   rM   rN   i   s   é € Ð=ªn¡d a”t˜A—z�zªnùrS   Ú
)r!   ÚziprB   r   )	ÚrowsÚheadersÚcolsÚcolÚwidthsÚheader_lineÚsep_lineÚrÚbodys	            r   Ú_make_tablerd   c   s´   € æ-1Œ4”�w�i $Ñ&Ð(Ô)¸°y€DÙ?CÓDºt¸ŒcÑ3©sÓ3Ö3¹t€FÐDØ—*‘*ÑI´C¸Ô4HÓIÓI€KØ�z‰zÑ2©6Ó2Ó2€HÙGKÓLÂtÀ!ˆE�J‰JÑ=¬c°!¬nÓ=Ö=Át€DÐLØ�9‰9�kÐ,¨tÑ3Ó4Ð4ùò	 Eùò Ms   ¤CÁ?+Cz[0mz[31mz[33mz[38;5;208mz[35mz[1mz[3mz[2m)ÚresetÚredÚyellowÚorangeÚpurpleÚboldÚitalicÚdimc                 óx   • [         R                  R                  5       (       a  [        U    U  [        S    3$ U $ )zdReturn color/style-formatted input `s` if `sys.stdout` is interactive, e.g. connected to a terminal.re   )ÚsysÚstdoutÚisattyÚPALETTE)r;   Úcolors     r   Ú_stylers   y   s8   € ä
‡z�z×Ñ×ÑÜ˜%‘.Ð! ! ¤W¨WÑ%5Ð$6Ð7Ð7àˆr   c                 óf   •  [         R                  " 5       R                  $ ! [         a    U s $ f = frJ   )ÚshutilÚget_terminal_sizeÚcolumnsÚ	Exception)Údefaults    r   Ú_get_terminal_widthrz   �   s0   € ðÜ×'Ò'Ó)×1Ñ1Ð1øÜó ØŠðús   ‚! ¡0¯0c                   ó¦   • \ rS rSr% Sr\\   \S'   \\   \S'   \\\\\	   \\	   4      \S'   \
\   \S'   \\\4   \S'   S rS	 rS
\S-  4S jrSrg)ÚLoadStateDictInfoéˆ   a2  
Mutable container for state-dict loading results and diagnostics. Each entry in this structure is mutable,
and will usually be mutated in-place during the loading pipeline.

Attributes:
    missing_keys (`set[str]`):
        Keys that are missing from the loaded checkpoints but expected in the model's architecture.
    unexpected_keys (`set[str]`):
        Keys that are found in the checkpoints, but not expected in the model's architecture.
    mismatched_keys (`set[tuple[str, tuple[int], tuple[int]]]`):
        Keys that are found in the checkpoints and are expected in the model's architecture, but with a different shape.
    error_msgs ( `list[str]`):
        Some potential error messages.
    conversion_errors (`dict[str, str]`):
        Errors happening during the on-the-fly weight conversion process.
Úmissing_keysÚunexpected_keysÚmismatched_keysÚ
error_msgsÚconversion_errorsc                 ód   • U R                   U R                   Vs1 s H  oS   iM	     sn-  $ s  snf )zMReturn all effective missing keys, including `missing` and `mismatched` keys.r   )r~   r€   )Úselfr-   s     r   Úmissing_and_mismatchedÚ(LoadStateDictInfo.missing_and_mismatched¡   s/   € à× Ñ °$×2FÒ2FÓ#GÒ2F¨Q a¤DÑ2FÑ#GÑGÐGùÒ#Gs   š-c                 ó`   • U R                   U R                  U R                  U R                  S.$ )N©r~   r   r€   r�   rˆ   )r„   s    r   Úto_dictÚLoadStateDictInfo.to_dict¥   s0   € ð !×-Ñ-Ø#×3Ñ3Ø#×3Ñ3ØŸ/™/ñ	
ð 	
r   r   Nc           	      ó¼  • [        5       n/ nSnU R                  (       a\  US[        SS5       S3[        SS5      -   -  n[        U R                  5       H#  n[        SS5      nUR	                  XES	S	/5        M%     U R
                  (       a[  US[        S
S5       S3[        SS5      -   -  n[        U R
                  5       H"  n[        SS5      nUR	                  XES	/5        M$     U R                  (       a£  US[        SS5       S3[        SS5      -   -  nU R                   VVVs0 s H	  u  pgo†Xx4_M     n	nnn[        U	5      R                  5        HB  u  n
u  p¼[        SS5      nU
US[        U5       S[        U5       3/nUR	                  U5        MD     U R                  (       aq  US[        SS5       S3[        SS5      -   -  n[        U R                  5      R                  5        H*  u  pN[        SS5      nSU S3nUR	                  XEU/5        M,     [        U5      S:X  a  gSS/nUS:”  a  US/-  nOUS	S	/-  n[        UUS9nUU-   nU$ s  snnnf ) z/Generate the minimal table of a loading report.z

Notes:z
- zUNEXPECTED:rh   Ú	zbcan be ignored when loading from different task/architecture; not ok if you expect identical arch.rk   Ú
UNEXPECTEDr=   zMISSING:rf   zsthose params were newly initialized because missing from the checkpoint. Consider training on your downstream task.ÚMISSINGz	MISMATCH:rg   zRckpt weights were loaded, but they did not match the original empty weight shapes.ÚMISMATCHz$Reinit due to size mismatch - ckpt: z
 vs model:zCONVERSION:ri   z$originate from the conversion schemeÚ
CONVERSIONz

r   NÚKeyÚStatuséÈ   ÚDetails)r\   )rz   r   rs   r:   r%   r~   r€   r"   r   r‚   r   rd   )r„   Úterm_wr[   Útipsr-   ÚstatusÚaÚbrX   Úiteratorr   Ú
shape_ckptÚshape_modelÚdataÚvÚ_detailsr\   ÚtableÚreports                      r   Úcreate_loading_reportÚ'LoadStateDictInfo.create_loading_report®   s›  € ä$Ó&ˆàˆØˆØ××Ø�dœ6 -°Ó:Ð;¸2Ð>ÄØtØóBñ ñ ˆDô % T×%9Ñ%9Ö:�Ü ¨hÓ7�Ø—‘˜Q¨¨BÐ/Ö0ñ ;ð ××Ø�dœ6 *¨eÓ4Ð5°RÐ8¼6ð FØó<ñ ñ ˆDô % T×%6Ñ%6Ö7�Ü 	¨5Ó1�Ø—‘˜Q¨˜OÖ,ñ 8ð ××Ø�dœ6 +¨xÓ8Ð9¸Ð<¼vØdÐfnó@ñ ñ ˆDð 26×1EÒ1EÕFÒ1E¡g a¨A˜A˜6š	Ñ1EˆHÒFÜ2AÀ(Ó2K×2QÑ2QÖ2SÑ.�Ñ.�jÜ 
¨HÓ5�àØØ:¼3¸z»?Ð:KÈ:ÔVYÐZeÓVfÐUgÐhð�ð
 —‘˜DÖ!ñ 3Tð ×!×!Ø�dœ6 -°Ó:Ð;¸2Ð>ÄØ6¸óBñ ñ ˆDô (¨×(>Ñ(>Ó?×EÑEÖG‘�Ü ¨hÓ7�Ø! !  D˜>�Ø—‘˜Q¨Ð1Ö2ñ Hô ˆt‹9˜‹>Øà˜(Ð#ˆØ�C‹<Ø˜	�{Ñ"‰Gà˜˜B�xÑˆGÜ˜D¨'Ñ2ˆØ˜‘ˆàˆùô? Gs   Ä)IrV   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r&   r   Ú__annotations__Útupler(   r!   r    r…   r‰   r¢   Ú__static_attributes__rV   r   r   r|   r|   ˆ   so   ‡ ñð" �c‘(ÓØ˜‘XÓØ˜˜s E¨#¡J°°c±
Ð:Ñ;Ñ<Ó<Ø�S‘	ÓØ˜C ˜H‘~Ó%òHò
ð; s¨T¡z÷ ;r   r|   Úpretrained_model_name_or_pathÚignore_mismatched_sizesÚloading_infoÚloggerc                 ó"  • Uc  [         R                  " [        5      nUR                  (       aK  SR	                  UR                  5      nSU;   a  US-  n[        SU R                  R                   SU 35      eUR                  5       nUc  g[        S    U R                  R                   S[        S	    S
U S3nUR                  Xv-   5        UR                  (       a  [        S5      eU(       d  UR                  (       a  [        S5      egg)zÂ
Log a readable report about state_dict loading issues.

This version is terminal-size aware: for very small terminals it falls back to a compact
Key | Status view so output doesn't wrap badly.
Nz
	zsize mismatchzb
	You may consider adding `ignore_mismatched_sizes=True` to `from_pretrained(...)` if appropriate.z#Error(s) in loading state_dict for z:
	rj   z LOAD REPORTre   z from: rY   zˆWe encountered some issues during automatic conversion of the weights. For details look at the `CONVERSION` entries of the above report!zjYou set `ignore_mismatched_sizes` to `False`, thus raising an error. For details look at the above report!)ÚloggingÚ	getLoggerr¤   r�   r   ÚRuntimeErrorÚ	__class__r¢   rq   Úwarningr‚   r€   )Úmodelr¬   r­   r®   r¯   Ú	error_msgr¡   Úpreludes           r   Úlog_state_dict_reportr¹   ì   s   € ð �~Ü×"Ò"¤8Ó,ˆð ××Ø—K‘K × 7Ñ 7Ó8ˆ	Ø˜iÓ'ØØvñˆIô Ð@ÀÇÁ×AYÑAYÐ@ZÐZ_Ð`iÐ_jÐkÓlÐlð ×/Ñ/Ó1€FØ�~Øä˜‘Ð! %§/¡/×":Ñ":Ð!;¸<ÌÐPWÑHXÐGYÐY`Ða~Ð`ð  @Bð  C€Gð ‡N�N�7Ñ#Ô$ð ×%×%Üð ó
ð 	
ö # |×'C×'CÜØxó
ð 	
ð (DÐ"r   )é
   )éP   rJ   )r±   Úreru   rn   Úcollectionsr   r   Údataclassesr   Útypingr   Úcompiler   r   r   r!   r(   r   r    r:   r>   r?   rG   rd   rq   rs   rz   r|   ÚboolÚLoggerr¹   rV   r   r   Ú<module>rÃ      s*  ðó Û 	Û Û 
ß 0Ý !Ý ð �JŠJÐ.Ó/€	ð#�Sð #˜Sô #ñ
'˜˜c™ð '°#õ 'ð*˜T # s (™^ð *°°S¸#°X±ô *ðZ �:Š:Ð'Ó(€ð$�3ð $˜3ô $òò5ð ØØØØØØØñ	€òôð ÷`ð `ó ð`ðP %)ñ,
à#&ð,
ð "ð,
ð $ð	,
ð
 �N‰N˜TÑ!ö,
r   