o
    Xi
                     @  sx   d Z ddlmZ ddlZddlmZmZ ddlZdd	d
Z	dddZ
dddZdddZdddZdd ZdddZdS )zVersion utils for testing.    )annotationsN)CallableSequenceversionstrreturnboolc                 C  &   ddl }tj|jjtj| jk S )zAReturns True if the ONNX version is older than the given version.r   N)onnx	packagingr   parse__version__release)r   r
    r   V/home/ubuntu/.local/lib/python3.10/site-packages/onnxscript/_internal/version_utils.pyonnx_older_than   
   r   c                 C  r	   )zBReturns True if the torch version is older than the given version.r   N)torchr   r   r   r   r   )r   r   r   r   r   torch_older_than   r   r   bool | Nonec                 C  s@   zddl }W n
 ty   Y dS w tj|jjtj| jk S )zIReturns True if the transformers version is older than the given version.r   N)transformersImportErrorr   r   r   r   r   )r   r   r   r   r   transformers_older_than!   s   r   c                 C  r	   )zHReturns True if the onnxruntime version is older than the given version.r   N)onnxruntimer   r   r   r   r   )r   r   r   r   r   onnxruntime_older_than.   r   r   c                 C  r	   )zBReturns True if the numpy version is older than the given version.r   N)numpyr   r   r   r   r   )r   r   r   r   r   numpy_older_than8   r   r   c                  C  s,   zddl } | s	J W dS  ty   Y dS w )z#Tells if transformers is installed.r   NTF)r   r   )r   r   r   r   has_transformersB   s   r   warnsWarning | Sequence[Warning]r   c                   s    fdd}|S )zlCatches warnings.

    Args:
        warns: warnings to ignore

    Returns:
        decorated function
    c                   s*   d u rt d  d fdd}|S )Nzwarns cannot be None for 'z'.c                   s@   t   t d  | W  d    S 1 sw   Y  d S )Nignore)warningscatch_warningssimplefilter)self)fctr   r   r   call_f[   s   
$z0ignore_warnings.<locals>.wrapper.<locals>.call_f)AssertionError)r%   r&   r   )r%   r   wrapperW   s   z ignore_warnings.<locals>.wrapperr   )r   r)   r   r(   r   ignore_warningsM   s   
r*   )r   r   r   r   )r   r   r   r   )r   r   r   r   )__doc__
__future__r   r!   typingr   r   packaging.versionr   r   r   r   r   r   r   r*   r   r   r   r   <module>   s   








