
    iq	                     N    d dl Zd dlZd dlmZ d ZdedefdZdefdZ	d Z
d	 Zy)
    Nwrapsc           	          | t         j                  vr|S t         j                  j                  | d      }g d}g d}||v ry||vrt        d|  d| d||z          y)	z-Check if environment varable has True-y value0)1trueTRUEonONyesYES)r   falseFALSEoffOFFnoNOTz'Unexpected environment variable value `=z`. Expected one of F)osenvirongetRuntimeError)vardefaultvaltruesfalsess        [/var/www/html/engine/venv/lib/python3.12/site-packages/torchaudio/_internal/module_utils.pyeval_envr      sw    
"**
**..c
"C;E>F
e|
&5cU!C5 A$v~.01 	1     modulesreturnc                  &    t        d | D              S )aP  Returns if a top-level module with :attr:`name` exists *without**
    importing it. This is generally safer than try-catch block around a
    `import X`. It avoids third party libraries breaking assumptions of some of
    our tests, e.g., setting multiprocessing start method when imported
    (see librosa/#747, torchvision/#544).
    c              3   ^   K   | ]%  }t         j                  j                  |      d u ' y wN)	importlibutil	find_spec).0ms     r   	<genexpr>z&is_module_available.<locals>.<genexpr>    s$     H1y~~''*$6Hs   +-)all)r!   s    r   is_module_availabler-      s     HHHHr    c                      | D cg c]  }t        |      r| }}|sd }|S t        |      dk(  rd|d    nd| fd}|S c c}w )zDecorate function to give error message if invoked without required optional modules.

    This decorator is to give better error message to users rather
    than raising ``NameError:  name 'module' is not defined`` at random places.
    c                     | S r%    funcs    r   	decoratorz"requires_module.<locals>.decorator-   s    Kr       zmodule: r   z	modules: c                 2     t                fd       }|S )Nc                  R    t        j                   dj                   d       )N.z
 requires r   
__module____name__)argskwargsr2   reqs     r   wrappedz3requires_module.<locals>.decorator.<locals>.wrapped4   s*    "doo%6ajQTPU#VWWr    r   )r2   r>   r=   s   ` r   r3   z"requires_module.<locals>.decorator3   s"    4[X X Nr    )r-   len)r!   r*   missingr3   r=   s       @r   requires_modulerA   #   si     "@Q)<Q)?q@G@	  *-W):%)G9@U	 # As
   AAc                       fd}|S )zLGenerate decorator to give users message about missing TorchAudio extension.c                 2     t                fd       }|S )Nc                  R    t        j                   dj                   d       )Nr7    r8   )r;   r<   r2   messages     r   r>   z5fail_with_message.<locals>.decorator.<locals>.wrappedA   s(    $//!2!DMM?!G9MNNr    r   )r2   r>   rF   s   ` r   r3   z$fail_with_message.<locals>.decorator@   s"    	t	O 
	O r    r0   )rF   r3   s   ` r   fail_with_messagerG   =   s     r    c                     | S )zlOp-op decorator. Used in place of fail_with_message when a functionality that requires extension works fine.r0   r1   s    r   no_oprI   J   s    Kr    )importlib.utilr&   r   	functoolsr   r   strboolr-   rA   rG   rI   r0   r    r   <module>rN      s?     	 &I# I$ Ic 4
r    