
    ~Vjim                         d dl Zd dlZd dlZd dlmZmZ d dlmZ d Z	de
defdZde
fdZg Zdd
e
dee
         defdZdd
e
dee
         defdZdZdZ eedd          ZefdZedfdZ eee          Z eedd          Zd Zd ZdS )    N)partialwraps)Optionalc           	          | t           j        vr|S t           j                            | d          }g d}g d}||v rdS ||vrt          d|  d| d||z              dS )	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        [/root/voice-cloning/.venv/lib/python3.11/site-packages/torchaudio/_internal/module_utils.pyeval_envr       s    
"*
*..c
"
"C;;;E>>>F
e||t
&0c 0 0C 0 0$v~0 01 1 	1 5    modulesreturnc                  4    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   X   K   | ]%}t           j                            |          d uV  &d S N)	importlibutil	find_spec.0ms     r   	<genexpr>z&is_module_available.<locals>.<genexpr>"   s7      HH1y~''**$6HHHHHHr!   )all)r"   s    r   is_module_availabler/      s!     HHHHHHHHr!   c                  |    d | D             }|sd }n(t          |          dk    rd|d          nd| fd}|S )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                 0    g | ]}t          |          |S  )r/   r*   s     r   
<listcomp>z#requires_module.<locals>.<listcomp>+   s&    @@@Q)<Q)?)?@q@@@r!   c                     | S r&   r2   funcs    r   	decoratorz"requires_module.<locals>.decorator/   s    Kr!      zmodule: r   z	modules: c                 @     t                      fd            }|S )Nc                  F    t          j         dj         d           )N.z
 requires r   
__module____name__)argskwargsr6   reqs     r   wrappedz3requires_module.<locals>.decorator.<locals>.wrapped6   s,    "do#V#V#V#VQT#V#VWWWr!   r   )r6   rB   rA   s   ` r   r7   z"requires_module.<locals>.decorator5   s?    4[[X X X X X [X Nr!   )len)r"   missingr7   rA   s      @r   requires_modulerF   %   s     A@'@@@G 	 	 	 	 *-W):):%%%%@UG@U@U	 	 	 	 	 r!   F	directionversionremovec                 L     t                      fd            }|S )Nc                       d }r|ddndt                    z    dz  }t          j        |d            | i |S )Nz has been deprecated. z It will be removed from za futurezthe 
 release.    )
stacklevel)strwarningswarn)r?   r@   messagerG   r6   namerI   rH   s      r   rB   z wrap_deprecated.<locals>.wrappedC   sw    <<<< 	xw::V\_bcj_k_kVkwwwwGg!,,,,tT$V$$$r!   rC   )r6   rS   rG   rH   rI   rB   s   ````` r   wrap_deprecatedrT   B   sK    
4[[% % % % % % % % [% Nr!   c                       fd}|S )zDecorator to add deprecation message

    Args:
        direction (str): Migration steps to be given to users.
        version (str or int): The version when the object will be removed
        remove (bool): If enabled, append future removal message.
    c                     t          | | j         d| j                   }d}r|ddn dz  }d| d d	| j         d
|_        |S )Nr;   rH   rI   z#This function has been deprecated. zIt will be removed from futurerL   z%DEPRECATED

    .. warning::

       z
       z

    
    )rT   r=   r>   __doc__)r6   rB   rR   rG   rI   rH   s      r   r7   zdeprecated.<locals>.decoratorW   s    !$4?(L(LT](L(Liahqwxxx7 	gfgo((SZffffG 		 
 	  
\   r!   r2   )rG   rH   rI   r7   s   ``` r   
deprecatedr[   N   s0          & r!   zThis deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. Please see https://github.com/pytorch/audio/issues/3902 for more information.a*  This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information.2.9TrW   c                     t          | j        | j         d| j         |dd          | _        d| d| j         d| _        t
                              |            | S )Nr;   r\   TrW   ztDEPRECATED

.. warning::

    This class is deprecated from version 2.8. It will be removed in the 2.9 release.
    
)rT   __init__r=   r>   rZ   UNSUPPORTEDappend)cmsgs     r   dropping_class_supportrd   |   s{     -K-Kqz-K-KSZ_hlmmmAJ
 	    AI qHr!   c                 ,    d| d| j          d| _         | S )Nz[DEPRECATED]

.. warning::

    This object is deprecated deprecated from version 2.8. It will be removed in the 2.9 release.
    r^   rY   )rZ   )rb   rc   rS   s      r   dropping_const_supportrf      s7    
 	    AI Hr!   )rc   c                       fd}|S )zLGenerate decorator to give users message about missing TorchAudio extension.c                 @     t                      fd            }|S )Nc                  F    t          j         dj         d           )Nr;    r<   )r?   r@   r6   rR   s     r   rB   z5fail_with_message.<locals>.decorator.<locals>.wrapped   s+    $/MMDMMMGMMNNNr!   rC   )r6   rB   rR   s   ` r   r7   z$fail_with_message.<locals>.decorator   s?    	t	O 	O 	O 	O 	O 
	O r!   r2   )rR   r7   s   ` r   fail_with_messagerk      s$         r!   c                     | S )zlOp-op decorator. Used in place of fail_with_message when a functionality that requires extension works fine.r2   r5   s    r   no_oprm      s    Kr!   )NF)importlib.utilr'   r   rP   	functoolsr   r   typingr   r    rO   boolr/   rF   r`   rT   r[   DEPRECATION_MSGIO_DEPRECATION_MSGdropping_supportrd   rf   dropping_class_io_supportdropping_io_supportrk   rm   r2   r!   r   <module>rw      s       				  $ $ $ $ $ $ $ $        &I# I$ I I I Ic    4 	 	3 	# 	W[ 	 	 	 	 #  d    @T T  :ouTJJJ  #2     #2 	 	 	 	 $G$:@RSSS  j!3U4PPP 
 
 
    r!   