
    vhD                       d dl mZ d dlmZ d dlZd dlm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j"                  d	d
d      ZdAdZ e       Zese-	 d dlZ G d dej.                        Z G d de      Z e       Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z e        Z! G d de      Z" ejF                  dg d      Z$ ejF                  d g d!      Z% G d" d#e      Z& ejF                  d$d%d&g      Z'dBd'Z(dCd(Z) G d) d*e
      Z* G d+ d,e
      Z+ G d- d.e
      Z,	 	 dDd/Z-dEd0Z.	 	 	 	 	 	 	 	 	 	 	 	 dFd1Z/dGd2Z0dHdId3Z1dJd4Z2dKdLd5Z3dMd6Z4dNd7Z5dddd8	 	 	 dOd9Z6dPd:Z7nejH                  Z$ejJ                  Z%ej0                  Z	 dQdd;dd<	 	 	 	 	 	 	 	 	 dRd=Z/e/e_8        d> e_9        ej`                  Z0ejb                  Z1ejd                  Z2ejf                  Z3ejh                  Z4ejj                  Z5ejl                  Z6ejn                  Z7 ee6e%jt                  e$jv                  ?      Z< ee6e%jz                  e$j|                  ?      Z?dSd@Z@y# e$ r dZY w xY w)T    )annotations)SequenceN)partial)Any
NamedTupleTYPE_CHECKING)config)util)_pretty_printerjax_pprint_use_colorTz?Enable jaxpr pretty-printing with colorful syntax highlighting.)helpc                    	 t               } | j                  j                  }|dk(  rydt        | j                        v ry	 t        t        j                  d      xr t        j                  j                         S # t        $ r Y Ew xY w)NZMQInteractiveShellTcolabisatty)	get_ipython	__class____name__str	NameErrorhasattrsysstdoutr   )ipythonshells     R/opt/face_recognition/venv/lib/python3.12/site-packages/jax/_src/pretty_printer.py_can_use_colorr   /   s    	mG&&E%%	C))*	* 
+ 
X	&	>3::+<+<+>> 
 		s   %A; A; ;	BBc                  N    e Zd ZdZ	 d	dddd	 	 	 	 	 	 	 	 	 d
dZd ZddZddZy)Doc N # 	use_colorannotation_prefix
source_mapc               V    |t         xr t        j                  }t        | ||||      S )a  
      Formats a pretty-printer document as a string.

      Args:
      source_map: for each line in the output, contains a list of
        (start column, end column, source) tuples. Each tuple associates a
        region of output text with a source.
      r"   CAN_USE_COLOR_PPRINT_USE_COLORvalue_formatselfwidthr#   r$   r%   s        r   formatz
Doc.formatK   s5     
	!=&7&=&=	T5I&7JP P    c                "    | j                         S Nr/   r-   s    r   __str__zDoc.__str__]   s    [[]r0   c                    t        | |g      S r2   )concat)r-   others     r   __add__zDoc.__add__`   s    T5M""r0   c                    t               r2   )NotImplementedErrorr4   s    r   num_annotationszDoc.num_annotationsc   s    !!r0   P   
r.   intr#   zbool | Noner$   r   r%   'list[list[tuple[int, int, Any]]] | Nonereturnr   )r8   r   rB   r   rB   r@   )r   
__module____qualname__	__slots__r/   r5   r9   r<   r    r0   r   r   r   H   sa    I P9=$<@PP+6PP :P 
	P$#"r0   r   c                      e Zd Zd ZddZy)_NilDocc                     y)Nnilr    r4   s    r   __repr__z_NilDoc.__repr__g   s    ur0   c                     yNr   r    r4   s    r   r<   z_NilDoc.num_annotationsi       r0   NrC   )r   rD   rE   rK   r<   r    r0   r   rH   rH   f   s
    $r0   rH   c                  >    e Zd ZU dZded<   ded<   d
