U
    zh	                     @   sl   d dl mZ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	 qFeeZd
S )    )AnyIterable   )InvalidVersionVersion)__version__TorchVersionc                       s:   e 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item r   E/var/www/html/venv/lib/python3.8/site-packages/torch/torch_version.py	<genexpr>*   s     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              
      sb   zt t| || |W S  tk
r\ } z$t|ts8 t t || W Y S d }~X Y nX d S r   )getattrr   r   BaseExceptionr   r   super)r   r   r   e	__class__r   r   _cmp_wrapper.   s    
zTorchVersion._cmp_wrapper)
__name__
__module____qualname____doc__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-   N)typingr   r   Z_vendor.packaging.versionr   r   versionr   Zinternal_version__all__r   r   Z
cmp_methodsetattrr   r   r   r   <module>   s   .
