o
    "i                     @   s|   d dl mZmZ ddlmZ g dZG dd dZedZedZ	G d	d
 d
e
ZdD ]Zeeeefdd q+eeZdS )    )AnyIterable   )__version__)TorchVersionVersionInvalidVersionc                   @   s:   e Zd ZdZdeddfddZdd Zd	d
 Zdd ZdS )_LazyImporta  Wraps around classes lazy imported from packaging.version
    Output of the function v in following snippets are identical:
       from packaging.version import Version
       def v():
           return Version('1.2.3')
    and
       Version = _LazyImport('Version')
       def v():
           return Version('1.2.3')
    The difference here is that in later example imports
    do not happen until v is called
    cls_namereturnNc                 C   s
   || _ d S N)	_cls_name)selfr
    r   b/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/torch/torch_version.py__init__   s   
z_LazyImport.__init__c                 C   s:   zdd l }W n ty   ddlm} Y nw t|j| jS )Nr   )	packaging)Zpackaging.versionImportErrorpkg_resourcesr   getattrversionr   )r   r   r   r   r   get_cls   s   z_LazyImport.get_clsc                 O   s   |   |i |S r   )r   )r   argskwargsr   r   r   __call__   s   z_LazyImport.__call__c                 C   s   t ||  S r   )
isinstancer   )r   objr   r   r   __instancecheck__"   s   z_LazyImport.__instancecheck__)	__name__
__module____qualname____doc__strr   r   r   r   r   r   r   r   r	      s    	r	   r   r   c                       s@   e Zd ZdZdedefddZdededef 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'
    inpr   c                 C   sN   t |t r	|S t |trt|S t |tr#tddd |D S t|)N.c                 s   s    | ]}t |V  qd S r   )r"   ).0itemr   r   r   	<genexpr>G   s    z3TorchVersion._convert_to_version.<locals>.<genexpr>)r   r   r   r"   r   joinr   )r   r#   r   r   r   _convert_to_version;   s   

z TorchVersion._convert_to_versioncmpmethodc              
      s`   zt t| || |W S  ty/ } zt|t s t t ||W  Y d }~S d }~ww r   )r   r   r)   BaseExceptionr   r   r   super)r   r*   r+   e	__class__r   r   _cmp_wrapperK   s   zTorchVersion._cmp_wrapper)
r   r   r    r!   r   r)   r"   boolr1   __classcell__r   r   r/   r   r   )   s    "r   )__gt____lt____eq____ge____le__c                 C   s   |  ||S r   )r1   )xyr+   r   r   r   <lambda>W   s    r;   N)typingr   r   r   r   Zinternal_version__all__r	   r   r   r"   r   Z
cmp_methodsetattrr   r   r   r   <module>   s     -