+
    õäûj%  ã                  óÎ   € ^ RI Ht ^ RIHt ^ RIHtHtHtHt ^ RI	t	^RI
Ht ^RIHtHtHtHt  ! R R]4      t ! R	 R
]4      t]! RR7       ! R R4      4       t ! R R4      tR# )é    )Úannotations)Ú	dataclass)ÚCallableÚLiteralÚMappingÚSequenceN)Úcanonicalize_state_dict)ÚArchIdÚArchitectureÚModelDescriptorÚ	StateDictc                  ó   € ] tR t^tRtRtR# )ÚUnsupportedModelErrorzl
An error that will be thrown by `ArchRegistry` and `ModelLoader` if a model architecture is not supported.
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚWC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\spandrel\__helpers\registry.pyr   r      ó   † õr   r   c                  ó   € ] tR t^tRtRtR# )ÚDuplicateArchitectureErrorzY
An error that will be thrown by `ArchRegistry` if the same architecture is added twice.
r   Nr   r   r   r   r   r      r   r   r   T)Úfrozenc                  ó^   € ] tR t^t$ RtR]R&    R]R&    R
tR]R&    ]RR R	 ll4       tR
t	R# )ÚArchSupportz[
An entry in an `ArchRegistry` that describes how to detect and load a model architecture.
úArchitecture[torch.nn.Module]ÚarchitecturezCallable[[StateDict], bool]Údetectútuple[ArchId, ...]Úbeforec               ó$   € V ^8„  d   QhRRRRRR/# )é   Úarchr    r$   r#   Úreturnr   r   )Úformats   "r   Ú__annotate__ÚArchSupport.__annotate__0   s$   € ÷ 6ñ 6Ø+ð6Ø5Gð6à	ñ6r   c                ó.   € \        W P                  V4      # )z`
Creates an `ArchSupport` from an `Architecture` by using the architecture's ``detect`` method.
)r   r"   )r'   r$   s   &&r   Úfrom_architectureÚArchSupport.from_architecture/   s   € ô ˜4§¡¨fÓ5Ð5r   r   N)r   )
r   r   r   r   r   Ú__annotations__r$   Ústaticmethodr-   r   r   r   r   r   r      sG   ‡ ñð 0Ó/ðð (Ó'ðð
 "$€FÐÓ#ðð ö6ó ô6r   r   c                  ó¨   € ] tR t^9tRtR tR R ltR R ltR R ltR	 t	R
 R lt
R R ltRR R lltRR/R R llt]R R l4       tR R ltRtR# )ÚArchRegistryzr
A registry of architectures.