ddZd Zdd	Zy)_TextDoc)text
annotationr   rQ   
str | NonerR   Nc                    t        |t              sJ |       |t        |t              sJ |       || _        || _        y r2   )
isinstancer   rQ   rR   )r-   rQ   rR   s      r   __init__z_TextDoc.__init__s   s?    c"(D(":j##>J
J>di"dor0   c                t    | j                   d| j                   d| j                    dS d| j                   dS )Nztext("z", annotation="z"))rR   rQ   r4   s    r   rK   z_TextDoc.__repr__y   s>    		$#4T__4ESII3''r0   c                "    | j                   dS dS )N   r   )rR   r4   s    r   r<   z_TextDoc.num_annotations   s    //-Q414r0   r2   )rQ   r   rR   rS   rC   r   rD   rE   rF   __annotations__rV   rK   r<   r    r0   r   rP   rP   n   s!    &I
I#(5r0   rP   c                  <    e Zd ZU dZded<   ded<   d
dZd ZddZy	)
_ConcatDoc)children_num_annotationsz	list[Doc]r^   r@   r_   c                R    t        |      | _        t        d |D              | _        y )Nc              3  <   K   | ]  }|j                           y wr2   )r<   ).0childs     r   	<genexpr>z&_ConcatDoc.__init__.<locals>.<genexpr>   s     !Pe%"7"7"9!Ps   )listr^   sumr_   )r-   r^   s     r   rV   z_ConcatDoc.__init__   s     8ndm!!Px!PPdr0   c                "    d| j                    dS )Nzconcat())r^   r4   s    r   rK   z_ConcatDoc.__repr__   s    q99r0   c                    | j                   S r2   )r_   r4   s    r   r<   z_ConcatDoc.num_annotations   s    """r0   N)r^   Sequence[Doc]rC   rZ   r    r0   r   r]   r]      s#    0IQ :#r0   r]   c                  2    e Zd ZU dZded<   ddZd Zd	dZy)
	_BreakDocrQ   r   rQ   c                @    t        |t              sJ |       || _        y r2   )rU   r   rQ   )r-   rQ   s     r   rV   z_BreakDoc.__init__   s    c"(D("dir0   c                "    d| j                    dS )Nzbreak(rh   rm   r4   s    r   rK   z_BreakDoc.__repr__   s    		{!44r0   c                     yrM   r    r4   s    r   r<   z_BreakDoc.num_annotations   rN   r0   N)rQ   r   rC   rZ   r    r0   r   rl   rl      s    I
I 5r0   rl   c                  2    e Zd ZU dZded<   ddZd Zd	dZy)
	_GroupDocrc   r   rc   c                @    t        |t              sJ |       || _        y r2   )rU   r   rc   )r-   rc   s     r   rV   z_GroupDoc.__init__   s    s#*U*#djr0   c                "    d| j                    dS )Nzgroup(rh   rs   r4   s    r   rK   z_GroupDoc.__repr__   s    

|155r0   c                6    | j                   j                         S r2   rc   r<   r4   s    r   r<   z_GroupDoc.num_annotations       ZZ''))r0   N)rc   r   rC   rZ   r    r0   r   rr   rr      s    IJ 6*r0   rr   c                  <    e Zd ZU dZded<   ded<   d
dZd ZddZy	)_NestDocnrc   r@   r|   r   rc   c                N    t        |t              sJ |       || _        || _        y r2   )rU   r   r|   rc   )r-   r|   rc   s      r   rV   z_NestDoc.__init__   s%    s#*U*#dfdjr0   c                :    d| j                   | j                  f dS )Nznest(rh   r{   r4   s    r   rK   z_NestDoc.__repr__   s    tvvtzz'9&:!<<r0   c                6    | j                   j                         S r2   rw   r4   s    r   r<   z_NestDoc.num_annotations   rx   r0   N)r|   r@   rc   r   rC   rZ   r    r0   r   rz   rz      s     I
FJ
 =*r0   rz   c                  <    e Zd ZU dZded<   ded<   d
dZd ZddZy	)_SourceMapDocrc   sourcer   rc   r   r   c                N    t        |t              sJ |       || _        || _        y r2   )rU   r   rc   r   )r-   rc   r   s      r   rV   z_SourceMapDoc.__init__   s%    s#*U*#djdkr0   c                <    d| j                    d| j                   dS )Nzsource(z, rh   r   r4   s    r   rK   z_SourceMapDoc.__repr__   s    Bt{{m1EEr0   c                6    | j                   j                         S r2   rw   r4   s    r   r<   z_SourceMapDoc.num_annotations   s    zz))++r0   N)rc   r   r   r   rC   rZ   r    r0   r   r   r      s!    #IJK
 F,r0   r   Color)	BLACKREDGREENYELLOWBLUEMAGENTACYANWHITERESET	Intensity)DIMNORMALBRIGHTc                  Z    e Zd ZU dZded<   ded<   ded<   ded<   d	d	d	d
	 	 	 ddZddZy	)	_ColorDoc)
foreground
background	intensityrc   Color | Noner   r   Intensity | Noner   r   rc   Nr   r   r   c               j    t        |t              sJ |       || _        || _        || _        || _        y r2   )rU   r   rc   r   r   r   )r-   rc   r   r   r   s        r   rV   z_ColorDoc.__init__   s5     s#*U*#dj"do"do dnr0   c                6    | j                   j                         S r2   rw   r4   s    r   r<   z_ColorDoc.num_annotations   rx   r0   )rc   r   r   r   r   r   r   r   rC   )r   rD   rE   rF   r[   rV   r<   r    r0   r   r   r      sA    BIJAE+/.2!(!+!*r0   r   
_BreakModeFLATBREAKc                F   | g}|dk\  rt        |      dkD  r|j                         } t        | t              rnt        | t              r|t        | j
                        z  }nt        | t              r%|j                  t        | j                               nqt        | t              r|t        | j
                        z  }nHt        | t        t        t        t        f      r|j                  | j                          nt#        d|       |dk\  rt        |      dkD  r|dk\  S )Nr   Invalid document )lenpoprU   rH   rP   rQ   r]   extendreversedr^   rl   rz   rr   r   r   appendrc   
ValueError)docr.   agendas      r   _fitsr      s    UF
1*VqJJLc	C	!c8$SXXc:&hs||,-c9%SXXcHiMJKcii ,c22 1*Vq A:r0   c                   | g}| j                         dk(  ryd}d}t        |      dkD  rD|j                         } t        | t              rnt        | t
              r| j                  |dk\  r|ry|dz  }nt        | t              r%|j                  t        | j                               nt        | t              rd}nt        | t              r|j                  | j                         ntt        | t              r|j                  | j                         nHt        | t               st        | t"              r|j                  | j                         nt%        d|       t        |      dkD  rDy)Nr   TFrY   r   )r<   r   r   rU   rH   rP   rR   r]   r   r   r^   rl   rz   r   rc   rr   r   r   r   )r   r   r<   
seen_breaks       r   _sparser      s   UF
!OJ
f+/JJLc	C	!c8$>>%!j
Q
/c:&hs||,-c9%
c8$cii c9%cii c9%C)Gcii ,c22) f+/, r0   c                  ,    e Zd ZU ded<   ded<   ded<   y)_ColorStater   r   r   r   r   Nr   rD   rE   r[   r    r0   r   r   r     s    r0   r   c                  @    e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   y)_Stater@   indentr   moder   r   r   colorr   r%   Nr   r    r0   r   r   r   !  s    K
	HOr0   r   c                  ,    e Zd ZU ded<   ded<   ded<   y)_Liner   rQ   r@   r.   	list[str]r   Nr   r    r0   r   r   r   (  s    
IJr0   r   c                R   | rt         |dfS d}|j                  |j                  k7  r:|t        t         j                  t	        |j                  j
                              z  }|j                  |j                  k7  r:|t        t         j                  t	        |j                  j
                              z  }|j                  |j                  k7  rW|t         j                  j                  z  }|t        t         j                  t	        |j                  j
                              z  }||fS )N )coloramar   getattrForer   namer   Backr   Styler   )r#   stateupdate	color_strs       r   _update_colorr   .  s    (RZI6,,,78==#f.?.?.D.D*EFFi6,,,78==#f.?.?.D.D*EFFi&***8>>(((i78>>3v/?/?/D/D+EFFi9r0   c                   t        d | D              }g }| D ]  }t        |j                        dk(  r|j                  |j                         7|j                  |j                   d||j
                  z
  z   | |j                  d           |j                  dd  D ]  }|j                  d|z   | |          |S )Nc              3  4   K   | ]  }|j                     y wr2   )r.   )rb   ls     r   rd   z%_align_annotations.<locals>.<genexpr>@  s     (Q(s   r    rY   )maxr   r   r   rQ   r.   )linesr$   maxlenoutr   as         r   _align_annotationsr   =  s     (%((F
C >	Q]]	q	 

166

affXcVagg%567&'a(8'9; 	<qr" 	>A
**f~&7%8<
=	>> Jr0   c          	     f
   g }t        t        j                  t        j                  t        j                        }t        t        j                  t        j                  t        j
                        }|}d}	t        g }
t        dt        j                  | |      g}d}d}g }t        |      dkD  r|j                         \  } }|5|k7  r0t        |      }|	|k7  rt        ur|
j                  |	|f       ||}	t        | t              rnbt        | t              ret!        ||      \  }}||z  }|| j"                  z  }| j$                  |j                  | j$                         |t        | j"                        z  }nt        | t&              r2|j)                  fdt+        | j,                        D               nt        | t.              rމt        j                  k(  rt        |      dkD  rt!        |||      \  }}||z  }|j                  t1        |||             |At        |      }|	|k7  rt        ur|
j                  |	|f       |j                  |
       g }
}	dz  }g }}nt!        ||      \  }}||z  }|| j"                  z  }|t        | j"                        z  }nt        | t2              r7|j                  t        | j4                  z   | j6                               nvt        | t8              rt;        | ||z
        rCt=        |       r8|j                  t        t        j>                  | j6                               n|j                  t        t        j                  | j6                               nt        | t@              r~t        | jB                  xs jB                  | jD                  xs jD                  | jF                  xs jF                        |j                  t        | j6                               nOt        | tH              r3|j                  t        | j6                  | jJ                               ntM        d|       t        |      dkD  rt        |      dkD  rt!        |||      \  }}||z  }|=t        |      }|	|k7  rt        ur|
j                  |	|f       |j                  |
       |j                  t1        |||             djO                  tQ        ||            }t!        |||      \  }}||z   S )Nr   r   c              3  <   K   | ]  }t        |        y wr2   )r   )rb   dr   imr   s     r   rd   z_format.<locals>.<genexpr>o  s&      7 Q1eV4 7s   r   r   
))r   r   r   r   r   r   
_NO_SOURCEr   r   r   r   r   r   rU   rH   rP   r   rQ   rR   r]   r   r   r^   rl   r   rz   r|   rc   rr   r   r   r   r   r   r   r   r   r   r   joinr   )r   r.   r#   r$   r%   r   default_colorsannotation_colorscolor_statesource_startline_source_mapr   k	line_textline_annotationsagenda_sourceposr   r   _r   r   r   r   s                       @@@@r   r+   r+   N  sx    E ekk9;K;KLN#EKKimmL KLFOQ
((#~vFGF	AI
f+/(.

%aC		MV$;)n36#;

 
 ,V!<
=	C	!c8$!.y+u!MYY	SXX	>>%

!
!#..
1	S]c:& 7'57 	7c9%
   !"Q&%29k2C&E"K"I
,,uY+;<
=#i.Cs"vZ'?$$lC%@Ao. OLAg)
!#0K#O
 +y
y
 )
sxx
)
s388}
!c8$fQY399eVDEc9% #uqy!gcl
--q*//399eVL
M
--q*"2"2CIIufM
Nc9%CNN>e.>.>NN>e.>.>MM<U__> 	fQ399eV<=c=)fQ399eSZZ@A,c22w f+/z q ,Y,= ?k99i	Nc		z!9c6:;(	LLy!%567
))&u.?@
AC K*8:LAy?r0   c                     t         S )zAn empty document.)_nilr    r0   r   rJ   rJ     s    Kr0   c                    t        | |      S )zLiteral text.)rP   )srR   s     r   rQ   rQ     s    Az""r0   c                T    t        |       } t        |       dk(  r| d   S t        |       S )zConcatenation of documents.rY   r   )re   r   r]   )docss    r   r7   r7     s*    :D
4yA~!Wndr0   c                    t        |       S )z]A break.

    Prints either as a newline or as `text`, depending on the enclosing group.
    )rl   rm   s    r   brkr     s    
 T?r0   c                    t        |       S )zLayout alternative groups.

    Prints the group with its breaks as their text (typically spaces) if the
    entire group would fit on the line when printed that way. Otherwise, breaks
    inside the group as printed as newlines.
    )rr   )r   s    r   groupr     s     S>r0   c                    t        | |      S )z'Increases the indentation level by `n`.)rz   )r|   r   s     r   nestr     s    Asr0   r   c                    t        | |||      S )zANSI colors.

    Overrides the foreground/background/intensity of the text for the child doc.
    Requires use_colors=True to be set when printing and the `colorama` package
    to be installed; otherwise does nothing.
    r   )r   )r   r   r   r   s       r   r   r     s     SZJ') )r0   c                    t        | |      S )a{  Source mapping.

    A source map associates a region of the pretty-printer's text output with a
    source location that produced it. For the purposes of the pretty printer a
    ``source`` may be any object: we require only that we can compare sources for
    equality. A text region to source object mapping can be populated as a side
    output of the ``format`` method.
    )r   )r   r   s     r   r%   r%     s     f%%r0   r!   r"   c               `    |t         xr t        j                  }| j                  ||||      S )z
    Formats a pretty-printer document as a string.

    Args:
    source_map: for each line in the output, contains a list of
      (start column, end column, source) tuples. Each tuple associates a
      region of output text with a source.
    r"   r'   r,   s        r   r+   r+     s<     ;$5$;$;i<<6G   r0   c                "    | j                         S r2   r3   r4   s    r   <lambda>r     s    T[[] r0   )r   r   c                    t        |      }t        |      dk(  r
t               S t        |      dk(  r|d   S |d   g}|dd D ]$  }|j                  |        |j                  |       & t	        |      S )z(Concatenates `docs`, separated by `sep`.r   rY   N)re   r   rJ   r   r7   )sepr   xsr   s       r   r   r     ss    	d$Y!^5LY!^7NQy"!"X cIIcNIIcN 
r0   )rB   bool)r   r   r.   r@   rB   r   )r   r   rB   r   )r#   r   r   r   r   r   rB   ztuple[_ColorState, str])r   zlist[_Line]r$   r   rB   r   )r   r   r.   r@   r#   r   r$   r   r%   rA   rB   r   )rB   r   r2   )r   r   rR   rS   rB   r   )r   rj   rB   r   )r   )rQ   r   rB   r   )r   r   rB   r   )r|   r@   r   r   rB   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r=   r?   )r   r   r   rj   rB   r   )A
__future__r   collections.abcr   enum	functoolsr   r   typingr   r   r   jax._srcr	   r
   jax._src.libr   
bool_stater)   r   r(   r   ImportError	StrictABCr   rH   r   rP   r]   rl   rr   rz   objectr   r   Enumr   r   r   r   r   r   r   r   r   r   r   r+   rJ   rQ   r7   r   r   r   r   r%   r/   r5   r   r   type_annotationr   r   keywordr   r    r0   r   <module>r     s  8 # $   
 1 1   ; &F%%	J ?    O+"DNN "<  
$5 5(#3 ## *# ** * x*,c , $))G C D%dii%@A)*# *& tyy'89*,<J 
z j ."Y	YY(,YADY7Y Y@#
 59'+*.
)$
)'
)	& 

%'')#7;":>)4 8 	$ #**#+#			$!!&#


%			$


%))* %9+;+;%*]]4
%9#3#3


KY 
 Hs   I3 3I>=I>