U
    ‰do  ã                   @   sT   d dl Z d dlmZmZmZmZmZ eegef eeedf  ee dœdd„ZdS )é    N)ÚAnyÚCallableÚIterableÚListÚTuple.)ÚcallableÚinputsÚreturnc              	      sH   t ƒ ‰ ‡ fdd„}z t |¡ |D ]}| |Ž  q"W 5 t d¡ X tˆ ƒS )a¾  Trace the execution of a callable in order to determine which modules it uses.

    Args:
        callable: The callable to execute and trace.
        inputs: The input to use during tracing. The modules used by 'callable' when invoked by each set of inputs
            are union-ed to determine all modules used by the callable for the purpooses of packaging.

    Returns: A list of the names of all modules used during callable execution.
    c                    s„   |dkrd S | j j}d }|| jkr0| j| j}nB|| jkrH| j| j}n*d| jkrrt| jd |d ƒ}|rn|jnd }|r€ˆ  |¡ d S )NÚcallÚself)Úf_codeÚco_nameÚ	f_globalsÚ
__module__Úf_localsÚgetattrÚadd)ÚframeÚeventÚargÚnameÚmoduleÚmethod©Zmodules_used© úL/tmp/pip-unpacked-wheel-ua33x9lu/torch/package/analyze/trace_dependencies.pyÚrecord_used_modules   s    	


z/trace_dependencies.<locals>.record_used_modulesN)ÚsetÚsysÚ
setprofileÚlist)r   r   r   Úinpr   r   r   Útrace_dependencies   s    
r"   )	r   Útypingr   r   r   r   r   Ústrr"   r   r   r   r   Ú<module>   s
    þ