
    vhQ                       U d dl mZ d dlZd dlmZmZmZmZ d dl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mZmZmZmZmZmZmZ d dlZd dlZd dlmZ d dlmZ d dlmZ d d	lm Z!  ejD                  e#      Z$eZ%eZ& ed
      Z' ed      Z( ed      Z) ed      Z*esedk  r(ed`d       Z+edad       Z+edbd       Z+edcd       Z+d Z+ne!jV                  Z+er(eddd       Z,eded       Z,edfd       Z,edgd       Z,d Z,ne!jX                  Z,er(edhd       Z-edid       Z-edjd       Z-edkd       Z-d Z-ne!jZ                  Z-	 	 dldZ.	 	 dmdZ/dnd Z0dod!Z1dod"Z2dpd#Z3	 	 	 	 	 	 dqd$Z4	 	 	 	 	 	 	 	 drd%Z5	 	 	 	 	 	 	 	 	 	 	 	 dsd&Z6dtd'Z7dud(Z8e8Z9 e:       Z;dvd)Z<d* Z=d+e>d,<    e	e!j~                  d-      Z@	 	 	 	 	 	 dwd.ZAd/ ZBdxd0ZC ej                         aEd1 ZF eCd2      ZG	 	 dy	 dzd3Z ej                         aHd4 ZI G d5 d6      ZJ G d7 d8      ZK G d9 d:      ZLd{d;ZMd|d}d<ZNd~d=ZOdd>ZPdd?ZQdd@ZR	 	 d	 	 	 	 	 	 	 ddAZSdB ZTddCZUddDZVddEZW G dF dG      ZXdH ZY G dI dJ      ZZdK Z[dL Z\ddMZ] G dN dOee'         Z^ G dP dQ      Z_ddRZ`ddSZaddTZbdddUZc G dV dWej                        Ze G dX dYeeZ      ZfdZgd[e>d\<   dd]Zh eie!d^      re!j                  Zjdd_Zky)    )annotationsN)CallableIterableIteratorSequence)partial)AnyGenericSupportsIndexTypeVaroverloadTYPE_CHECKINGcast)config)jaxlib_extension_version)weakref_lru_cache)utilsTT1T2T3ib  c                     y N )__arg1s    H/opt/face_recognition/venv/lib/python3.12/site-packages/jax/_src/util.pysafe_zipr   4   s    9<    c                     y r   r   )r   __arg2s     r   r   r   6   s    SVr   c                     y r   r   )r   r    __arg3s      r   r   r   8   s    mpr   c                     y r   r   )r   r    r"   __arg4argss        r   r   r   :   s	     MPr   c                 D    | st        d      t        t        | ddi      S )af  
    Like builtin :func:`zip`, but with additional safety checks.

    The differences from :func:`zip` are:

    - :func:`safe_zip` checks that at least one argument is provided.
    - :func:`safe_zip` checks that all arguments have the same length.
    - :func:`safe_zip` returns an eagerly-evaluated list instead of a
      lazily-evaluated iterator.
    z&safe_zip requires at least 1 argument.strictT)	TypeErrorlistzip)r%   s    r   r   r   =   s(     >??T'$'((r   c                     y r   r   fr   s     r   safe_mapr.   S   s    GJr   c                     y r   r   r-   r   r    s      r   r.   r.   V   s    adr   c                     y r   r   r-   r   r    r"   s       r   r.   r.   Y   s    {~r   c                     y r   r   r-   r   r    r"   r$   r%   s         r   r.   r.   \   s	     TWr   c           	         t        t        t         |            }t        |d         }|dd  D ]1  }t        |      |k(  rJ dt        t        t        |                     t        t        | g|       S )Nr      zlength mismatch: )r)   maplen)r-   r%   nargs       r   r.   r.   _   sr    D$ DDGAABx GX]F/Sd^0D/EFF]GAr   c                     y r   r   r,   s     r   foreachr<   j   s    EHr   c                     y r   r   r0   s      r   r<   r<   m   s    _br   c                     y r   r   r2   s       r   r<   r<   p   s    y|r   c                     y r   r   r4   s         r   r<   r<   s   s	     RUr   c                    t        | g|  y r   )r.   )r-   r%   s     r   r<   r<   v   s    Qr   c                    g }g }| D ]'  \  }}|j                  |       |j                  |       ) t        |      t        |      fS )z2Unzip sequence of length-2 tuples into two tuples.appendtuple)xysxsysxys        r   unzip2rJ   ~   sL    
 "" daIIaLIIaL 
