o
    he                     @   st   d dl Zd dlmZ d dlmZmZ ddlmZ eej	
dZdeeef ded	efd
dZdedefddZdS )    N)Union)Versionparse   )STR_OPERATION_TO_FUNCtorchlibrary_or_version	operationrequirement_versionc                 C   sX   |t  vrtdtt   d| t | }t| tr%ttj	| } || t|S )a  
    Compares a library version to some requirement using a given operation.

    Args:
        library_or_version (`str` or `packaging.version.Version`):
            A library name or a version to check.
        operation (`str`):
            A string representation of an operator, such as `">"` or `"<="`.
        requirement_version (`str`):
            The version to compare the library version against
    z`operation` must be one of z, received )
r   keys
ValueErrorlist
isinstancestrr   	importlibmetadataversion)r   r	   r
    r   O/var/www/html/ai/venv/lib/python3.10/site-packages/accelerate/utils/versions.pycompare_versions   s   
r   r   c                 C   s   t t| |S )a	  
    Compares the current PyTorch version to a given reference with an operation.

    Args:
        operation (`str`):
            A string representation of an operator, such as `">"` or `"<="`
        version (`str`):
            A string version of PyTorch
    )r   torch_version)r	   r   r   r   r   is_torch_version.   s   
r   )importlib.metadatar   typingr   packaging.versionr   r   	constantsr   r   r   r   r   r   r   r   r   r   r   <module>   s   