U
    Mh                     @   sZ   d dl Z d dlmZmZmZmZmZ dg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trace_dependencies.)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 Z/var/www/html/venv/lib/python3.8/site-packages/torch/package/analyze/trace_dependencies.pyrecord_used_modules   s    	


z/trace_dependencies.<locals>.record_used_modulesN)setsys
setprofilelist)r   r	   r   Zinpr   r   r   r      s    
)
r   typingr   r   r   r   r   __all__strr   r   r   r   r   <module>   s    