
    Vpf#                       U d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dlZd dl	m
Z
mZmZ d dlmZ d dlmZ d dlmZ  eded	e
f         
          Zeej        gZded<   d0dZdZd1dZd2dZd2dZd3dZd4dZd5dZd6d Zd7d#Zd8d$Z  G d% d&e!          Z"d'Z# G d( d)e!          Z$d*e$_%        d9d+Z&d9d,Z'd:d-Z(d;d/Z)dS )<    )annotations)CallableN)AnyTypeVarcast)config)util)xla_extensionC.)boundz	list[str]_exclude_pathspathstrc                :    t                               |            d S N)r   append)r   s    W/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/traceback_util.pyregister_exclusionr   "   s        zThe stack trace below excludes JAX-internal frames.
The preceding is the original exception that occurred, unmodified.

--------------------path_prefixreturnboolc                V   t           j                            |           } t           j                            |          }	 t           j                            | |g          }n# t          $ r Y dS w xY w	 ||k    pt           j                            ||          S # t          $ r Y dS w xY w)NF)osr   abspath
commonpath
ValueErrorsamefileOSError)r   r   commons      r   _path_starts_withr!   *   s    			$,,+W{ 344FF	    55	
[ IBG$4$4V[$I$II	   55s$    !A" "
A0/A04%B 
B('B(ftypes.FrameTypec                F     t           fdt          D                        S )Nc              3  L   K   | ]}t          j        j        |          V  d S r   )r!   f_codeco_filename).0r   r"   s     r   	<genexpr>z include_frame.<locals>.<genexpr>;   sF       - - #18#7>> - - - - - -r   )anyr   r"   s   `r   include_framer,   :   s@     - - - -+- - - - - 
- -r   c                    d| j         j        v S )Nzimportlib._bootstrap)r&   r'   r+   s    r   _ignore_known_hidden_framer.   A   s    	18#7	77r   tbtypes.TracebackTypec                l    t          j        |           D ]\  }}t          |          s
d|j        d<   d S )NT__tracebackhide__)	tracebackwalk_tbr,   f_locals)r/   r"   _linenos      r   #_add_tracebackhide_to_hidden_framesr7   D   sH    %b)) - -ja -(,aj$%- -r   types.TracebackType | Nonec                    d }t          t          j        |                     }t          |          D ]0\  }}t	          |          rt          j        |||j        |          }1|S r   )listr3   r4   reversedr,   typesTracebackTypef_lasti)r/   outframesr"   linenos        r   filter_tracebackrB   I   sh    #	!"%%&&&F## ; ;iaQ ;Q	6::c	*r   c                   | }d}t          j        | j                  D ]f\  }}t          |          r|r|j        j        dk    r n>t          |          rt          j        |||j	        |          }|j        j        dk    rd}g|S )NFz<module>T)
r3   
walk_stacktb_framer.   r&   co_namer,   r<   r=   r>   )r/   r?   reached_module_levelr"   rA   s        r   _add_call_stack_framesrH   R   s     	#'44 " "ia!!$$   0J > >eQ ;Q	6::cx:%%!	*r   traceback.FrameSummaryc                8    | j         t          k    o
| j        dk    S )Nreraise_with_filtered_traceback)filename__file__namer+   s    r   _is_reraiser_framerO   j   s!    
*
  6
