
    <Цi((                         S SK Jr  S SKJrJr  S SKrS SKrS SKrS SKrS SK	r
\R                  S 5       rSS.S jrSSS.S	 jrS
 r " S S5      rS rg)    )TracebackType)ListOptionalNc               #   &  #     S v   g ! [          Ga  n U R                  n/ nUGb  UR                  R                  R                  nUR                  R
                  R                  S5      nUS:X  GaG  UGbC  [        R                  " SSSS9 nUR                  U5        S S S 5        O! , (       d  f       O= fUR                  n[        SWR                  S5      nUR                  UR                  R                  S	9n[        UR                  S
5      (       a8  UR                  UR                  R                  UR                  R                   S9n[#        UUR
                  0 UR$                  ES[&        R(                  0E5      n[+        S XR,                  UR.                  5      n	UR1                  U	5        OUR1                  U5        UR2                  nUb  GM  S n
[5        U5       H  nXl        Un
M     U R7                  U
5      eS n A ff = f7f)N__compile_source__z<string>wFz.py)modedeletesuffixz__inspect_currentframe()eval)co_nameco_linetable)r   co_firstlineno__inspect_currentframe)	Exception__traceback__tb_framef_codeco_filename	f_globalsgettempfileNamedTemporaryFilewritecompilenamereplacer   hasattrr   r   r   f_localsinspectcurrentframer   tb_lasti	tb_linenoappendtb_nextreversedwith_traceback)exctbstackfilenamesourcefframecode
fake_framefake_tbr%   s              U/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torch/utils/_traceback.pyreport_compile_source_on_errorr3   /   s    S* Q* n{{))55H[[**../CDF:%&*<2 00c%PUVZ[GGFO WVV 91666J||ELL,@,@|A5<<88  <<%*\\%>%>',||'B'B ( D "OO..0'2F2F
 (*kk2<< W%R BG nL 5/B JG "   ))cQ*sD   H	 HHA8H	B'	H	'
B5	1D(H	-H		HHbasec                   Uc@  [         R                  R                  [         R                  R                  [        5      5      n [         R                  R	                  X/5      nU [        U5      S-   S $ ! [         a    U s $ f = f)ziShorten a source filepath, with the assumption that torch/ subdirectories don't need to be shown to user.N   )ospathdirname__file__
commonpathlen
ValueError)fnr5   prefixs      r2   shorten_filenamerA      so    |wwrwwx89$##RJ/ #f+/"##  	s    A6 6BBF)r5   linec                    SnU(       a  U R                    S3nU [        U R                  US9 SU R                   SU R                   3$ )z
Format a FrameSummary in a short way, without printing full absolute path or code.

The idea is the result fits on a single line.
 z  # r4   :z in )rB   rA   r+   linenor   )r.   r5   rB   
extra_lines       r2   format_framerH      sQ     J

|4(
\*5>>EFa~UYZ_ZdZdYeff    c                 F    [        [        R                  " U 5      S   5      $ )zJFormat a TracebackType in a short way, printing only the inner-most frame.)rH   	traceback
extract_tbr)   s    r2   format_traceback_shortrO      s    	,,R0455rI   c                   j    \ rS rSrSS/rSS jrS rS rS r\	S	S	SS
.S j5       r
S r\	S 5       rSrg)CapturedTraceback   r)   skipr   c                     Xl         X l        g Nr)   rS   )selfr)   rS   s      r2   __init__CapturedTraceback.__init__   s    	rI   c                     S U l         g rU   rN   rW   s    r2   cleanupCapturedTraceback.cleanup   s	    rI   c                     SS K nU R                  c  [        R                  " 5       $ [	        UR
                  R                  R                  U R                  /5      S   U R                  5      $ )Nr   )	torch._C._profilerr)   rL   StackSummary_extract_symbolized_tb_C	_profilersymbolize_tracebacksrS   )rW   torchs     r2   summaryCapturedTraceback.summary   sT    !77?))++%HH33TWWI>qAII
 	
rI   c                 $    S S U R                   S.4$ )NrV   )rS   r[   s    r2   __getstate__CapturedTraceback.__getstate__   s    II
  	rI   F)scriptcpprS   c                     SSK nU (       d  U(       a  US:X  d   S5       e[        UR                  R                  R	                  SXS9U (       d  U(       a  S5      $ US-   5      $ )a  
Like traceback.extract_stack(), but faster (approximately 20x faster); it
is fast enough that you can unconditionally log stacks this way as part of
normal execution.  It returns a torch._C._profiler.CapturedTraceback
object that must be formatted specially with format_captured_tb.

By default, this only reports Python backtraces (like extract_stack).  You
can set the script/cpp kwargs to also turn on TorchScript/C++ trace
reporting.
r   Nzskip with script/cpp NYIT)pythonrk   rl   r7   )r_   rQ   rb   rc   gather_traceback)rk   rl   rS   re   s       r2   extractCapturedTraceback.extract   sd     	"S198889 HH//tF/T 3A	
 	
 %)1H	
 	
rI   c                 J    [         R                  " U R                  5       5      $ )a<  
Formats a single torch._C._profiler.CapturedTraceback into a list of
strings equivalent to the output of traceback.format_list.  Note that if
pass it CapturedTraceback with C++ traces,  it is better not to use this
function and use the batch formatting API format_captured_tbs to amortize
the cost of symbolization
)rL   format_listrf   r[   s    r2   formatCapturedTraceback.format   s     $$T\\^44rI   c                    SSK n/ n/ n[        U 5       HG  u  pEUR                  c  UR                  / 5        M%  UR                  S5        UR                  U5        MI     UR                  R
                  R                  U Vs/ s H  o@U   R                  PM     sn5        U H+  n[        R                  " X   R                  5       5      X$'   M-     U$ s  snf )zO
Bulk version of CapturedTraceback.format.  Returns a list of list of strings.
r   N)
r_   	enumerater)   r$   rb   rc   rd   rL   rs   rf   )tbsre   rsdelayed_idxsir)   s         r2   
format_allCapturedTraceback.format_all   s    
 	" )+s^EAuu}		"		$##A& $ 	//L0QLqQL0QRA))#&..*:;BE  		 1Rs   C)rS   r)   N)r   )__name__
__module____qualname____firstlineno__	__slots__rX   r\   rf   ri   staticmethodrp   rt   r|   __static_attributes__ rI   r2   rQ   rQ      sS    vI

 U 
 
.5  rI   rQ   c           	          [         R                  " 5       n[        XS 5       H3  nUR                  [         R                  " US   US   US   5      5        M5     U$ )z|
Given a symbolized traceback from symbolize_tracebacks, return a StackSummary object of
pre-processed stack trace entries.
Nr+   rB   r   )rL   r`   r&   r$   FrameSummary)r)   rS   r*   r-   s       r2   ra   ra      sQ    
 ""$Ebi Y++AjM1V9aiPQ !LrI   )typesr   typingr   r   r   rL   
contextlibr    os.pathr8   contextmanagerr3   rA   rH   rO   rQ   ra   r   rI   r2   <module>r      sf     !     N T* T*l "& 
$ !%5 	g6S SlrI   