a
    ÇÀhâ	  ã                   @   st   d dl mZ d dlmZ d dlmZmZ d dlmZ	 dgZ
G dd„ deƒZdD ]Zeeeefdd	„ƒ qNee	ƒZd
S )é    )ÚIterable)ÚAny)ÚInvalidVersionÚVersion)Ú__version__ÚTorchVersionc                       s>   e Zd ZdZdZeedœdd„Zeeedœ‡ fdd„Z	‡  Z
S )	r   ab  A string with magic powers to compare to both Version and iterables!
    Prior to 1.10.0 torch.__version__ was stored as a str and so many did
    comparisons against torch.__version__ as if it were a str. In order to not
    break them we have TorchVersion which masquerades as a str while also
    having the ability to compare against both packaging.version.Version as
    well as tuples of values, eg. (1, 2, 1)
    Examples:
        Comparing a TorchVersion object to a Version object
            TorchVersion('1.10.0a') > Version('1.10.0a')
        Comparing a TorchVersion object to a Tuple object
            TorchVersion('1.10.0a') > (1, 2)    # 1.2
            TorchVersion('1.10.0a') > (1, 2, 1) # 1.2.1
        Comparing a TorchVersion object against a string
            TorchVersion('1.10.0a') > '1.2'
            TorchVersion('1.10.0a') > '1.2.1'
    © )ÚinpÚreturnc                 C   sN   t |tƒr|S t |tƒr t|ƒS t |tƒrBtd dd„ |D ƒ¡ƒS t|ƒ‚d S )NÚ.c                 s   s   | ]}t |ƒV  qd S ©N)Ústr)Ú.0Úitemr   r   úO/var/www/html/assistant/venv/lib/python3.9/site-packages/torch/torch_version.pyÚ	<genexpr>,   ó    z3TorchVersion._convert_to_version.<locals>.<genexpr>)Ú
isinstancer   r   r   Újoinr   )Úselfr	   r   r   r   Ú_convert_to_version    s    


z TorchVersion._convert_to_version)ÚcmpÚmethodr
   c              
      s`   zt t| ƒ|ƒ|  |¡ƒW S  tyZ } z(t|tƒs6‚ t tƒ |ƒ|ƒW  Y d }~S d }~0 0 d S r   )Úgetattrr   r   ÚBaseExceptionr   r   Úsuper)r   r   r   Úe©Ú	__class__r   r   Ú_cmp_wrapper0   s    
zTorchVersion._cmp_wrapper)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   Úboolr   Ú__classcell__r   r   r   r   r      s   )Ú__gt__Ú__lt__Ú__eq__Ú__ge__Ú__le__c                 C   s   |   ||¡S r   )r   )ÚxÚyr   r   r   r   Ú<lambda>?   r   r.   N)Úcollections.abcr   Útypingr   Ztorch._vendor.packaging.versionr   r   Ztorch.versionr   Zinternal_versionÚ__all__r   r   Z
cmp_methodÚsetattrr   r   r   r   Ú<module>   s   0
ý