Ë
    ÌÓ^j  ã                  óÐ   — d dl mZ d dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
mZ erd dlmZ d dlmZ  ed«      Z e	d	«      Z e	d
«      Z e«       Z ed¬«      Zdd„Z	 	 	 	 dd„Zy)é    )ÚannotationsN)ÚThreadPoolExecutor)ÚConcatenateÚTYPE_CHECKINGÚTypeVar)Ú	ParamSpec)ÚCallable)ÚFutureÚ_PÚ_TÚ_Cé   )Úmax_workersc                ó²   ‡ ‡‡‡— t         Št        j                  «       ŠdŠdˆˆˆˆ fd„}dˆˆfd„}dˆˆˆfd„}dˆˆˆˆ fd„}||_        ||_        ||_        |S )	z�
    Like functools.cache but with a prefetch() method that starts computing
    the value in a background thread, and a set() method for prepopulating.
    Nc                 óª   •— ‰5  ‰ t         ur‰ cd d d «       S ‰�‰j                  «       Š d Š‰ cd d d «       S  ‰«       Š ‰ cd d d «       S # 1 sw Y   y xY w©N)Ú_cache_sentinelÚresult©Ú_cacheÚ_futureÚ_lockÚfuncs   €€€€úa/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/utils/_functools.pyÚwrapperz#prefetchable_cache.<locals>.wrapper"   sb   ø€ àñ 	Øœ_Ñ,Ø÷	ñ 	ð Ð"Ø Ÿ™Ó)�Ø�Ø÷	ñ 	ñ “VˆFØ÷	÷ 	ò 	ús   „
A	˜A	·A	Á	Ac                ó^   •— ‰5  ‰t         urt        d«      ‚| Šd d d «       y # 1 sw Y   y xY w)Nz$prefetchable_cache value already set)r   ÚRuntimeError)Úvalr   r   s    €€r   Úset_valz#prefetchable_cache.<locals>.set_val.   s4   ø€ àñ 	Øœ_Ñ,Ü"Ð#IÓJÐJØˆF÷	÷ 	ñ 	ús   „#£,c                 óD   •— ‰5  t         Š d Šd d d «       y # 1 sw Y   y xY wr   )r   )r   r   r   s   €€€r   Úclearz!prefetchable_cache.<locals>.clear5   s%   ø€ àñ 	Ü$ˆFØˆG÷	÷ 	ñ 	ús   „	–c                 ó†   •— ‰5  ‰ t         us‰�
	 d d d «       y t        j                  ‰«      Šd d d «       y # 1 sw Y   y xY wr   )r   Ú_prefetch_executorÚsubmitr   s   €€€€r   Úprefetchz$prefetchable_cache.<locals>.prefetch;   sG   ø€ àñ 	6Øœ_Ñ,°Ð0CØ÷	6ð 	6ô )×/Ñ/°Ó5ˆG÷	6÷ 	6ñ 	6ús   „7™7·A )Úreturnr   )r   r   r&   ÚNone)r&   r'   )r   Ú	threadingÚLockÚsetr!   r%   )r   r   r   r!   r%   r   r   r   s   `    @@@r   Úprefetchable_cacher+      sV   û€ ô
 *€FÜ�N‰NÓ€EØ!%€G÷
ð 
ö÷÷6ð 6ð €G„KØ€G„MØ€GÔØ€Nó    c                óf   ‡ ‡— d‰ j                   z   Št        j                  ‰ «      dˆˆ fd„«       }|S )a  
    Like `@functools.cache` but for methods.

    `@functools.cache` (and similarly `@functools.lru_cache`) shouldn't be used
    on methods because it caches `self`, keeping it alive
    forever. `@cache_method` ignores `self` so won't keep `self` alive (assuming
    no cycles with `self` in the parameters).

    Footgun warning: This decorator completely ignores self's properties so only
    use it when you know that self is frozen or won't change in a meaningful
    way (such as the wrapped function being pure).
    Ú_cache_method_c                óÀ   •— |rt        d«      ‚t        | ‰d «      x}si }t        | ‰|«       |j                  |t        «      }|t        ur|S  ‰| g|¢­i |¤Ž}|||<   |S )Nz.cache_method does not accept keyword arguments)ÚAssertionErrorÚgetattrÚsetattrÚgetr   )ÚselfÚargsÚkwargsÚcacheÚcached_valueÚvalueÚ
cache_nameÚfs         €€r   Úwrapzcache_method.<locals>.wrapY   sw   ø€ áÜ Ð!QÓRÐRÜ   z°4Ó8Ð8�Ð8ØˆEÜ�D˜* eÔ,Ø—y‘y ¤Ó7ˆØœÑ.ØÐÙ�$Ð(˜Ò( Ñ(ˆØˆˆd‰Øˆr,   )r4   r   r5   z_P.argsr6   z	_P.kwargsr&   r   )Ú__name__Ú	functoolsÚwraps)r;   r<   r:   s   ` @r   Úcache_methodr@   H   s5   ù€ ð " A§J¡JÑ.€Jä‡_�_�QÓõó ðð €Kr,   )r   úCallable[[], _T]r&   rA   )r;   ú!Callable[Concatenate[_C, _P], _T]r&   rB   )Ú
__future__r   r>   r(   Úconcurrent.futuresr   Útypingr   r   r   Útyping_extensionsr   Úcollections.abcr	   r
   r   r   r   Úobjectr   r#   r+   r@   © r,   r   ú<module>rJ      sq   ðÝ "ã Û Ý 1ß 6Ñ 6Ý 'ñ Ý(Ý)ñ ˆtƒ_€ÙˆTƒ]€ÙˆTƒ]€ñ “(€á'°AÔ6Ð ó,ð^Ø(ðà&ôr,   