&5
57r   eBaseExceptionc                    | j         dS t          j        | j         j                  }t	          d |d d         D                       S )NFc              3  4   K   | ]}t          |          V  d S r   )rO   )r(   r"   s     r   r)   z%_is_under_reraiser.<locals>.<genexpr>r   s+      44q""444444r   )__traceback__r3   extract_stackrE   r*   )rP   r/   s     r   _is_under_reraiserrW   n   sI    _5q788"	44BssG444	4	44r   c                    d                     t          j        t          |           |                                                     S )N )joinr3   format_exception_onlytypestrip)rP   s    r   r[   r[   t   s3    	0a!<<	=	=	C	C	E	EEr   c                      e Zd ZdS )UnfilteredStackTraceN)__name__
__module____qualname__ r   r   r_   r_   w   s          r   r_   zFor simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.c                      e Zd Zd ZdS )SimplifiedTracebackc                    t           S r   )_simplified_tb_msg)selfs    r   __str__zSimplifiedTraceback.__str__~   s    r   N)r`   ra   rb   ri   rc   r   r   re   re   }   s#            r   re   z
jax.errorsc                 F    	 t                       dS # t          $ r Y dS w xY w)z6Returns true if we appear to be in an IPython session.TF)get_ipython	NameErrorrc   r   r   _running_under_ipythonrm      s7    MMM4	   55s    
  c                 0    ddl } | j        dd         dk    S )z?Returns true if the IPython version supports __tracebackhide__.r   N   )      )IPythonversion_info)rr   s    r   _ipython_supports_tracebackhidert      s"    ...		bqb	!W	,,r   c                 z    t           j        j        } | | dk    r!t                      rt	                      rd} nd} | S )Nautotracebackhidequiet_remove_frames)r   traceback_filteringvaluerm   rt   )modes    r   _filtering_moder|      sG    		#	)$	\TV^^   #%D%F%F #dd"d	+r   func                l     t          j                    fd            }t          t          |          S )a  Wraps ``fun`` to form a boundary for filtering exception tracebacks.

  When an exception occurs below ``fun``, this appends to it a custom
  ``__cause__`` that carries a filtered traceback. The traceback imitates the
  stack trace of the original exception, but with JAX-internal frames removed.

  This boundary annotation works in composition with itself. The topmost frame
  corresponding to an :func:`~api_boundary` is the one below which stack traces
  are filtered. In other words, if ``api_boundary(f)`` calls
  ``api_boundary(g)``, directly or indirectly, the filtered stack trace provided
  is the same as if ``api_boundary(f)`` were to simply call ``g`` instead.

  This annotation is primarily useful in wrapping functions output by JAX's
  transformations. For example, consider ``g = jax.jit(f)``. When ``g`` is
  called, JAX's JIT compilation machinery is invoked, which in turn calls ``f``
  in order to trace and translate it. If the function ``f`` raises an exception,
  the stack unwinds through JAX's JIT internals up to the original call site of
  ``g``. Because the function returned by :func:`~jax.jit` is annotated as an
  :func:`~api_boundary`, such an exception is accompanied by an additional
  traceback that excludes the frames specific to JAX's implementation.
  c                 F   d}	  
| i |S # t           $ r}t                      }t          |          s|dk    r |dk    rt          |j                    d\  }}	 |j        }t          |          }|                    |           t          t          d          rt          j	        |           t          j        dk    r$|dk    r|                    dt          z              n|dk    rt                      }nf|d	k    rMt          |          }	|	 d
t            }	t#          |	          }|                    t%          |                     nt'          d| d          |j        |_        |j        |_        |j        |_        ||_        d |_         # ~~~w xY wd }~ww xY w)NToffrw   )NNreplace_thread_exc_traceback)      rx   z--------------------
remove_framesz

zJAX_TRACEBACK_FILTERING=z is not a valid value.)	Exceptionr|   rW   r7   rU   rB   with_tracebackhasattrr
   r   sysrs   add_noterg   re   r[   _jax_message_appendr_   rH   r   	__cause____context____suppress_context__)argskwargsr2   rP   r{   filtered_tb
unfilteredr/   	jax_errormsgr}   s             r   rK   z5api_boundary.<locals>.reraise_with_filtered_traceback   s   1S$!&!!! / / /d	A		 $%--		 	 +AO<<< *k:&_&r**	%%% ="@AA 	B 
4[
A
A
Aw&&43H+H+H
**-0BB
C
C
C
C*** ,--II&&'**C33133C,S11I$$%;B%?%?@@@@TTTTUUU !)
"#-)
+,+A)
(!!+!-_/s(    F AFD6FFFF )	functoolswrapsr   r   )r}   rK   s   ` r   api_boundaryr      sG    . ?33 3 3 3 3h 
a0	1	11r   )r   r   )r   r   r   r   r   r   )r"   r#   r   r   )r/   r0   )r/   r0   r   r8   )r/   r0   r   r0   )r"   rI   r   r   )rP   rQ   r   r   )rP   rQ   r   r   )r   r   )r   r   )r}   r   r   r   )*
__future__r   collections.abcr   r   r   r   r3   r<   typingr   r   r   jax._srcr   r	   jax._src.libr
   r   rM   r   __annotations__r   r   r!   r,   r.   r7   rB   rH   rO   rW   r[   r   r_   rg   re   ra   rm   rt   r|   r   rc   r   r   <module>r      s|   # " " " " " " $ $ $ $ $ $     				 



      % % % % % % % % % %             & & & & & & GCxS)***%t}5 5 5 5 5    
    - - - -8 8 8 8- - - -
      07 7 7 75 5 5 5F F F F , + + + +9 + + +F     )    ".     - - - -
   L2 L2 L2 L2 L2 L2r   