o
    j9:j[                     @   s   d dl Z d dlmZ d dlZd dlmZ 	ddedejjde	dB dedef
d	d
Z
dedededefddZdejjdeeef dB fddZddejjde	defddZdS )    N)Any)
LazyStringnamegmmaybe_idkwargsreturnc                    sr   dt ffdd dvrdd< dv r/ztj s dd< W n ty.   dd< Y nw t fddS )	z;
    Returns a LazyString that formats the graph code.
    r   c                      s    d ur d  S S )N  r
   )r   r   r
   V/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/torch/fx/_utils.pyformat_name   s   z+lazy_format_graph_code.<locals>.format_nameprint_outputFcoloredc                      s(   t d   djjjjdi S )Nz===== z =====
r
   )_format_graph_codeforward__code__co_filenameprint_readabler
   )r   r   r   r
   r   <lambda>    s
    z(lazy_format_graph_code.<locals>.<lambda>)strsysstdoutisattyAttributeErrorr   )r   r   r   r   r
   )r   r   r   r   r   r   lazy_format_graph_code   s   
r   filename	graph_strc                 C   s   d|  d| d| dS )z7
    Returns a string that formats the graph code.
    zTRACED GRAPH
 r	   
r
   )r   r   r   r
   r
   r   r   (   s   r   graphc                 C   s2   | j D ]}|jdkrd|jv r|jd   S qdS )zF
    Returns the nn_module_stack of the first call_function node.
    call_functionnn_module_stackN)nodesopmeta)r   noder
   r
   r   #first_call_function_nn_module_stack/   s
   
r%      r$   	num_nodesc                 C   sP   g }| }t |D ]}|t|  |jdkr n|j}qd|ddd S )zD
    Returns a string of the last num_nodes nodes in the graph.
    rootr   N)rangeappendr   format_noder"   prevjoin)r$   r'   node_contextscur_r
   r
   r   get_node_context9   s   
r2   )N)r&   )r   typingr   torchtorch._loggingr   r   fxGraphModuleintr   r   Graphdictr%   Noder2   r
   r
   r
   r   <module>   s&    
 " 
