U
    d%                     @   s$   d dl mZ ejejdddZdS )    N)gmreturnc              	      s6   dd  | j j fddd |   W 5 Q R X | S )a  
    Sets a breakpoint in `gm`'s generated python code. It drops into pdb when
    `gm` gets run.

    Args:
        gm: graph module to insert breakpoint. It is then recompiled for it to
            take effect.

    Returns:
        the `gm` with breakpoint inserted.
    c                 S   s   d| S )Nimport pdb; pdb.set_trace()
)r    bodyr   r   ?/tmp/pip-unpacked-wheel-ua33x9lu/torch/fx/experimental/debug.py
insert_pdb   s    zset_trace.<locals>.insert_pdbc                    s    fddS )Nc                    s    r | n| S )Nr   r   )cur_transformr	   r   r   <lambda>   s    z-set_trace.<locals>.<lambda>.<locals>.<lambda>r   r
   r	   r   r   r      s    zset_trace.<locals>.<lambda>)Zmake_transformer)graphZon_generate_codeZ	recompile)r   r   r   r   	set_trace   s    
r   )Ztorch.fxZfxZGraphModuler   r   r   r   r   <module>   s   