rE"I	r   c                    g }g }g }| D ]9  \  }}}|j                  |       |j                  |       |j                  |       ; t        |      t        |      t        |      fS )z4Unzip sequence of length-3 tuples into three tuples.rB   )xyzsrF   rG   zsrH   rI   zs          r   unzip3rO      sd    
 """ gaAIIaLIIaLIIaL 
rE"IuRy	((r   c                L    t        |       } |D ]
  \  }}|| |<    t        |       S )z Substitute values within a list.)r)   rD   )lstreplaceivs       r   subvalsrU      s1    S	# daCF	sr   c                    t        |       } g }|D ]  }|j                  | d|        | |d }  |j                  |        |S )0Split list into sublists of the specified sizes.N)r)   rC   r%   nslistsr9   s       r   
split_listr[      sO    	d$
% a	LLbq8D ,,t	,r   c                    t        |       } t        |      t        |       k(  rt        d |D              sJ g }|D ]  }|j	                  | d|        | |d }  |S )rW   c              3  &   K   | ]	  }|d k\    yw)r   Nr   ).0r9   s     r   	<genexpr>z%split_list_checked.<locals>.<genexpr>   s     %9a1f%9s   N)r)   sumr8   allrC   rX   s       r   split_list_checkedrb      sf    	d$	RCI	#%9b%9"99	9
% a	LLbq8D 
,r   c                    t        |       t        |      k(  sJ g g f}t        | |      D ]  \  }}||   j                  |        |S )z*Partition a list into two based on a mask.)r8   r*   rC   )bslrZ   brH   s        r   partition_listrg      sO    	RCF		$&8%"aj da	!HOOA	,r   c                V   t        |       t        |      k(  r#t        |       t        |       z
  t        |      k(  sJ t        |      t        |      }}| D cg c]  }|rt        |      n
t        |       }}t	               }t        ||      t        ||      cxu r|u sJ  J |S c c}w )z0Merge the elements of two lists based on a mask.)r`   r8   iternextobject)rd   l0l1i0i1rf   outsentinels           r   merge_listsrr      s    
 
RCG	B#b' 1SW <<	<8T"Xb"=?@AR483@#@X(	b(	tB1	=X	==	==	=	* As   B&c                    t        |      }| D cg c]  }|||   n
t        |       }}t               }t        ||      |u sJ |S c c}w r   )ri   rj   rk   )subssrcbasebase_rS   rp   rq   s          r   	subs_listrx      sX     t*%;?@a1=Qd5k	1@#@X(	eX	(	**	*	* 	As   Ac                    t        |       t        |      k(  sJ t        |      }t        | |      D cg c]  \  }}|||   n|||   n
t        |        }}}t	               }	t        ||	      |	u sJ |S c c}}w r   )r8   ri   r*   rj   rk   )
subs1subs2src1src2rv   rw   f1f2rp   rq   s
             r   
subs_list2r      s     
Us5z	!!	!
t*%$'u$5	7 R ^bR^b	e
 	7# 	7X(	eX	(	**	*	*		7s   #A6c                j    t        |       } |D cg c]  }| j                  |       }}| rJ |S c c}w r   )dictpop)dctnamesnamerQ   s       r   
split_dictr      s7    S	##()4)#).	* 	*s   0c                R    t        t        j                  j                  |             S )z&Concatenates/flattens a list of lists.)r)   itchainfrom_iterable)rF   s    r   concatenater      s    	bhh$$R(	))r   c           
         t        |       }|D cg c]$  }t        |      D cg c]  }t        |       c}& }}}t        |t              t        u sJ |S c c}w c c}}w )zpSplits `xs` into subsequences of lengths `ns`.

  Unlike `split_list`, the `sum(ns)` must be equal to `len(xs)`.)ri   rangerj   _unflatten_done)rF   rY   xs_iterr9   _unflatteneds         r   	unflattenr      sV     H'<>?qq2A$w-2?+?	g	'?	::	:	 3?s   AAAAc                @     t        |       t        t        |             S )zCurries arguments of f, returning a function on any remaining arguments.

  For example:
  >>> f = lambda x, y, z, w: x * y + z * w
  >>> f(2,3,4,5)
  26
  >>> curry(f)(2)(3, 4, 5)
  26
  >>> curry(f)(2, 3)(4, 5)
  26
  >>> curry(f)(2, 3, 4, 5)()
  26
  )wrapsr   r-   s    r   curryr      s     
q''1%	&&r   z$Callable[[Iterable[Any]], list[Any]]toposortparentsc                    t        t        | |            t        |      D cg c]
  \  }}|s	| }}}t        |      D cg c]
  \  }}|r	| }}}fd}|||fS c c}}w c c}}w )Nc                    g }D ]7  }|r|j                  | d          | dd  } |j                  |d          |dd  }9 |rJ | rJ |S Nr   r6   )rC   )new_lhsnew_rhsrp   ssidess       r   mergezsplit_merge.<locals>.merge  sg    
C 	


71:!"+

71:!"+ ;;Jr   )r)   r7   r*   )	predicaterF   rH   r   lhsrhsr   r   s          @r   split_merger     so     s9b!
"%2u~+tq!+#+2u~/tq!Q/#/ 
c5 	,/s   
A#A#
A)A)c                      y r   r   r   r   r   _ignorer     s    dr   c                      fd}|S )Nc                    t        j                         fd       t        j                          fd       }j                  |_        j                  |_        t
        j                  |j                         |S )Nc                     |i |S r   r   )r   r%   kwargsr-   s      r   cachedz#cache.<locals>.wrap.<locals>.cached#  s    r   c                     t         j                  j                  r | i |S  rt        j                         n	t	               g| i |S r   )r   check_tracer_leaksvaluetrace_contextr   )r%   r   r   r-   trace_context_in_keys     r   wrapperz$cache.<locals>.wrap.<locals>.wrapper'  sQ    		"	"	(	($!&!!.BF((*	 %%#% %r   )	functools	lru_cacher   cache_clear
cache_infocache_clearing_funsadd)r-   r   r   max_sizer   s   ` @r   wrapzcache.<locals>.wrap"  st    "  #  __Q% % !,,G**GG//0Nr   r   )r   r   r   s   `` r   cacher   !  s      
+r   c                 (    t         D ]	  }  |          y r   )r   )clears    r   clear_all_cachesr   6  s    " e	Gr   )r   c                    t        j                  |rt        j                  nt        | |      }t
        j                  |       |S )a	  
  Least recently used cache decorator with weakref support.

  The cache will take a weakref to the first argument of the wrapped function
  and strong refs to all subsequent operations. In all other respects it should
  behave similar to `functools.lru_cache`.
  )_weakref_lru_cacher   r   r   r   _weakref_lru_cachesr   )callmaxsizer   cached_calls       r   r   r   =  s;     #442fw+ +&	r   c                 :    t         D ]  } | j                           y r   )r   r   )r   s    r   clear_all_weakref_lru_cachesr   O  s    ( kr   c                      e Zd ZdgZd Zd Zy)
Unhashablevalc                    || _         y r   r   selfr   s     r   __init__zUnhashable.__init__V  	    DHr   c                4    | j                   |j                   k(  S r   r   r   others     r   __eq__zUnhashable.__eq__Y      88uyy  r   N)__name__
__module____qualname__	__slots__r   r   r   r   r   r   r   S  s    g)!r   r   c                  $    e Zd ZdgZd Zd Zd Zy)Hashabler   c                    || _         y r   r   r   s     r   r   zHashable.__init___  r   r   c                ,    t        | j                        S r   )hashr   r   s    r   __hash__zHashable.__hash__b  s    >r   c                4    | j                   |j                   k(  S r   r   r   s     r   r   zHashable.__eq__e  r   r   Nr   r   r   r   r   r   r   r   r   r   r   r   \  s    g)!r   r   c                  $    e Zd ZdgZd Zd Zd Zy)
WrapKwArgsr   c                    || _         y r   r   r   s     r   r   zWrapKwArgs.__init__k  r   r   c           	     z    t        t        d t        | j                  j	                               D                    S )Nc              3  *   K   | ]  \  }}||f  y wr   r   )r^   krT   s      r   r_   z&WrapKwArgs.__hash__.<locals>.<genexpr>o  s     BAq!fBs   )r   rD   sortedr   itemsr   s    r   r   zWrapKwArgs.__hash__n  s(    B0@)ABBCCr   c                4    | j                   |j                   k(  S r   r   r   s     r   r   zWrapKwArgs.__eq__q  r   r   Nr   r   r   r   r   r   h  s    g)D!r   r   c                    |dz   | z   dz   S )N()r   )r   transform_names     r   	wrap_namer   t  s    	#		$s	**r   c                r    t        | dd       }||S t        | t              rt        | j                        S |S )Nr   )getattr
isinstancer   fun_namefunc)fundefault_namer   s      r   r   r   x  s:    	j$	'$	KWCHHr   c                    t        | dd       }||S t        | t              rt        | j                        S t        |       S )Nr   )r   r   r   fun_qual_namer   r   )r   	qual_names     r   r   r     s?    c>40)W""	#r   c                    t        j                  |       } | | cxk  r|k  sn t        d|  d|       | dk  r| |z   } | S )z?Canonicalize an axis in [-num_dims, num_dims) to [0, num_dims).zaxis z) is out of bounds for array of dimension r   )operatorindex
ValueError)axisnum_dimss     r   canonicalize_axisr     sM    		$
d	%X	%
uTF"KH:V
WW	AX(?D	+r   c                   ||k(  r| S t        |t              r|f}t        |t              r|f}|D cg c]  }t        || j                         }}|D cg c]  }t        || j                         }}t	        t        j                  |             D cg c]	  }||vs| }}t        t        ||            D ]  \  }}|j                  ||        | j                  |      S c c}w c c}w c c}w r   )
r   intr   ndimr   npr   r*   insert	transpose)rH   ru   dstarS   permdr   s           r   moveaxisr    s    CZHS&CS&C/23!	1aff	%3#3/23!	1aff	%3#32771:&	7!3,!	7$	7Sc]# daKK1	
T	 	43	7s   C$C)	C.C.c                    |  |z   S r   r   )rH   rI   s     r   ceil_of_ratior    s    27r   c                      d fd}|S )zs
  Like functools.wraps, but with finer-grained control over the name and docstring
  of the resulting function.
  c                   	 t              }t        dd      xs d}| j                  j                  t        di              t        di       | _        |nj                  |      | _        t        dd      | _        |n j
                  d
||d| _        t        d	| j                        | _	        | _
        | S # t        $ r Y | S w xY w)N__doc__ __dict____annotations__)r   r   z<unknown module>)r   docr   r   )r   r   r  updater  formatr   r   r  r   __wrapped__	Exception)r   r   r  docstrr   namestrwrappeds      r   r   zwraps.<locals>.wrapper  s    gdGY+1rc	ll'':r:;#G->Cc$_T'..T.2Jclw6HIcn"NS'&--DDcDVD 
k .#,,Gcco J  
Js   CC 	CC)r   r   returnr   r   )r  r  r  r   r   s   ```` r   r   r     s      
.r   c                D    t        dt        |       j                         )NzUnhandled case: )AssertionErrortyper   )rH   s    r   assert_unreachabler     s     )$q'*:*:);<==r   c                p    d|cxk  rt        |       k  sn J |t        |       f       | d | |fz   | |d  z   S Nr   r8   tidxr   s      r   tuple_insertr'    sD    	
c	SV	*c3q6]*		
4CC6	AcdG	##r   c                n    d|cxk  rt        |       k  sn J |t        |       f       | d | | |dz   d  z   S r   r#  )r%  r&  s     r   tuple_deleter)    sA    	
c	CF	)S#a&M)		
4C1S1WX;	r   c                v    d|cxk  rt        |       k  sn J |t        |       f       | d | |fz   | |dz   d  z   S r   r#  r$  s      r   tuple_updater+    sH    	
c	CF	)S#a&M)		
4CC6	Ac!efI	%%r   c                  .    e Zd ZdZd Zd Zd Zd Zd Zy)HashableFunctiona
  Decouples function equality and hash from its identity.

  Local lambdas and function defs are reallocated on each function call, making
  the functions created on different calls compare as unequal. This breaks our
  caching logic, which should really only care about comparing the semantics and
  not actual identity.

  This class makes it possible to compare different functions based on their
  semantics. The parts that are taken into account are: the bytecode of the
  wrapped function (which is cached by the CPython interpreter and is stable
  across the invocations of the surrounding function), and `closure` which
  should contain all values in scope that affect the function semantics. In
  particular `closure` should contain all elements of the function closure, or
  it should be possible to derive the relevant elements of the true function
  closure based solely on the contents of the `closure` argument (e.g. in case
  some closed-over values are not hashable, but are entirely determined by
  hashable locals).
  c                     || _         || _        y r   r-   closure)r   r-   r0  s      r   r   zHashableFunction.__init__  s    DFDLr   c                    t        |      t        u xrH | j                  j                  |j                  j                  k(  xr | j                  |j                  k(  S r   )r  r-  r-   __code__r0  r   s     r   r   zHashableFunction.__eq__  sH    K++ *FFOOuww///*LLEMM)+r   c                X    t        | j                  j                  | j                  f      S r   )r   r-   r2  r0  r   s    r   r   zHashableFunction.__hash__  s    $,,/00r   c                &     | j                   |i |S r   r   r   r%   r   s      r   __call__zHashableFunction.__call__  s    4664"6""r   c                P    d| j                   j                   d| j                   dS )Nz
<hashable z with closure=>)r-   r   r0  r   s    r   __repr__zHashableFunction.__repr__  s$    (t||nAFFr   N)	r   r   r   r  r   r   r   r6  r9  r   r   r   r-  r-    s!    &+
1#Gr   r-  c                      fdS )Nc                    t        |       S r   )r-  r/  s    r   <lambda>z&as_hashable_function.<locals>.<lambda>  s    #Aw/ r   r   )r0  s   `r   as_hashable_functionr=    s	    	//r   c                  $    e Zd Zd Zd Zd Zd Zy)HashablePartialc                .    || _         || _        || _        y r   r-   r%   r   )r   r-   r%   r   s       r   r   zHashablePartial.__init__  s    DFDIDKr   c                    t        |      t        u xrc | j                  j                  |j                  j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  S r   )r  r?  r-   r2  r%   r   r   s     r   r   zHashablePartial.__eq__  s`    K?* DFFOOuww///DII#D(,u||(CEr   c                    t        t        | j                  j                         d             }t	        | j
                  j                  | j                  |f      S )Nc                    | d   S r"  r   )kvs    r   r<  z*HashablePartial.__hash__.<locals>.<lambda>  s
    be r   )key)rD   r   r   r   r   r-   r2  r%   )r   r   s     r   r   zHashablePartial.__hash__  s?    6$++++-3CDEF$))V455r   c                \     | j                   g | j                  |i | j                  |S r   rA  r5  s      r   r6  zHashablePartial.__call__
  s-    466=499=t=t{{=f==r   N)r   r   r   r   r   r   r6  r   r   r   r?  r?    s    
E
6>r   r?  c                x    	 t        j                  |       }d}|r ||       S  |      S # t        $ r d}Y w xY w)NFT)r   r   r(   )r   if_posif_namedposnameds        r   maybe_named_axisrM    sG    
..
CE !$1fSk1 
 Es   + 99c                    t         j                  j                  rdg}	 |j                  | d   d    d| d   d           | dd D ]  \  }}|j                  d| d|         	 |j                  d       t
        j                  d	j                  |             yy# t        $ r-}|j                  d       |j                  |        Y d}~hd}~ww xY w)
zFormat and log `pairs` if config.jax_distributed_debug is enabled.

  Args:
    pairs: A sequence of label/value pairs to log. The first pair is treated as
    a heading for subsequent pairs.
  z
DISTRIBUTED_DEBUG_BEGINr   z: r6   Nz  z!DISTRIBUTED_DEBUG logging failed!DISTRIBUTED_DEBUG_END
)r   distributed_debugr   rC   r  loggerwarningjoin)pairslineslabelr   es        r   distributed_debug_logrY    s     ##()ElleAhqk]"U1Xa[M23) ,,%r%5'*+,
 
LL()
NN499U#$ $  ll67llaSs   AB 	C&#CCc                H    t         j                  |       j                         S )zbReturns unique elements from `it` in the order of occurrence.

  The elements must be hashable.
  )r   fromkeyskeys)r   s    r   stable_uniquer]  )  s    
 
r				!!r   c                  P    e Zd ZU ded<   ded<   d ZddZddZddZdd	Zdd
Z	y)
OrderedSetzset[T]elts_setlist[T]	elts_listc                0    t               | _        g | _        y r   )setr`  rb  r   s    r   r   zOrderedSet.__init__5  s    EDMDNr   c                    || j                   vr7| j                   j                  |       | j                  j                  |       y y r   )r`  r   rb  rC   r   elts     r   r   zOrderedSet.add9  s7    
$--
mm
nnC   r   c                4    |D ]  }| j                  |        y r   )r   )r   eltsrX  s      r   r  zOrderedSet.update>  s     
hhqkr   c                ,    t        | j                        S r   )ri   rb  r   s    r   __iter__zOrderedSet.__iter__B  s    r   c                ,    t        | j                        S r   )r8   rb  r   s    r   __len__zOrderedSet.__len__E  s    t~~r   c                    || j                   v S r   )r`  rf  s     r   __contains__zOrderedSet.__contains__H  s    $--r   N)rg  r   r  None)ri  zSeq[T]r  rp  )r  zIterator[T])r  r  )rg  r   r  bool)
r   r   r   r  r   r   r  rk  rm  ro  r   r   r   r_  r_  1  s,    !
  r   r_  c                  4    e Zd ZU ded<   ded<   d Zd Zd Zy)	HashableWrapperr	   rH   z
int | Noner   c                N    || _         t        |      | _        y #  d | _        Y y xY wr   )rH   r   )r   rH   s     r   r   zHashableWrapper.__init__O  s    DF!WDIs    	$c                \    | j                   | j                   S t        | j                        S r   )r   idrH   r   s    r   r   zHashableWrapper.__hash__S  s"    		-499=2dff:=r   c                    t        |t              sy| j                  | j                  |j                  k(  S | j                  |j                  u S )NF)r   rs  r   rH   r   s     r   r   zHashableWrapper.__eq__U  s=    e_- $		 5466UWWL466UWW;LLr   N)r   r   r   r  r   r   r   r   r   r   rs  rs  L  s    &>Mr   rs  c                    t        | t              rt        t        |       j                  S t        | t        j
                        r| j                  S | S r   )r   propertyr   fgetr   cached_propertyr   r   s    r   _original_funcr|  [  s=    8!!!!!Y../66M	
(r   c                     d fd}|S )Nc                    | _         | S r   )r   )r   modules    r   r   zset_module.<locals>.wrapperd  s    doKr   )r   r   r  r   r   )r  r   s   ` r   
set_moduler  c  s     
.r   c                      fd}|S )zEA decorator replacing a Python class with its C++ version at runtime.c                    | S h d}| j                   j                         D ]-  \  }}||vst        t        |      d      r!t	        ||       / | j
                  _        S )N>   r  r  r   _use_cpp)r  r   hasattrr|  setattrr  )clsexclude_methods	attr_nameattrcpp_clss       r   r   zuse_cpp_class.<locals>.wrappern  sg    j;O<<--/ ,	4	/	)~d+Z8
'9d
+,
 kkGONr   r   )r  r   s   ` r   use_cpp_classr  k  s     
.r   c                H     t         t              st        d       fd}|S )zKA decorator excluding methods from the set that are forwarded to C++ class.z``is_enabled`` must be a boolc                0    rt        |       }d|_        | S )NT)r|  r  )r-   original_func
is_enableds     r   	decoratorz!use_cpp_method.<locals>.decorator  s    $Q'm#mHr   )r   rq  r(   )r  r  s   ` r   use_cpp_methodr  ~  s&    	J	%
3
44
 
r   c                  F    e Zd ZdZd Zej                  Zej                  Zy)StrictABCMetaa%  A variant of `abc.ABCMeta` which does not allow virtual subclasses.

  Virtual subclasses support require `abc.ABCMeta` to roundtrip through
  pure Python when doing instance/subclass checking. This if fine for ABCs
  which need virtual subclasses, but is wasteful for the ones which don't.
  c                     ~t        |  d      )Nz$ does not support virtual subclasses)NotImplementedError)r  subclasss     r   registerzStrictABCMeta.register  s    
%IJ
KKr   N)r   r   r   r  r  r  __instancecheck____subclasscheck__r   r   r   r  r    s'    L ,,,,r   r  c                      e Zd ZdZy)	StrictABCr   N)r   r   r   r   r   r   r   r  r    s    )r   r  )	metaclasszCallable | Nonetest_event_listenerc                *    t         sy t        | g|  y r   )r  )r   r%   s     r   
test_eventr    s    	
d"T"r   Mutexc                    d}| dk  ryt        t        j                  t        j                  | d            t	        |      dz
        }| d|z  z  }|d||    dS )N)r  KMGr   r   z0.00Bi  r6   z.2fB)minmathfloorlogr8   )	num_bytesprefixesexponentscaled_values       r   pprint_bytesr    sb    %(!^DHHY56H8IJ(dHn-,hx01	33r   )r   Iterable[T1]r  zlist[tuple[T1]])r   r  r    Iterable[T2]r  zlist[tuple[T1, T2]])r   r  r    r  r"   Iterable[T3]r  zlist[tuple[T1, T2, T3]])
r   Iterable[Any]r    r  r"   r  r$   r  r  zlist[tuple[Any, ...]])r-   zCallable[[T1], T]r   r  r  ra  )r-   zCallable[[T1, T2], T]r   r  r    r  r  ra  )
r-   zCallable[[T1, T2, T3], T]r   r  r    r  r"   r  r  ra  )r-   zCallable[..., T]r   r  r    r  r"   r  r$   r  r  ra  )r-   zCallable[[T1], Any]r   r  r  rp  )r-   zCallable[[T1, T2], Any]r   r  r    r  r  rp  )
r-   zCallable[[T1, T2, T3], Any]r   r  r    r  r"   r  r  rp  )r-   zCallable[..., Any]r   r  r    r  r"   r  r$   r  r  rp  )rE   zIterable[tuple[T1, T2]]r  z%tuple[tuple[T1, ...], tuple[T2, ...]])rL   zIterable[tuple[T1, T2, T3]]r  z5tuple[tuple[T1, ...], tuple[T2, ...], tuple[T3, ...]])rQ   Sequence[T]rR   zIterable[tuple[int, T]]r  tuple[T, ...])r%   r  rY   Sequence[int]r  list[list[T]])rd   Sequence[bool]re   r  r  ztuple[list[T], list[T]])rd   r  rl   Sequence[T1]rm   zSequence[T2]r  zlist[T1 | T2])rt   Sequence[int | None]ru   r  rv   r  r  ra  )rz   r  r{   r  r|   r  r}   r  rv   r  r  ra  )r   zdict[T1, T2]r   r  r  zlist[T2])rF   zIterable[Sequence[T]]r  ra  )rF   Iterable[T]rY   r  r  r  )r   zCallable[[T], bool]rF   r  r  zFtuple[list[T], list[T], Callable[[Sequence[T], Sequence[T]], list[T]]])i   T)i   T)r   r   r   rq  )r   strr   r  r  r  )z<unnamed function>)r   r   r   r  r  r  )r   r   r  r  )r   r   r   r  r  r  )rH   Arrayru   int | Sequence[int]r  r  r  r  )rH   r  rI   r  r  r  )NN)r  r   r  
str | Noner  r  r  Callable[[T], T])r%  r  r&  r  r   r   r  r  )r%  r  r&  r  r  r  )r   r  r  r  )r-   r   r  r   )r  r  r  r  )r  z	type[Any]r  zCallable[[type[T]], type[T]])T)r  rq  r  r  )r   r  r  rp  )r  zint | floatr  r  )l
__future__r   abccollections.abcr   r   r   r   r   r   	itertoolsr   loggingr  r   typingr	   r
   r   r   r   r   r   weakrefnumpyr  jax._srcr   jax._src.libr   r   r   r   jaxlib_utils	getLoggerr   rR  Seqr  r   r   r   r   r   r.   r<   rJ   rO   rU   r[   rb   rg   rr   rx   r   r   r   flattenrk   r   r   r   r  topological_sortr   r   r   r   WeakSetr   r   memoizer   r   r   r   r   r   r   r   r   r  r  r   r   r'  r)  r+  r-  r=  r?  rM  rY  r]  r_  rs  r|  r  r  r  ABCMetar  r  r  r  r  r  r  r   r   r   <module>r     s   # 
 B B       X X X    1 @ .			8	$ 	CLT]T]T] ,s2 < <V Vp p P  P) ""(  J Jd d~ ~ W  W ""(H Hb b| | U  U
   '
	.
)	>)
 
 
 #

%08C

(<


(
0;
 
* ('  / .<00)<" L, & &goo' 
 
.237,0  &goo' ! !
! 
!
! 
!+  
 <>$&$G $GL0> >$2%("   6M M&	-CKK --  (, _ +#
 <!


%4r   