a
    ==ic%                     @   s$   d dl mZ ejejdddZdS )    N)gmreturnc                    sJ   dd  | j j fddd |   W d   n1 s<0    Y  | 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g| S )Nzimport pdb; pdb.set_trace()
 bodyr   r   l/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/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_transformerN)graphZon_generate_codeZ	recompile)r   r   r   r   	set_trace   s    
&r   )Ztorch.fxZfxZGraphModuler   r   r   r   r   <module>   s   