
    [Th                         S SK r S SKJr  S SKrS SKJr  S
S jrS rS\R                  R                  S\\
   4S jrSS\4S	 jjrg)    N)Optional)
LazyStringc                    ^ ^^^^ UU 4S jmST;  a  STS'   ST;   a)   [         R                  R                  5       (       d  STS'   [	        UUU4S j5      $ ! [         a    STS'    N"f = f)z3
Returns a LazyString that formats the graph code.
c                     > T b  T ST  3$ T$ )N  )maybe_idnames   G/var/www/auris/envauris/lib/python3.13/site-packages/torch/fx/_utils.pyformat_name+lazy_format_graph_code.<locals>.format_name   s    V1XJ''K    print_outputFcoloredc            	         > [        ST " 5        S3TR                  R                  R                  TR                  " S0 TD65      $ )Nz===== z =====
r   )_format_graph_codeforward__code__co_filenameprint_readable)r   gmkwargss   r   <lambda>(lazy_format_graph_code.<locals>.<lambda>   s=    "[]O8,JJ++''
r   )sysstdoutisattyAttributeErrorr   )r
   r   r	   r   r   s   ````@r   lazy_format_graph_coder   	   su    
 V#!&~F	&::$$&&$)y! 	
   	& %F9	&s   (A A*)A*c                     SU  SU SU S3$ )z/
Returns a string that formats the graph code.
zTRACED GRAPH
 r   
r   )r
   filename	graph_strs      r   r   r   '   s     TF!H:Qyk<<r   graphreturnc                     U R                    H6  nUR                  S:X  d  M  SUR                  ;   d  M'  UR                  S   s  $    g)z>
Returns the nn_module_stack of the first call_function node.
call_functionnn_module_stackN)nodesopmeta)r$   nodes     r   #first_call_function_nn_module_stackr-   .   s?     77o%*;tyy*H99.//  r   c                     / nU n[        U5       H@  nUR                  UR                  5       5        UR                  S:X  a    OUR                  nMB     SR                  USSS2   5      $ )z<
Returns a string of the last num_nodes nodes in the graph.
rootr!   N)rangeappendformat_noder*   prevjoin)r,   	num_nodesnode_contextscur_s        r   get_node_contextr:   8   sd     M
C9S__./66Vhh	 
 99]4R4())r   )N)   )r   typingr   torchtorch._loggingr   r   r   fxGraphdictr-   strr:   r   r   r   <module>rC      sF    
   %<=uxx~~ (4. *3 *r   