Architectures are detected/loaded in insertion order unless `before` is specified.
c                	ó0   € . V n         . V n        / V n        R # ©N)Ú_architecturesÚ_orderedÚ_by_id©Úselfs   &r   Ú__init__ÚArchRegistry.__init__@   s   € à57ˆÔØ/1ˆŒØ46ˆŽr   c               ó   € V ^8„  d   QhRR/# )r&   r(   r2   r   )r)   s   "r   r*   ÚArchRegistry.__annotate__F   s   € ÷ ñ �lñ r   c                ó€   € \        4       pV P                  Vn        V P                  Vn        V P                  Vn        V# )z!
Returns a copy of the registry.
)r2   r5   r6   r7   )r9   Únews   & r   ÚcopyÚArchRegistry.copyF   s4   € ô ‹nˆØ!×0Ñ0ˆÔØ—}‘}ˆŒØ—[‘[ˆŒ
Øˆ
r   c               ó    € V ^8„  d   QhRRRR/# )r&   ÚidzArchId | strr(   Úboolr   )r)   s   "r   r*   r=   P   s   € ÷ !ñ !˜|ð !°ñ !r   c                	ó   € WP                   9   # r4   )r7   ©r9   rC   s   &&r   Ú__contains__ÚArchRegistry.__contains__P   s   € Ø—[‘[Ñ Ð r   c               ó    € V ^8„  d   QhRRRR/# )r&   rC   ústr | ArchIdr(   r   r   )r)   s   "r   r*   r=   S   s   € ÷ 'ñ '˜lð '¨{ñ 'r   c                	ó:   € V P                   \        V4      ,          # r4   )r7   r
   rF   s   &&r   Ú__getitem__ÚArchRegistry.__getitem__S   s   € Ø�{‰{œ6 "›:Õ&Ð&r   c                ó6   € \        V P                  R4      4      # )z@
Returns an iterator over all architectures in insertion order.
Ú	insertion)ÚiterÚarchitecturesr8   s   &r   Ú__iter__ÚArchRegistry.__iter__V   s   € ô �D×&Ñ& {Ó3Ó4Ð4r   c               ó   € V ^8„  d   QhRR/# )r&   r(   Úintr   )r)   s   "r   r*   r=   \   s   € ÷ (ñ (˜ñ (r   c                	ó,   € \        V P                  4      # r4   )Úlenr5   r8   s   &r   Ú__len__ÚArchRegistry.__len__\   s   € Ü�4×&Ñ&Ó'Ð'r   c               ó    € V ^8„  d   QhRRRR/# )r&   rC   rJ   r(   zArchSupport | Noner   )r)   s   "r   r*   r=   _   s   € ÷ 1ñ 1�lð 1Ð'9ñ 1r   c                	óL   € V P                   P                  \        V4      R 4      # r4   )r7   Úgetr
   rF   s   &&r   r\   ÚArchRegistry.get_   s   € Ø�{‰{�‰œv b›z¨4Ó0Ð0r   c               ó    € V ^8„  d   QhRRRR/# )r&   Úorderz!Literal['insertion', 'detection']r(   úlist[ArchSupport]r   )r)   s   "r   r*   r=   b   s   € ÷ 8ñ 8à0ð8ð 
ñ8r   c                óŽ   € VR8X  d   \        V P                  4      # VR8X  d   \        V P                  4      # \        RV 24      h)z°
Returns a new list with all architectures in the registry.

The order of architectures in the list is either insertion order or the order in which architectures are detected.
rO   Ú	detectionzInvalid order: )Úlistr5   r6   Ú
ValueError)r9   r_   s   &&r   rQ   ÚArchRegistry.architecturesb   sF   € ð �KÔÜ˜×+Ñ+Ó,Ð,Ø�kÔ!Ü˜Ÿ™Ó&Ð&ä˜¨u¨gÐ6Ó7Ð7r   Úignore_duplicatesFc               ó$   € V ^8„  d   QhRRRRRR/# )r&   rQ   r   rf   rD   r(   r`   r   )r)   s   "r   r*   r=   r   s(   € ÷ &ñ &à#ð&ð  ð&ð 
ñ	&r   c               óÀ  € \        V P                  4      p\        V P                  4      p. pV F„  pVP                  P
                  V9   d-   V'       d   K(  \        RVP                  P
                   24      hVP                  V4       WdVP                  P
                  &   VP                  V4       K†  	  \        P                  V4      pW0n        Wpn
        W@n        V# )a€  
Adds the given architectures to the registry.

Throws an error if an architecture with the same ID already exists,
unless `ignore_duplicates` is True, in which case the old architecture is retained.

Throws an error if a circular dependency of `before` references is detected.

If an error is thrown, the registry is left unchanged.

Returns a list of architectures that were added.
zDuplicate architecture: )rc   r5   Údictr7   r!   rC   r   Úappendr2   Ú_get_orderedr6   )r9   rf   rQ   Únew_architecturesÚ	new_by_idÚaddedr'   Únew_ordereds   &$*     r   ÚaddÚArchRegistry.addr   sÈ   € ô$ ! ×!4Ñ!4Ó5ÐÜ˜Ÿ™Ó%ˆ	ØˆÛ!ˆDØ× Ñ ×#Ñ# yÔ0ß$ÙÜ0Ø.¨t×/@Ñ/@×/CÑ/CÐ.DÐEóð ð ×$Ñ$ TÔ*Ø.2�d×'Ñ'×*Ñ*Ñ+Ø�L‰L˜Öñ "ô #×/Ñ/Ð0AÓBˆà/ÔØ#ŒØŒØˆr   c               ó    € V ^8„  d   QhRRRR/# )r&   rQ   r`   r(   r   )r)   s   "r   r*   r=   ›   s   € ÷ !ñ !Ð$5ð !Ð:Kñ !r   c                	óN  aaaaaa€ / o/ oV  Fg  pVSVP                   P                  &   VP                   F;  pVS9  d   . SV&   SV,          P                  VP                   P                  4       K=  	  Ki  	  . o\	        4       o. oR  VVVVVV3R lloV  F  pS! V4       K  	  S# )c               ó   € V ^8„  d   QhRR/# )r&   r'   r   r   )r)   s   "r   r*   Ú/ArchRegistry._get_ordered.<locals>.__annotate__©   s   € ÷ 	ñ 	˜ñ 	r   c                óà  <€ V P                   P                  S9   d6   \        R RP                  . SOV P                   P                  N4       24      hV S9   d   R# SP	                  V 4       SP                  V P                   P                  4       SP                  V P                   P                  . 4       F  pS! SV,          4       K  	  SP                  V 4       SP                  4        R# )z/Circular dependency in architecture detection: z -> N)r!   rC   rd   Újoinrp   rj   r\   Úpop)r'   r$   Úby_idÚ
inv_beforeÚorderedÚseenÚstackÚvisits   & €€€€€€r   r~   Ú(ArchRegistry._get_ordered.<locals>.visit©   sÅ   ø€ Ø× Ñ ×#Ñ# uÔ,Ü ØEÀfÇkÁkÐRpÐTYÐRpÐ[_×[lÑ[l×[oÑ[oÐRpÓFqÐErÐsóð ð �tŒ|ÙØ�H‰H�TŒNØ�L‰L˜×*Ñ*×-Ñ-Ô.à$Ÿ.™.¨×):Ñ):×)=Ñ)=¸rÖB�Ù�e˜F•mÖ$ñ Cð �N‰N˜4Ô Ø�I‰IŽKr   )r!   rC   r$   rj   Úset)	rQ   r'   r$   ry   rz   r{   r|   r}   r~   s	   &  @@@@@@r   rk   ÚArchRegistry._get_orderedš   s£   ý€ à13ˆ
Ø+-ˆÛ!ˆDØ*.ˆE�$×#Ñ#×&Ñ&Ñ'ØŸ+œ+�Ø Ô+Ø)+�J˜vÑ&Ø˜6Õ"×)Ñ)¨$×*;Ñ*;×*>Ñ*>Ö?ó &ñ "ð &(ˆÜ!$£ˆØ ˆ÷	õ 	ó  "ˆDÙ�$ŽKñ "ð ˆr   c               ó    € V ^8„  d   QhRRRR/# )r&   Ú
state_dictr   r(   r   r   )r)   s   "r   r*   r=   ¾   s   € ÷ $ñ $˜yð $¨_ñ $r   c                ó²   € \        V4      pV P                   F7  pVP                  V4      '       g   K  VP                  P	                  V4      u # 	  \
        h)zË
