ó
    qyüiB“  ã                  ó¾  • % S r SSKJ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  SSKJrJrJr  SSKJrJrJr  SSKJrJr  SSKJr  SS	KJrJr  SS
KJrJrJ r   SSK!r"SSK#J$r$  SSK%J&r&J'r'J(r(  \(       a
  SSK)r)SSK)J*r*  \$RV                  " \,5      r-Sr.\'" 5       (       a  Sr.\/" 5       r0S\1S'   SMS jr2Sr3\&" 5       (       a  Sr3SNS jr4SOS jr5S r6SPS jr7SPS jr8SPS jr9SPS jr:SPS jr;S r<   SQ       SRS jjr=S r>SPS  jr? SS     STS! jjr@SUS" jrAS# rBS$ rCSVS% jrD " S& S'\5      rESWS( jrF SX       SYS) jjrG " S* S+\H\5      rI " S, S-\I5      rJ " S. S/\I5      rK " S0 S15      rLS2 rMS3 rNSZS[S4 jjrOSXS5 jrPS6 rQSXS7 jrRS8 rSS9 rTS: rUS; rVSXS\S< jjrW " S= S>\ SS?9rXS]S@ jrYS^SA jrZS_SB jr[S`SC jr\SD r]SE r^SF r_ " SG SH\5      r`SISJSKS\a44SL jrbg)az
Generic utilities
é    )ÚannotationsN)ÚOrderedDictÚUserDict)ÚCallableÚIterableÚMutableMapping)ÚAbstractContextManagerÚ	ExitStackÚnullcontext)ÚfieldsÚis_dataclass)ÚEnum)ÚpartialÚwraps)ÚTYPE_CHECKINGÚAnyÚ	TypedDicté   )Úloggingé   )Úis_mlx_availableÚis_torch_availableÚis_torch_fx_proxy)ÚnnFTzset[type[Any]]Ú_registered_model_output_typesc           	     ó,  • [         (       d  g SS KnUR                  R                  5       (       a  g U [        ;   a  g SS KJs  Jn  UR                  U [        [        [        U S9U R                   SU R                   3S9  [        R                  U 5        g )Nr   )Úoutput_typeÚ.)Úserialized_type_name)Ú_is_torch_availableÚtorchÚcompilerÚis_compilingr   Útorch.utils._pytreeÚutilsÚ_pytreeÚregister_pytree_nodeÚ_model_output_flattenr   Ú_model_output_unflattenÚ
__module__Ú__name__Úadd)r   r!   Útorch_pytrees      ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/utils/generic.pyÚ"_register_model_output_pytree_noder/   8   sˆ   € ßÒØÛð
 ‡~�~×"Ñ"×$Ñ$ØØÔ4Ó4Øç.Ð.à×%Ñ%ØÜÜÔ'°[ÑAØ +× 6Ñ 6Ð7°q¸×9MÑ9MÐ8NÐOð	 &ñ ô #×&Ñ& {Õ3ó    c                ó\   • U R                  5       n U S;   a  gU S;   a  g[        SU < 35      e)zãConvert a string representation of truth to true (1) or false (0).

True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'.
Raises ValueError if 'val' is anything else.
>   Ú1ÚtÚyÚonÚyesÚtruer   >   Ú0ÚfÚnÚnoÚoffÚfalser   zinvalid truth value )ÚlowerÚ
ValueError)Úvals    r.   Ú	strtoboolrA   W   s:   € ð �)‰)‹+€CØ
Ð2Ó2ØØ
Ð3Ó3ØÜ
Ð+¨C©7Ð3Ó
4Ð4r0   c                ó¶   • [        [        U 5      5      nUR                  S5      (       a  gUR                  S5      (       a  gUR                  S5      (       a  gg)z·
Tries to guess the framework of an object `x` from its repr (brittle but will help in `is_tensor` to try the
frameworks in a smart order, without the need to import the frameworks).
z<class 'torch.Úptz<class 'numpy.Únpz<class 'mlx.ÚmlxN)ÚstrÚtypeÚ
startswith)ÚxÚrepresentations     r.   Úinfer_framework_from_reprrK   e   sT   € ô
 œ˜a›“\€NØ× Ñ Ð!1×2Ñ2ØØ	×	"Ñ	"Ð#3×	4Ñ	4ØØ	×	"Ñ	" >×	2Ñ	2Øð 
3r0   c                ó  • [         [        [        S.n[        U 5      nUc  / OU/nUS:w  a  UR	                  S5        UR                  U Vs/ s H  oDUS4;  d  M  UPM     sn5        U Vs0 s H  oDX   _M	     sn$ s  snf s  snf )z³
Returns an (ordered since we are in Python 3.7+) dictionary framework to test function, which places the framework
we can guess from the repr first, then Numpy, then the others.
)rC   rD   rE   rD   )Úis_torch_tensorÚis_numpy_arrayÚis_mlx_arrayrK   ÚappendÚextend)rI   Úframework_to_testÚpreferred_frameworkÚ
frameworksr9   s        r.   Ú_get_frameworks_and_test_funcrU   s   s™   € ô ÜÜñÐô
 4°AÓ6Ðà*Ñ2‘Ð9LÐ8M€JØ˜dÓ"Ø×Ñ˜$ÔØ×ÑÑ"3Ó\Ò"3˜QÐATÐVZÐ@[Ñ7[—qÑ"3Ñ\Ô]Ù-7Ó8ªZ¨Ð Ñ#Ò#©ZÑ8Ð8ùò ]ùÚ8s   ÁA=ÁA=Á,Bc                óˆ   • [        U 5      nUR                  5        H  nU" U 5      (       d  M    g   [        U 5      (       a  gg)zs
Tests if `x` is a `torch.Tensor`, `np.ndarray` or `mlx.array` in the order defined by `infer_framework_from_repr`
TF)rU   Úvaluesr   )rI   Úframework_to_test_funcÚ	test_funcs      r.   Ú	is_tensorrZ   †   sA   € ô
 ;¸1Ó=ÐØ+×2Ñ2Ö4ˆ	Ù�Q�<‹<Ùñ 5ô
 ˜×ÑØàr0   c                ó6   • [        U [        R                  5      $ )z'
Tests if `x` is a numpy array or not.
)Ú
isinstancerD   Úndarray©rI   s    r.   rN   rN   —   s   € ô �aœŸ™Ó$Ð$r0   c                óL   • [         (       d  gSSKn[        XR                  5      $ )zU
Tests if `x` is a torch tensor or not. Safe to call even if torch is not installed.
Fr   N)r    r!   r\   ÚTensor©rI   r!   s     r.   rM   rM   ž   ó   € ÷ ÒØãä�aŸ™Ó&Ð&r0   c                óL   • [         (       d  gSSKn[        XR                  5      $ )zU
Tests if `x` is a torch device or not. Safe to call even if torch is not installed.
Fr   N)r    r!   r\   Údevicera   s     r.   Úis_torch_devicere   ª   rb   r0   c                ó°   • [         (       d  gSSKn[        U [        5      (       a  [	        X5      (       a  [        X5      n Og[        XR                  5      $ )zT
Tests if `x` is a torch dtype or not. Safe to call even if torch is not installed.
Fr   N)r    r!   r\   rF   ÚhasattrÚgetattrÚdtypera   s     r.   Úis_torch_dtyperj   ¶   sD   € ÷ ÒØãä�!”S×ÑÜ�5×ÑÜ˜Ó!‰AàÜ�aŸ™Ó%Ð%r0   c                ó  • [        U 5      (       a  g[        U 5      (       a  g[        U [        [        [
        [        R                  45      (       a  g[        U [        [        45      (       a  [        U 5      S:X  a  g[        U S   5      $ g)z9
Check if a value is array-like (includes ragged arrays)
Tr   F)rN   rM   r\   ÚintÚfloatÚboolrD   ÚnumberÚlistÚtupleÚlenÚ_is_tensor_or_array_like)Úvalues    r.   rs   rs   Ç   sn   € ô �e×ÑØÜ�u×ÑØÜ�%œ#œu¤d¬B¯I©IÐ6×7Ñ7Øä�%œ$¤˜×'Ñ'Üˆu‹:˜‹?àÜ'¨¨a©Ó1Ð1àr0   c                óÈ   • [         (       d  [        S5      eSSKnU S:X  a
  [        5       $ UR                  " U 5      (       d  U(       a  UR
                  " XX#S9$ [        5       $ )an  
Context manager that only autocasts if:

- `autocast` is already enabled in this context
- Or this call to `maybe_autocast` has `enabled=True`

This prevents `autocast` being added to the graph when it is effectively a no-op.
Which makes graph splitting in `torch.compile` more flexible as it removes the
requirement that partition IDs be monotonically increasing.
z2`maybe_autocast` requires PyTorch to be installed.r   NÚmeta)ri   ÚenabledÚcache_enabled)r    ÚImportErrorr!   r   Úis_autocast_enabledÚautocast)Údevice_typeri   rw   rx   r!   s        r.   Úmaybe_autocastr}   Û   sU   € ÷  ÒÜÐNÓOÐOãà�fÓÜ‹}ÐØ× Ò  ×-Ñ-¶Ø�~Š~˜kÀÑeÐeä‹}Ðr0   c                ó8   • SS K Jn  [        XR                  5      $ )Nr   )Úmlx.coreÚcorer\   Úarray)rI   Úmxs     r.   Ú_is_mlxrƒ   ø   s   € Ýä�aŸ™Ó"Ð"r0   c                ó2   • [         (       d  S$ [        U 5      $ )zR
Tests if `x` is a mlx array or not. Safe to call even when mlx is not installed.
F)Ú_is_mlx_availablerƒ   r^   s    r.   rO   rO   þ   s   € ÷ *Ò)ˆ5Ð9¬w°q«zÐ9r0   c                óª   • U b  Ub  [        S5      eU b  U R                  nOUnUc  gUb%  [        R                  " S[	        U5      -   U5      SL$ SU;   $ )a@  
Checks whether some flavor of flash attention is requested or not. Optionally, checks for a specific version of
flash attention.

This is checked against one of the two arguments, i.e. either the `config` or the directly passed value
`requested_attention_implementation`. Otherwise, an error will be raised (ambiguity).

The different versions of flash attention are usually
- Implementations based on the original flash attention repo: https://github.com/Dao-AILab/flash-attention
- Kernels implementations such as: https://huggingface.co/kernels-community/vllm-flash-attn3
Nz…Requested attention implementation is ambiguous: Please pass either the config or the name of the attention implementation, not both.Fz	.*flash.*Úflash)r?   Ú_attn_implementationÚreÚmatchrF   )ÚconfigÚ"requested_attention_implementationÚversionÚ checked_attention_implementations       r.   Úis_flash_attention_requestedr�     s}   € ð ÑÐ@ÑLÜðcó
ð 	
ð
 ÑØ+1×+FÑ+FÑ(à+MÐ(ð (Ñ/Øð ÑÜ�xŠx˜¤s¨7£|Ñ3Ð5UÓVÐ^bÐbÐbàÐ6Ñ6Ð6r0   c                óP   • U c  gU R                  S5      nXR                  S5      4$ )zñ
Split the optional `paged|` prefix from an attention implementation string.

Note that `None` means using the default attention implementation, which is either torch's native `sdpa` or `eager` (if `sdpa` is not implemented for that model).
)FNzpaged|)rH   Úremoveprefix)ÚimplementationÚis_pageds     r.   Úsplit_attention_implementationr”   )  s1   € ð ÑØà×(Ñ(¨Ó2€HØ×0Ñ0°Ó:Ð:Ð:r0   c                ó‚  • [        U [        [        45      (       a  U $ [        U [        [        45      (       a/  U R                  5        VVs0 s H  u  pU[        U5      _M     snn$ [        U [        [        45      (       a>  [        S U  5       5      (       a  [        U 5      $ U  Vs/ s H  n[        U5      PM     sn$ S S S.n[        U 5      nUR                  5        H  u  pgU" U 5      (       d  M  XF   " U 5      s  $    [        U [        R                  5      (       a  U R                  5       $ U $ s  snnf s  snf )zH
Convert a PyTorch tensor, Numpy array or python list to a python list.
c              3  ól   #   • U  H*  n[        U[        [        [        R                  45      v •  M,     g 7f©N)r\   rl   rm   rD   ro   )Ú.0rI   s     r.   Ú	<genexpr>Úto_py_obj.<locals>.<genexpr>@  s%   é € ÐCºs¸!Œz˜!œc¤5¬"¯)©)Ð4×5Ð5ºsùs   ‚24c                ó"   • U R                  5       $ r—   ©Útolist©Úobjs    r.   Ú<lambda>Úto_py_obj.<locals>.<lambda>G  ó
   € ˜#Ÿ*™*œ,r0   c                ó"   • U R                  5       $ r—   rœ   rž   s    r.   r    r¡   H  r¢   r0   ©rC   rD   )r\   rl   rm   Údictr   ÚitemsÚ	to_py_objrp   rq   ÚallrU   rD   ro   r�   )rŸ   ÚkÚvÚoÚframework_to_py_objrX   Ú	frameworkrY   s           r.   r§   r§   6  s  € ô �#œœU�|×$Ñ$Øˆ
Ü	�Cœ$¤Ð)×	*Ñ	*Ø,/¯I©I¬KÔ8ªK¡D A�”9˜Q“<’©KÒ8Ð8Ü	�Cœ$¤˜×	'Ñ	'äÑC¹sÓC×CÑCÜ˜“9Ðñ '*Ó*¢c ”	˜!–¡cÑ*Ð*ñ 'Ù&ñÐô ;¸3Ó?ÐØ 6× <Ñ <Ö >Ñˆ	Ù�S�>‹>Ø&Ò1°#Ó6Ò6ñ !?ô
 �#”r—y‘y×!Ñ!Ø�z‰z‹|Ðàˆ
ùó1 9ùò +s   ÁD6Â)D<c                ó�  • S S S.n[        U [        [        45      (       a/  U R                  5        VVs0 s H  u  p#U[	        U5      _M     snn$ [        U [
        [        45      (       a  [        R                  " U 5      $ [        U 5      nUR                  5        H  u  pVU" U 5      (       d  M  X   " U 5      s  $    U $ s  snnf )zH
Convert a PyTorch tensor, Numpy array or python list to a Numpy array.
c                óZ   • U R                  5       R                  5       R                  5       $ r—   )ÚdetachÚcpuÚnumpyrž   s    r.   r    Úto_numpy.<locals>.<lambda>^  s   € ˜#Ÿ*™*›,×*Ñ*Ó,×2Ñ2Ô4r0   c                ó   • U $ r—   © rž   s    r.   r    r³   _  s   € ™#r0   r¤   )
r\   r¥   r   r¦   Úto_numpyrp   rq   rD   r�   rU   )rŸ   Úframework_to_numpyr©   rª   rX   r­   rY   s          r.   r¶   r¶   X  s°   € ñ 5ÙñÐô
 �#œœhÐ'×(Ñ(Ø+.¯9©9¬;Ô7ª;¡4 1�”8˜A“;’©;Ò7Ð7Ü	�Cœ$¤˜×	'Ñ	'Ü�xŠx˜‹}Ðô ;¸3Ó?ÐØ 6× <Ñ <Ö >Ñˆ	Ù�S�>‹>Ø%Ò0°Ó5Ò5ñ !?ð €Jùó 8s   ¶Cc                óê   •  [        U SS9 nUR                  5       nSSS5        [        R                  " W5      nU$ ! , (       d  f       N&= f! [        R                   a    [        SU  S35      ef = f)zeA helper to load safe config files and raise a proper error message if it wasn't serialized correctlyzutf-8)ÚencodingNz"It looks like the config file at 'z' is not a valid JSON file.)ÚopenÚreadÚjsonÚloadsÚJSONDecodeErrorÚOSError)Ú	json_fileÚreaderÚtextÚconfig_dicts       r.   Úsafe_load_json_filerÄ   p  sq   € ðcÜ�) gÒ.°&Ø—;‘;“=ˆD÷ /ä—j’j Ó&ˆð Ð÷ /Õ.ûô ×Ñó cÜÐ:¸9¸+ÐE`ÐaÓbÐbðcús   ‚
A Œ=�A ½
AÁA Á$A2c                  óŽ   ^ • \ rS rSrSrSS jrU 4S jrU 4S jrS rS r	S r
S	 rS
 rU 4S jrU 4S jrU 4S jrSS jrSrU =r$ )ÚModelOutputi{  a‘  
Base class for all model outputs as dataclass. Has a `__getitem__` that allows indexing by integer or slice (like a
tuple) or strings (like a dictionary) that will ignore the `None` attributes. Otherwise behaves like a regular
python dictionary.

<Tip warning={true}>

You can't unpack a `ModelOutput` directly. Use the [`~utils.ModelOutput.to_tuple`] method to convert it to a tuple
before.

</Tip>
c                ó   • [        U 5        g)zÔRegister subclasses as pytree nodes.

This is necessary to synchronize gradients when using `torch.nn.parallel.DistributedDataParallel` with
`static_graph=True` with modules that output `ModelOutput` subclasses.
N)r/   )Úclss    r.   Ú__init_subclass__ÚModelOutput.__init_subclass__‰  s   € ô 	+¨3Õ/r0   c                ó  >• [         TU ]  " U0 UD6  [        [        U 5      5        U R                  [
        :g  nU(       a@  [        U 5      (       d/  [        U R                   SU R                  R                   S35      eg g )Nr   z` is not a dataclass. This is a subclass of ModelOutput and so must use the @dataclass decorator.)
ÚsuperÚ__init__r/   rG   Ú	__class__rÆ   r   Ú	TypeErrorr*   r+   )ÚselfÚargsÚkwargsÚis_modeloutput_subclassrÎ   s       €r.   rÍ   ÚModelOutput.__init__‘  s{   ø€ Ü‰Ò˜$Ð) &Ò)Ü*¬4°«:Ô6ð #'§.¡.´KÑ"?Ðæ"¬<¸×+=Ñ+=ÜØ—?‘?Ð# 1 T§^¡^×%<Ñ%<Ð$=ð >_ð _óð ð ,>Ð"r0   c                ó¤  >^ • [        [        T 5      5        [        T 5      n[        U5      (       d"  [	        T R
                  R                   S35      e[        S USS  5       5      (       d"  [	        T R
                  R                   S35      e[        T US   R                  5      n[        U 4S jUSS  5       5      nU(       GaB  [        U5      (       Gd1  [        U[        5      (       a  UR                  5       nSnO [        U5      nSnU(       aÝ  [!        T US   R                  S5        ["        T
T ]I  US   R                  5        ['        W5       H—  u  pg[        U[(        [*        45      (       a'  [        U5      S
:w  d  [        US   [,        5      (       d*  US:X  a  UT US   R                  '   O[	        SU S35      e  g[!        T US   US   5        US   c  MŒ  US   T US   '   M™     gUb  UT US   R                  '   ggU H-  n[        T UR                  5      n	U	c  M  U	T UR                  '   M/     g! [         a    S	n GN>f = f)zUCheck the ModelOutput dataclass.

Only occurs if @dataclass decorator has been used.
z has no fields.c              3  ó<   #   • U  H  oR                   S L v •  M     g 7fr—   )Údefault)r˜   Úfields     r.   r™   Ú,ModelOutput.__post_init__.<locals>.<genexpr>¬  s   é € ÐGÒ6F¨U—=‘= DÕ(Ò6Fùs   ‚r   Nz. should not have more than one required field.r   c              3  óT   >#   • U  H  n[        TUR                  5      S L v •  M     g 7fr—   ©rh   Úname©r˜   rØ   rÐ   s     €r.   r™   rÙ   °  s#   øé € Ð#dÒScÈ%¤G¨D°%·*±*Ó$=ÀÕ$EÒScùs   ƒ%(TFr   zCannot set key/value for z&. It needs to be a tuple (key, value).)r/   rG   r   rr   r?   rÎ   r+   r¨   rh   rÜ   rZ   r\   r¥   r¦   ÚiterrÏ   ÚsetattrrÌ   Ú__delitem__Ú	enumeraterp   rq   rF   )rÐ   Úclass_fieldsÚfirst_fieldÚother_fields_are_noneÚiteratorÚfirst_field_iteratorÚidxÚelementrØ   rª   rÎ   s   `         €r.   Ú__post_init__ÚModelOutput.__post_init__¡  s6  ù€ ô
 	+¬4°«:Ô6Ü˜d“|ˆô �<× Ñ Ü §¡× 7Ñ 7Ð8¸ÐHÓIÐIÜÑG°lÀ1À2Ñ6FÓG×GÑGÜ §¡× 7Ñ 7Ð8Ð8fÐgÓhÐhä˜d L°¡O×$8Ñ$8Ó9ˆÜ #Ô#dÐS_Ð`aÐ`bÑScÓ#dÓ dÐç ¬°;×)?Ò)?Ü˜+¤t×,Ñ,Ø&×,Ñ,Ó.�Ø'+Ñ$ð1Ü# KÓ0�HØ+/Ð(ö $ä˜˜l¨1™o×2Ñ2°DÔ9Ü‘Ñ# L°¡O×$8Ñ$8Ô9Ü$-¨hÖ$7‘L�CÜ% g´´e¨}×=Ñ=ÄÀWÃÐQRÓARÔZdÐelÐmnÑeoÔqt×ZuÑZuØ !›8à9D˜D ¨a¡×!5Ñ!5Ò6ô #-Ø";¸G¸9ÐDjÐ kó#ð ñ Ü˜D '¨!¡*¨g°a©jÔ9Ø˜q‘zÓ-Ø+2°1©:˜˜W Q™ZÓ(ò %8ð Ñ(Ø-8��\ !‘_×)Ñ)Ò*ð )ó &�Ü˜D %§*¡*Ó-�Ø“=Ø'(�D˜Ÿ™Ó$ò &øô5 !ó 1Ø+0Ó(ð1ús   ÄH? È?IÉIc                óH   • [        SU R                  R                   S35      e)Nz$You cannot use ``__delitem__`` on a ú
 instance.©Ú	ExceptionrÎ   r+   ©rÐ   rÑ   rÒ   s      r.   rà   ÚModelOutput.__delitem__Ù  s#   € ÜÐ>¸t¿~¹~×?VÑ?VÐ>WÐWaÐbÓcÐcr0   c                óH   • [        SU R                  R                   S35      e)Nz#You cannot use ``setdefault`` on a rì   rí   rï   s      r.   Ú
setdefaultÚModelOutput.setdefaultÜ  s#   € ÜÐ=¸d¿n¹n×>UÑ>UÐ=VÐV`ÐaÓbÐbr0   c                óH   • [        SU R                  R                   S35      e)NzYou cannot use ``pop`` on a rì   rí   rï   s      r.   ÚpopÚModelOutput.popß  s"   € ÜÐ6°t·~±~×7NÑ7NÐ6OÈzÐZÓ[Ð[r0   c                óH   • [        SU R                  R                   S35      e)NzYou cannot use ``update`` on a rì   rí   rï   s      r.   ÚupdateÚModelOutput.updateâ  s#   € ÜÐ9¸$¿.¹.×:QÑ:QÐ9RÐR\Ð]Ó^Ð^r0   c                óŒ   • [        U[        5      (       a  [        U R                  5       5      nX!   $ U R	                  5       U   $ r—   )r\   rF   r¥   r¦   Úto_tuple)rÐ   r©   Ú
inner_dicts      r.   Ú__getitem__ÚModelOutput.__getitem__å  s8   € Ü�aœ×ÑÜ˜dŸj™j›lÓ+ˆJØ‘=Ð à—=‘=“? 1Ñ%Ð%r0   c                ó¤   >• [        U 5       Vs1 s H  o3R                  iM     nnX;   a  Ub  [        TU ]  X5        [        TU ]  X5        g s  snf r—   )r   rÜ   rÌ   Ú__setitem__Ú__setattr__)rÐ   rÜ   rt   rØ   Úfield_namesrÎ   s        €r.   r  ÚModelOutput.__setattr__ì  sG   ø€ Ü/5°d¬|Ó<ª| e—z”z©|ˆÐ<ØÓ 5Ñ#4ä‰GÑ Ô,Ü‰Ñ˜DÕ(ùò	 =s   �Ac                óB   >• [         TU ]  X5        [         TU ]	  X5        g r—   )rÌ   r   r  )rÐ   Úkeyrt   rÎ   s      €r.   r   ÚModelOutput.__setitem__ó  s   ø€ ä‰Ñ˜CÔ'ä‰Ñ˜CÕ'r0   c                óª   >^ • [        T 5      (       d  [        TT ]	  5       $ [        TT ]	  5       tpn[        U 4S j[	        T 5       5       5      nX/UQ7$ )Nc              3  óP   >#   • U  H  n[        TUR                  5      v •  M     g 7fr—   rÛ   rÝ   s     €r.   r™   Ú)ModelOutput.__reduce__.<locals>.<genexpr>ý  s   øé € ÐIºL°5”W˜T 5§:¡:×.Ð.ºLùs   ƒ#&)r   rÌ   Ú
__reduce__rq   r   )rÐ   ÚcallableÚ_argsÚ	remainingrÑ   rÎ   s   `    €r.   r
  ÚModelOutput.__reduce__ù  sP   ù€ Ü˜D×!Ñ!Ü‘7Ñ%Ó'Ð'Ü&+¡gÑ&8Ó&:Ð#ˆ˜)ÜÔI¼FÀ4¼LÓIÓIˆØÐ) 	Ñ)Ð)r0   c                óJ   ^ • [        U 4S jT R                  5        5       5      $ )zQ
Convert self to a tuple containing all the attributes/keys that are not `None`.
c              3  ó.   >#   • U  H
  nTU   v •  M     g 7fr—   rµ   )r˜   r©   rÐ   s     €r.   r™   Ú'ModelOutput.to_tuple.<locals>.<genexpr>  s   øé € Ð2¢k �T˜!–W¢kùs   ƒ)rq   Úkeys©rÐ   s   `r.   rû   ÚModelOutput.to_tuple   s   ø€ ô Ô2 d§i¡i¤kÓ2Ó2Ð2r0   rµ   )ÚreturnÚNone)r  rq   )r+   r*   Ú__qualname__Ú__firstlineno__Ú__doc__rÉ   rÍ   ré   rà   rò   rõ   rø   rý   r  r   r
  rû   Ú__static_attributes__Ú__classcell__)rÎ   s   @r.   rÆ   rÆ   {  sN   ø† ñô0õõ 6)òpdòcò\ò_ò&õ)õ(õ*÷3ò 3r0   rÆ   c                óf   • [        U R                  5       5      [        U R                  5       5      4$ r—   )rp   rW   r  )Úoutputs    r.   r(   r(     s#   € Ü�—‘“Ó ¤$ v§{¡{£}Ó"5Ð5Ð5r0   c           
     ó6   • U" S0 [        [        X5      5      D6$ )Nrµ   )r¥   Úzip)rW   Úcontextr   s      r.   r)   r)     s   € ñ
 Ñ4œœc 'Ó2Ó3Ñ4Ð4r0   c                  ó(   • \ rS rSrSr\S 5       rSrg)ÚExplicitEnumi  z;
Enum with more explicit error message for missing values.
c           
     ó~   • [        U SU R                   S[        U R                  R	                  5       5       35      e)Nz is not a valid z, please select one of )r?   r+   rp   Ú_value2member_map_r  )rÈ   rt   s     r.   Ú	_missing_ÚExplicitEnum._missing_  s?   € äØˆgÐ% c§l¡l ^Ð3JÌ4ÐPS×PfÑPf×PkÑPkÓPmÓKnÐJoÐpó
ð 	
r0   rµ   N)r+   r*   r  r  r  Úclassmethodr%  r  rµ   r0   r.   r"  r"    s   † ñð ñ
ó ó
r0   r"  c                  ó$   • \ rS rSrSrSrSrSrSrg)ÚPaddingStrategyi  zz
Possible values for the `padding` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an
IDE.
ÚlongestÚ
max_lengthÚ
do_not_padrµ   N)	r+   r*   r  r  r  ÚLONGESTÚ
MAX_LENGTHÚ
DO_NOT_PADr  rµ   r0   r.   r)  r)    s   † ñð
 €GØ€JØƒJr0   r)  c                  ó$   • \ rS rSrSrSrSrSrSrg)Ú
TensorTypei*  z�
Possible values for the `return_tensors` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for
tab-completion in an IDE.
rC   rD   rE   rµ   N)	r+   r*   r  r  r  ÚPYTORCHÚNUMPYÚMLXr  rµ   r0   r.   r1  r1  *  s   † ñð
 €GØ€EØ
ƒCr0   r1  c                  ó.   • \ rS rSrSrSS jrS rS rSrg)	ÚContextManagersi5  zŽ
Wrapper for `contextlib.ExitStack` which enters a collection of context managers. Adaptation of `ContextManagers`
in the `fastcore` library.
c                ó.   • Xl         [        5       U l        g r—   )Úcontext_managersr
   Ústack)rÐ   r8  s     r.   rÍ   ÚContextManagers.__init__;  s   € Ø 0ÔÜ“[ˆ�
r0   c                ó`   • U R                    H  nU R                  R                  U5        M      g r—   )r8  r9  Úenter_context)rÐ   Úcontext_managers     r.   Ú	__enter__ÚContextManagers.__enter__?  s$   € Ø#×4Ô4ˆOØ�J‰J×$Ñ$ _Ö5ò  5r0   c                ó<   • U R                   R                  " U0 UD6  g r—   )r9  Ú__exit__rï   s      r.   rA  ÚContextManagers.__exit__C  s   € Ø�
‰
×Ò˜TÐ, VÓ,r0   )r8  r9  N)r8  zlist[AbstractContextManager])	r+   r*   r  r  r  rÍ   r>  rA  r  rµ   r0   r.   r6  r6  5  s   † ñô
!ò6õ-r0   r6  c                ó¶   • [         R                  " U R                  5      nUR                   H)  nUS:X  d  M  UR                  U   R                  SL d  M)    g   g)zb
Check if a given model can return loss.

Args:
    model_class (`type`): The class of the model.
Úreturn_lossTF)ÚinspectÚ	signatureÚforwardÚ
parametersr×   )Úmodel_classrF  Úps      r.   Úcan_return_lossrK  G  sR   € ô ×!Ò! +×"5Ñ"5Ó6€Ià×!Ô!ˆØ�Õ )×"6Ñ"6°qÑ"9×"AÑ"AÀTÔ"IÙñ "ð r0   c                ó  • U R                   n[        R                  " U R                  5      nSU;   a+  UR                   Vs/ s H  nSU;   d  US;   d  M  UPM     sn$ UR                   Vs/ s H  nSU;   d  M  UPM     sn$ s  snf s  snf )za
Find the labels used by a given model.

Args:
    model_class (`type`): The class of the model.
ÚQuestionAnsweringÚlabel)Ústart_positionsÚend_positions)r+   rE  rF  rG  rH  )rI  Ú
model_namerF  rJ  s       r.   Úfind_labelsrR  W  s„   € ð ×%Ñ%€JÜ×!Ò! +×"5Ñ"5Ó6€Ià˜jÓ(Ø$×/Ò/ÓmÒ/�a°7¸a³<À1ÐHlÑCl—Ñ/ÑmÐmà$×/Ò/Ó@Ò/�a°7¸a±<—Ñ/Ñ@Ð@ùò nùâ@s   ÁBÁBÁ,
BÁ:Bc                ó0   • SS jn[        U" XU5      5      $ )z/Flatten a nested dict into a single level dict.c              3  ó  #   • U R                  5        Hk  u  p4U(       a  [        U5      U-   [        U5      -   OUnU(       a7  [        U[        5      (       a"  [	        XEUS9R                  5        S h  v•N   Mf  XT4v •  Mm     g  N7f)N)Ú	delimiter)r¦   rF   r\   r   Úflatten_dict)ÚdÚ
parent_keyrU  r©   rª   r  s         r.   Ú_flatten_dictÚ#flatten_dict.<locals>._flatten_dictj  sg   é € Ø—G‘G–I‰DˆAÞ:D”#�j“/ IÑ-´°A³Ò6È!ˆCÞ”Z ¤>×2Ñ2Ü'¨¸)ÑD×JÑJÓL×LÒLà�f”ò ñ Mùs   ‚A0BÁ2BÁ3B©Ú r   )r¥   )rW  rX  rU  rY  s       r.   rV  rV  g  s   € ôô ‘˜a¨YÓ7Ó8Ð8r0   c                óÖ   • [        U 5      (       a  [        R                  " XS9$ [        U 5      (       a  Uc  U R                  $ U R
                  " U6 $ [        S[        U 5       S35      e)z4
Framework-agnostic version of transpose operation.
)Úaxesz"Type not supported for transpose: r   )rN   rD   Ú	transposerM   ÚTÚpermuter?   rG   )r�   r^  s     r.   r_  r_  u  s^   € ô �e×ÑÜ�|Š|˜EÑ-Ð-Ü	˜×	Ñ	Ø™,ˆu�w‰wÐ@¨E¯MªM¸4Ð,@Ð@äÐ=¼dÀ5»k¸]È!ÐLÓMÐMr0   c                ó¼   • [        U 5      (       a  [        R                  " X5      $ [        U 5      (       a  U R                  " U6 $ [	        S[        U 5       S35      e)z2
Framework-agnostic version of reshape operation.
z Type not supported for reshape: r   )rN   rD   ÚreshaperM   r?   rG   )r�   Únewshapes     r.   rc  rc  �  sQ   € ô �e×ÑÜ�zŠz˜%Ó*Ð*Ü	˜×	Ñ	Ø�}Š}˜hÐ'Ð'äÐ;¼DÀ»K¸=ÈÐJÓKÐKr0   c                óÞ   • [        U 5      (       a  [        R                  " XS9$ [        U 5      (       a"  Uc  U R                  5       $ U R                  US9$ [	        S[        U 5       S35      e)z2
Framework-agnostic version of squeeze operation.
)Úaxis©Údimz Type not supported for squeeze: r   )rN   rD   ÚsqueezerM   r?   rG   ©r�   rf  s     r.   ri  ri  �  sb   € ô �e×ÑÜ�zŠz˜%Ñ+Ð+Ü	˜×	Ñ	Ø"&¡,ˆu�}‰}‹ÐK°E·M±MÀd°MÐ4KÐKäÐ;¼DÀ»K¸=ÈÐJÓKÐKr0   c                ó¼   • [        U 5      (       a  [        R                  " X5      $ [        U 5      (       a  U R	                  US9$ [        S[        U 5       S35      e)z6
Framework-agnostic version of expand_dims operation.
rg  z$Type not supported for expand_dims: r   )rN   rD   Úexpand_dimsrM   Ú	unsqueezer?   rG   rj  s     r.   rl  rl  ™  sS   € ô �e×ÑÜ�~Š~˜eÓ*Ð*Ü	˜×	Ñ	Ø�‰ 4ˆÐ(Ð(äÐ?ÄÀUÃ¸}ÈAÐNÓOÐOr0   c                ó¾   • [        U 5      (       a  [        R                  " U 5      $ [        U 5      (       a  U R	                  5       $ [        S[        U 5       S35      e)z/
Framework-agnostic version of size operation.
z$Type not supported for tensor_size: r   )rN   rD   ÚsizerM   Únumelr?   rG   )r�   s    r.   Útensor_sizerq  ¥  sM   € ô �e×ÑÜ�wŠw�u‹~ÐÜ	˜×	Ñ	Ø�{‰{‹}ÐäÐ?ÄÀUÃ¸}ÈAÐNÓOÐOr0   c                óô   • [         (       d  [        U 5      $ SSKnUR                  R	                  5       (       a5  [        XR                  5      (       a  U R                  UR                  5      $ [        U 5      $ )zc
Casts an input to a torch int64 tensor if we are in a tracing context, otherwise to a Python int.
r   N)	r    rl   r!   ÚjitÚ
is_tracingr\   r`   ÚtoÚint64ra   s     r.   Ú	torch_intrw  ±  sU   € ÷ ÒÜ�1‹vˆãà %§	¡	× 4Ñ 4× 6Ñ 6¼:ÀaÏÉ×;VÑ;Vˆ1�4‰4�—‘ÓÐbÔ\_Ð`aÓ\bÐbr0   c                óô   • [         (       d  [        U 5      $ SSKnUR                  R	                  5       (       a5  [        XR                  5      (       a  U R                  UR                  5      $ [        U 5      $ )zg
Casts an input to a torch float32 tensor if we are in a tracing context, otherwise to a Python float.
r   N)	r    rl   r!   rs  rt  r\   r`   ru  Úfloat32ra   s     r.   Útorch_floatrz  ½  sU   € ÷ ÒÜ�1‹vˆãà"'§)¡)×"6Ñ"6×"8Ñ"8¼ZÈÏ<É<×=XÑ=Xˆ1�4‰4�—‘ÓÐdÔ^aÐbcÓ^dÐdr0   c                ó@   ^• U =(       d    / n [        U 5      mU4S jnU$ )aý  
Decorator to filter out named arguments that are not in the function signature.

This decorator ensures that only the keyword arguments that match the function's signature, or are specified in the
`extra` list, are passed to the function. Any additional keyword arguments are filtered out and a warning is issued.

Parameters:
    extra (`Optional[list]`, *optional*):
        A list of extra keyword argument names that are allowed even if they are not in the function's signature.

Returns:
    Callable:
        A decorator that wraps the function and filters out invalid keyword arguments.

Example usage:

    ```python
    @filter_out_non_signature_kwargs(extra=["allowed_extra_arg"])
    def my_function(arg1, arg2, **kwargs):
        print(arg1, arg2, kwargs)

    my_function(arg1=1, arg2=2, allowed_extra_arg=3, invalid_arg=4)
    # This will print: 1 2 {"allowed_extra_arg": 3}
    # And issue a warning: "The following named arguments are not valid for `my_function` and were ignored: 'invalid_arg'"
    ```
c                óô   >^ ^^^• [         R                  " T 5      n[        UR                  R	                  5       5      nUR                  T5      mSU;   mSU;   mST l        [        T 5      U UUU4S j5       nU$ )NrÐ   rÈ   Tc                 ó¬  >• 0 n0 nUR                  5        H  u  pEUT;   a  XRU'   M  XSU'   M     U(       a“  U Vs/ s H	  nSU S3PM     nnSR                  U5      nT
(       a  U S   R                  R                  S-   nOT	(       a  U S   R                  S-   nOSn[        R
                  " SU TR                   SU 3[        SS	9  T" U 0 UD6$ s  snf )
NÚ'z, r   r   r\  z1The following named arguments are not valid for `z` and were ignored: r   )Ú
stacklevel)r¦   ÚjoinrÎ   r+   ÚwarningsÚwarnÚUserWarning)rÑ   rÒ   Úvalid_kwargsÚinvalid_kwargsr©   rª   Úinvalid_kwargs_namesÚ
cls_prefixÚfuncÚis_class_methodÚis_instance_methodÚvalid_kwargs_to_passs           €€€€r.   ÚwrapperÚCfilter_out_non_signature_kwargs.<locals>.decorator.<locals>.wrapperó  só   ø€ àˆLØˆNàŸ™ž‘�ØÐ,Ó,Ø&' “Oà() 1Ó%ñ	 'ö Ù:HÓ'Iº.°Q¨!¨A¨3¨a«¹.Ð$Ð'IØ'+§y¡yÐ1EÓ'FÐ$ö &Ø!% a¡×!2Ñ!2×!;Ñ!;¸cÑ!A‘JÞ$Ø!% a¡×!1Ñ!1°CÑ!7‘Jà!#�Jä—’ØGÈ
À|ÐTX×TaÑTaÐSbð c*Ø*>Ð)?ðAäØ ò	ñ ˜Ð. Ñ.Ð.ùò% (Js   ºC)rE  rF  ÚsetrH  r  ÚunionÚ _filter_out_non_signature_kwargsr   )rˆ  ÚsigÚfunction_named_argsrŒ  r‰  rŠ  r‹  Úextra_params_to_passs   `   @@@€r.   Ú	decoratorÚ2filter_out_non_signature_kwargs.<locals>.decoratorç  s}   ü€ Ü×Ò Ó%ˆÜ! #§.¡.×"5Ñ"5Ó"7Ó8ÐØ2×8Ñ8Ð9MÓNÐð $Ð':Ñ:ÐØÐ#6Ñ6ˆð 15ˆÔ-ä	ˆt‹÷	/ó 
ð	/ð> ˆr0   )rŽ  )Úextrar”  r“  s     @r.   Úfilter_out_non_signature_kwargsr—  É  s&   ø€ ð6 �K�R€EÜ˜u›:Ðõ,ð\ Ðr0   c                  ó~   • \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S	\S
'   S	\S'   S\S'   S\S'   S	\S'   S\S'   Srg)ÚTransformersKwargsi  a)  
Keyword arguments to be passed to the forward pass of a `PreTrainedModel`.

Attributes:
    num_items_in_batch (`Optional[torch.Tensor]`, *optional*):
        Number of items in the batch. It is recommended to pass it when you are doing gradient accumulation.
    output_hidden_states (`Optional[bool]`, *optional*):
        Most of the models support outputting all hidden states computed during the forward pass.
    output_attentions (`Optional[bool]`, *optional*):
        Turn this on to return the intermediary attention scores.
    output_router_logits (`Optional[bool]`, *optional*):
        For MoE models, this allows returning the router logits to compute the loss.
    cu_seq_lens_q (`torch.LongTensor`, *optional*)
        Gets cumulative sequence length for query state.
    cu_seq_lens_k (`torch.LongTensor`, *optional*)
        Gets cumulative sequence length for key state.
    max_length_q (`int`, *optional*):
        Maximum sequence length for query state.
    max_length_k (`int`, *optional*):
        Maximum sequence length for key state.
    position_ids (`torch.LongTensor`, *optional*)
        Indices of positions of each input sequence tokens.
    is_causal (`bool`, *optional*)
        Can be set to False to enable bi-directional attention, i.e. use decoder Attention modules as encoders.
ztorch.Tensor | NoneÚnum_items_in_batchúbool | NoneÚoutput_hidden_statesÚoutput_attentionsÚoutput_router_logitsztorch.LongTensor | NoneÚcu_seq_lens_qÚcu_seq_lens_kú
int | NoneÚmax_length_qÚmax_length_kÚposition_idsÚ	is_causalrµ   N)r+   r*   r  r  r  Ú__annotations__r  rµ   r0   r.   r™  r™    sE   ‡ ñð4 ,Ó+Ø%Ó%Ø"Ó"Ø%Ó%Ø*Ó*Ø*Ó*ØÓØÓØ)Ó)ØÖr0   r™  )Útotalc                ó   • SU ;   $ )z3Checks whether a config dict is a timm config dict.Úpretrained_cfgrµ   )rÃ   s    r.   Úis_timm_config_dictrª  ?  s   € à˜{Ñ*Ð*r0   c                ó¾  • U c  g[        U 5      n [        R                  R                  U 5      n[        R                  R	                  U 5      nU(       aK  U R                  S5      (       a5  [        U 5       n[        R                  " U5      nSSS5        [        W5      $ U(       a•  [        R                  R                  [        R                  R                  U S5      5      (       aS  [        [        R                  R                  U S5      5       n[        R                  " U5      nSSS5        [        W5      $ g! , (       d  f       N¶= f! , (       d  f       N+= f)z9
Checks whether a checkpoint is a timm model checkpoint.
NFz.jsonzconfig.json)rF   ÚosÚpathÚisfileÚisdirÚendswithrº   r¼   Úloadrª  Úexistsr€  )Úpretrained_model_pathÚis_fileÚis_dirr9   rÃ   s        r.   Úis_timm_local_checkpointr¶  D  sô   € ð Ñ$Øô  Ð 5Ó6Ðä�g‰g�n‰nÐ2Ó3€GÜ�W‰W�]‰]Ð0Ó1€Fö Ð(×1Ñ1°'×:Ñ:ÜÐ'Ô(¨AÜŸ)š) A›,ˆK÷ )ä" ;Ó/Ð/ö ”"—'‘'—.‘.¤§¡§¡Ð.CÀ]Ó!S×TÑTÜ”"—'‘'—,‘,Ð4°mÓDÔEÈÜŸ)š) A›,ˆK÷ Fä" ;Ó/Ð/à÷ )Õ(ú÷ FÕEús   Á6D=ÄEÄ=
EÅ
Ec                ób   • [        XU5        U R                  5        H  n[        X1U5        M     g)z-
Set a value to a module and all submodules.
N)rß   ÚchildrenÚset_attribute_for_modules)Úmoduler  rt   Ú	submodules       r.   r¹  r¹  `  s)   € ô ˆF˜ÔØ—_‘_Ö&ˆ	Ü! )°%Ö8ò 'r0   c                ó~   • [        X5      (       a  [        X5        U R                  5        H  n[        X!5        M     g)z2
Delete a value from a module and all submodules.
N)rg   Údelattrr¸  Údel_attribute_from_modules)rº  r  r»  s      r.   r¾  r¾  i  s0   € ô
 ˆv×ÑÜ�Ôà—_‘_Ö&ˆ	Ü" 9Ö2ò 'r0   c                ó0   ^ • [        T 5      U 4S j5       nU$ )zÞ
Decorator to wrap model method, to call output.to_tuple() if return_dict=False passed as a kwarg or
return_dict=False is set in the config.

Note:
    output.to_tuple() convert output to tuple skipping all `None` values.
c                óø   >• [        U S5      (       a  U R                  R                  OSnUR                  SU5      nUb  UnT" U /UQ70 UD6nU(       d%  [	        U[
        5      (       d  UR                  5       nU$ )Nr‹   TÚreturn_dict)rg   r‹   rÁ  rõ   r\   rq   rû   )rÐ   rÑ   rÒ   rÁ  Úreturn_dict_passedr  rˆ  s         €r.   rŒ  Ú!can_return_tuple.<locals>.wrapper~  sp   ø€ ä18¸¸x×1HÑ1H�d—k‘k×-Ò-ÈdˆØ#ŸZ™Z¨°{ÓCÐØÑ)Ø,ˆKÙ�dÐ,˜TÒ, VÑ,ˆÞ¤:¨f´e×#<Ñ#<Ø—_‘_Ó&ˆFØˆr0   ©r   ©rˆ  rŒ  s   ` r.   Úcan_return_tuplerÆ  u  s"   ø€ ô ˆ4ƒ[ôó ðð €Nr0   c                ó0   ^ • [        T 5      U 4S j5       nU$ )z£
Decorator using config field (if they exist) as default value for some args and kwargs. Precedence is always
given to the args/kwargs that are explicitly passed.
c                ó  >• / SQnU GH3  nS nUTR                   R                  ;   a(  TR                   R                  R                  U5      S-
  nUb  [        U5      U:”  a
  X   b  X   nO.UR	                  U5      b  X$   nO[        U R                  US 5      nUc  M—  US:X  aB  [        U SS5      (       a/  U R                  (       a  U(       a  [        R                  S5        SnO!US:X  a  SS	/nXg;  a  [        S
U SU S35      eUb,  [        U5      U:”  a  [        U5      nXaU'   [        U5      nGM/  XbU'   GM6     UR	                  S[        U R                  SS 5      5      nUbG  [        U R                  S5      n	U	(       a  U R                  R                  n
X€R                  l        X‚S'    UR	                  SS5      (       aD  SSKJn  U" XR	                  SS5      UR	                  S5      5         T" U /UQ70 UD6nS S S 5        OT" U /UQ70 UD6nUb&  W	(       a  W
U R                  l        W$ U R                  ?W$ ! , (       d  f       N9= f! Ub&  W	(       a  W
U R                  l        f U R                  ?f f = f)N)Ú	use_cacheÚvision_feature_layerÚvision_feature_select_strategyÚvision_aspect_ratior   rÉ  Úgradient_checkpointingFzX`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.rË  r×   Úfullz%`Unexpected select feature strategy: z. Please select from r   r¥  Údebug_ior   )Úmodel_addition_debugger_contextÚdebug_io_dirÚmodel_debugÚprune_layers)Ú__code__Úco_varnamesÚindexrr   Úgetrh   r‹   ÚtrainingÚloggerÚwarning_oncer?   rp   rq   rg   r¥  Úmodel_debugging_utilsrÐ  )rÐ   rÑ   rÒ   Úargs_with_config_defaultsÚarg_nameÚ	arg_indexÚ	arg_valueÚvalid_strategiesr¥  Úis_causal_in_configÚis_causal_original_valuerÐ  r  rˆ  s                €r.   rŒ  Ú+merge_with_config_defaults.<locals>.wrapper’  su  ø€ ò%
Ð!ô 2ˆHØˆIØ˜4Ÿ=™=×4Ñ4Ó4Ø ŸM™M×5Ñ5×;Ñ;¸HÓEÈÑI�	àÑ$¬¨T«°YÓ)>À4Á?ÑC^Ø ™O‘	Ø—‘˜HÓ%Ñ1Ø"Ñ,‘	ä# D§K¡K°¸4Ó@�	àÓ$à˜{Ó*Ü˜tÐ%=¸u×EÑEÈ$Ï-Ï-Ö\eÜ×+Ñ+Øvôð %*˜	øØÐ!AÓAØ(1°6Ð':Ð$Ø Ó8Ü(ØCÀIÀ;ÐNcÐdtÐcuÐuvÐwóð ð Ñ(¬S°«Y¸Ó-BÜ ›:�DØ&/˜‘OÜ  ›;“Dà'0˜8Ô$ñA 2ðF —J‘J˜{¬G°D·K±KÀÈdÓ,SÓTˆ	ØÑ Ü")¨$¯+©+°{Ó"CÐÞ"Ø+/¯;©;×+@Ñ+@Ð(à$-�K‰KÔ!Ø"+�;Ñð	.Ø�z‰z˜* e×,Ñ,ÝSá4ØŸ*™* ^°]ÓCÀVÇZÁZÐP^ÓE_õñ " $Ð8¨Ò8°Ñ8�F÷ð ñ
 ˜dÐ4 TÒ4¨VÑ4�ð Ñ$Þ&Ø,D�D—K‘KÔ)ð ˆð Ÿ™Ð-àˆ÷õ ûð Ñ$Þ&Ø,D�D—K‘KÕ)àŸ™Ñ-ð	 %ús%   Æ2AI Ç7IÈI É
IÉI É+J rÄ  rÅ  s   ` r.   Úmerge_with_config_defaultsrä  Œ  s%   ø€ ô ˆ4ƒ[ôFó ðFðP €Nr0   c                óB   • [         R                  S5        [        U 5      $ )NzZThe `check_model_inputs` decorator is deprecated in favor of `merge_with_config_defaults`.)rÙ  rÚ  rä  )rˆ  s    r.   Úcheck_model_inputsræ  á  s   € Ü
×ÑÐtÔuÜ% dÓ+Ð+r0   c                  ó^   • \ rS rSrSr0 rS rS rS rS r	S r
S r\SS	 j5       rSS
 jrSrg)ÚGeneralInterfaceiæ  zÞ
Dict-like object keeping track of a class-wide mapping, as well as a local one. Allows to have library-wide
modifications through the class mapping, as well as local modifications in a single file with the local mapping.
c                ó   • 0 U l         g r—   ©Ú_local_mappingr  s    r.   rÍ   ÚGeneralInterface.__init__ð  s
   € Ø ˆÕr0   c                ó\   • XR                   ;   a  U R                   U   $ U R                  U   $ r—   )rë  Ú_global_mapping©rÐ   r  s     r.   rý   ÚGeneralInterface.__getitem__ó  s0   € à×%Ñ%Ó%Ø×&Ñ& sÑ+Ð+Ø×#Ñ# CÑ(Ð(r0   c                ó<   • U R                   R                  X05        g r—   )rë  rø   )rÐ   r  rt   s      r.   r   ÚGeneralInterface.__setitem__ù  s   € à×Ñ×"Ñ" C <Õ0r0   c                ó   • U R                   U	 g r—   rê  rï  s     r.   rà   ÚGeneralInterface.__delitem__ý  s   € Ø×Ñ Ñ$r0   c                óH   • [        0 U R                  EU R                  E5      $ r—   )rÞ   rî  rë  r  s    r.   Ú__iter__ÚGeneralInterface.__iter__   s$   € äÐC�t×+Ñ+ÐC¨t×/BÑ/BÐCÓDÐDr0   c                ó~   • [        U R                  R                  5       U R                  R                  5       -  5      $ r—   )rr   rî  r  rë  r  s    r.   Ú__len__ÚGeneralInterface.__len__  s0   € Ü�4×'Ñ'×,Ñ,Ó.°×1DÑ1D×1IÑ1IÓ1KÑKÓLÐLr0   c                ó<   • U R                   R                  X05        g r—   )rî  rø   )rÈ   r  rt   s      r.   ÚregisterÚGeneralInterface.register  s   € à×Ñ×"Ñ" C <Õ0r0   c                ó4   • [        U R                  5       5      $ r—   )rp   r  r  s    r.   Ú
valid_keysÚGeneralInterface.valid_keys  s   € Ü�D—I‘I“KÓ Ð r0   rê  N)r  rF   rt   r   )r  ú	list[str])r+   r*   r  r  r  rî  rÍ   rý   r   rà   rö  rù  r'  rü  rÿ  r  rµ   r0   r.   rè  rè  æ  sG   † ñð €Oò!ò)ò1ò%òEòMð ó1ó ð1÷!r0   rè  é   g      ð?g      >@c                ó$   ^ ^^^^• UUUUU 4S jnU$ )ae  
Decorator that retries a function call with exponential backoff.

Args:
    max_retries (`int`, *optional*, defaults to 5):
        Maximum number of retry attempts.
    initial_delay (`float`, *optional*, defaults to 1.0):
        Initial delay in seconds before the first retry.
    max_delay (`float`, *optional*, defaults to 30.0):
        Maximum delay in seconds between retries.
    jitter (`bool`, *optional*, defaults to `True`):
        Whether to add random jitter to the delay.
    exceptions (`tuple`, *optional*, defaults to `(Exception,)`):
        Tuple of exception types to catch and retry on.
c                ó<   >^ • [        T 5      UU UUUU4S j5       nU$ )Nc                 ó‚  >• Tn[        STS-   5       H  n T" U 0 UD6s  $    g ! T a”  nUT:X  a  e [        UT
5      nT	(       a  U[        R                  " SS5      -  n[        R                  STR                   SU ST SU SUS	 S
35        [        R                  " U5        [        US-  T
5      n S nAM¦  S nAff = f)Nr   gš™™™™™é?g333333ó?Ú[z
] attempt Ú/z	 failed: z
Retrying in z.1fzs...r   )	ÚrangeÚminÚrandomÚuniformrÙ  Úinfor+   ÚtimeÚsleep)rÑ   rÒ   ÚdelayÚattemptÚexcÚ	sleep_forÚ
exceptionsrˆ  Úinitial_delayÚjitterÚ	max_delayÚmax_retriess         €€€€€€r.   rŒ  Ú)retry.<locals>.decorator.<locals>.wrapper'  sÐ   ø€ à!ˆEä   K°!¡OÖ4�ð6Ù Ð0¨Ñ0Ò0ò 5øð "ó 6Ø +Ó-Øä # E¨9Ó 5�IÞØ!¤V§^¢^°C¸Ó%=Ñ=˜	ä—K‘KØ˜DŸM™M˜?¨*°W°I¸Q¸{¸mÈ9ÐUXÐTYð Z'Ø'0° o°Tð;ôô —J’J˜yÔ)Ü ¨¡	¨9Ó5–Eûð6ús   —$¤B>ªB	B9Â9B>rÄ  )rˆ  rŒ  r  r  r  r  r  s   ` €€€€€r.   r”  Úretry.<locals>.decorator&  s%   ù€ Ü	ˆt‹÷	6ñ 	6ó 
ð	6ð* ˆr0   rµ   )r  r  r  r  r  r”  s   ````` r.   Úretryr    s   ü€ ÷.ñ ð2 Ðr0   )r   ztype[ModelOutput]r  r  )r  rl   )r  ú
str | None)r  rn   )NTN)r|   rF   ri   ztorch.dtype | Nonerw   rn   rx   r›  )NNN)rŒ   r  r�   r¡  r  rn   )r’   r  r  ztuple[bool, str | None])rÀ   rF   )r  rÆ   r  ztuple[list[Any], list[str]]r—   )rW   zIterable[Any]r   r  r   ztype[ModelOutput] | Noner  rÆ   r[  )rW  r   rX  rF   rU  rF   )r–  zlist | None)rÃ   zdict[str, Any]r  rn   )r³  rF   r  rn   )rº  ú	nn.Moduler  rF   rt   r   )rº  r  r  rF   )cr  Ú
__future__r   rE  r¼   r¬  r
  r‰   r  r�  Úcollectionsr   r   Úcollections.abcr   r   r   Ú
contextlibr	   r
   r   Údataclassesr   r   Úenumr   Ú	functoolsr   r   Útypingr   r   r   r²   rD   r%   r   Úimport_utilsr   r   r   r!   r   Ú
get_loggerr+   rÙ  r    rŽ  r   r¦  r/   r…   rA   rK   rU   rZ   rN   rM   re   rj   rs   r}   rƒ   rO   r�   r”   r§   r¶   rÄ   rÆ   r(   r)   rF   r"  r)  r1  r6  rK  rR  rV  r_  rc  ri  rl  rq  rw  rz  r—  r™  rª  r¶  r¹  r¾  rÆ  rä  ræ  rè  rî   r  rµ   r0   r.   Ú<module>r'     s\  ðòõ #ã Û Û 	Û Û 	Û Û ß -ß >Ñ >ß EÑ Eß ,Ý ß $ß 0Ñ 0ã å ß QÑ Qö ÛÝð 
×	Ò	˜HÓ	%€ð Ð Ù×ÑØÐá14³Ð  Ó 6ô4ð2 Ð Ù×ÑØÐô5ôò9ô&ô"%ô	'ô	'ô&ò"ð, !%ØØ!%ð	Øðàðð ðð õ	ò:#ô:ð _cð!7Ø5?ð!7ØQ[ð!7à	õ!7ôH
;òòDô0ôI3�+ô I3ôX6ð -1ð5Øð5àð5ð *ð5ð õ	5ô	
�3˜ô 	
ô�lô ô�ô ÷-ñ -ò$ò Aö 9ô	Nò	Lô	Lò	Pò	Pò	cò	eöLô^$˜¨%ò $ôN+ô
ô89ô	3òò.Oòj,ô
&!�~ô &!ðT ØØØØˆ|õ0r0   