a
    h                     @   sz   d dl Z d dlmZmZ d dlmZmZ edZedZedZ	e
 Zeee	ef ef eee	ef ef ddd	ZdS )
    N)CallableTypeVar)Concatenate	ParamSpec_P_T_C)freturnc                    s6   dj   tttjtjtd fd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).
    Z_cache_method_)selfargskwargsr
   c                    sb   |rJ t |  d  }s(i }t|  | ||t}|tur@|S | g|R i |}|||< |S )N)getattrsetattrget_cache_sentinel)r   r   r   cacheZcached_valuevalueZ
cache_namer	    D/var/www/auris/lib/python3.9/site-packages/torch/utils/_functools.pywrap   s    zcache_method.<locals>.wrap)__name__	functoolswrapsr   r   r   r   r   )r	   r   r   r   r   cache_method   s    
 r   )r   typingr   r   Ztyping_extensionsr   r   r   r   r   objectr   r   r   r   r   r   <module>   s   