Detects the architecture of the given state dict and loads it.

This will canonicalize the state dict if it isn't already.

Throws an `UnsupportedModelError` if the model architecture is not supported.
)r	   r6   r"   r!   Úloadr   )r9   rƒ   r'   s   && r   r…   ÚArchRegistry.load¾   sJ   € ô -¨ZÓ8ˆ
à—M”MˆDØ�{‰{˜:×&Ô&Ø×(Ñ(×-Ñ-¨jÓ9Ò9ñ "ô $Ð#r   )r5   r7   r6   N)rO   )r   r   r   r   r   r:   r@   rG   rL   rR   rX   r\   rQ   rp   r0   rk   r…   r   r   r   r   r2   r2   9   s^   † ñò7õõ!õ'ò5õ(õ1÷8ð &ð #(÷&ðP ô!ó ð!÷F$ñ $r   r2   )Ú
__future__r   Údataclassesr   Útypingr   r   r   r   ÚtorchÚcanonicalizer	   Úmodel_descriptorr
   r   r   r   Ú	Exceptionr   rd   r   r   r2   r   r   r   Ú<module>rŽ      s`   ðÝ "å !ß 7Ó 7ã å 1ß NÓ Nô˜Iô ô ô ñ �$Ô÷6ð 6ó ð6÷@T$ó T$r   