
    JTh"(                         S SK Jr  S SK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)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              N/var/www/auris/envauris/lib/python3.13/site-packages/torch/utils/_traceback.pyreport_compile_source_on_errorr2   /   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)fnr4   prefixs      r1   shorten_filenamer@      so    |wwrwwx89$##RJ/ #f+/"##  	s    A6 6BBF)r4   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  # r3   :z in )rA   r@   r*   linenor   )r-   r4   rA   
extra_lines       r1   format_framerG      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.)rG   	traceback
extract_tbr(   s    r1   format_traceback_shortrN      s    	,,R0455rH   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(   rR   )selfr(   rR   s      r1   __init__CapturedTraceback.__init__   s    	rH   c                     S U l         g rT   rM   rV   s    r1   cleanupCapturedTraceback.cleanup   s	    rH   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(   rK   StackSummary_extract_symbolized_tb_C	_profilersymbolize_tracebacksrR   )rV   torchs     r1   summaryCapturedTraceback.summary   sT    !77?))++%HH33TWWI>qAII
 	
rH   c                 $    S S U R                   S.4$ )NrU   )rR   rZ   s    r1   __getstate__CapturedTraceback.__getstate__   s    II
  	rH   F)scriptcpprR   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)pythonrj   rk   r6   )r^   rP   ra   rb   gather_traceback)rj   rk   rR   rd   s       r1   extractCapturedTraceback.extract   sd     	"S198889 HH//tF/T 3A	
 	
 %)1H	
 	
rH   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
)rK   format_listre   rZ   s    r1   formatCapturedTraceback.format   s     $$T\\^44rH   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#   ra   rb   rc   rK   rr   re   )tbsrd   rsdelayed_idxsir(   s         r1   
format_allCapturedTraceback.format_all   s    
 	" )+s^EAuu}		"		$##A& $ 	//L0QLqQL0QRA))#&..*:;BE  		 1Rs   C)rR   r(   N)r   )__name__
__module____qualname____firstlineno__	__slots__rW   r[   re   rh   staticmethodro   rs   r{   __static_attributes__ rH   r1   rP   rP      sS    vI

 U 
 
.5  rH   rP   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*   rA   r   )rK   r_   r%   r#   FrameSummary)r(   rR   r)   r,   s       r1   r`   r`      sQ    
 ""$Ebi Y++AjM1V9aiPQ !LrH   )typesr   typingr   r   rK   
contextlibr   os.pathr7   contextmanagerr2   r@   rG   rN   rP   r`   r   rH   r1   <module>r      sf          N T* T*l "& 
$ !%5 	g6S SlrH   