
    uki]                    $   d Z ddlmZ dgZddlZddlmZ ddlZddlm	Z	 ddl
mZm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 ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8m9Z9 e9e:cZ:Z;e8e<cZ<Z=	 	 ddd	 	 	 	 	 dd Z>	 	 ddd	 	 	 	 	 dd!Z?	 	 d	 	 	 dd"Z@	 	 d	 	 	 dd#ZAddd$ZBdddd%dd&	 	 	 	 	 dd'ZC	 	 d	 	 	 dd)ZDddd*ZEddd-ZF	 ddddd.	 	 	 	 	 	 	 	 	 dd/ZGdd0ZHdd1ZIdd2ZJ	 	 d	 	 	 dd3ZK	 	 d	 	 	 dd4ZLddd5ZMddd6	 	 	 dd7ZNddd9dd:ZOdd;ZPdd<ZQdd=ZRdd>ZS	 	 	 d	 	 	 	 	 	 	 dd?ZT	 	 ddd	 	 	 	 	 	 	 dd@ZU	 	 	 d	 	 	 	 	 	 	 ddAZVddBZWdddC	 	 	 ddDZX	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddEZY	 	 d	 	 	 ddFZZddGZ[ddddH	 	 	 	 	 ddIZ\d8ddJ	 ddKZ]dddLZ^	 	 ddMdN	 	 	 	 	 ddOZ_dddd%dd&	 	 	 	 	 	 	 ddPZ`dddQZa	 	 ddddR	 	 	 	 	 	 	 	 	 	 	 ddSZb	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddTZcddUZd	 	 	 d 	 	 	 	 	 	 	 	 	 ddVZeddW	 ddXZf	 	 d	 	 	 	 	 ddYZgddZZhdd[Zi	 	 ddddR	 	 	 	 	 	 	 	 	 	 	 dd\Zjdd]Zkddd^Zld_ Zmeneoepej                  ej                  e1ej                  fZteuevewexfZydd`Zzda Z{dd	dbZ|d
dcZ}ej                  efZeej                  fz   Zdd Z ej                  def      	 	 	 	 	 	 	 	 ddg       Zej                  ddh       Zdi Zdj Z G dk dl      Z G dm dn      Zi doedpe{d(eJdqe}drds dtdu dv ezdwe&j                        dx ezdye&j                        dz ezd{e&j                        d| ezd}e&j                        d~ ezde&j                        d ezde&j                        dd d ezde&j                        d ezde&j                  d%      d ezde&j                         d ezde&j                   d%      i d ezde&j"                        d ezde&j"                  d%      d ezde&j$                        d ezde&j$                  d%      d ezde&j&                        d ezde&j&                  d%      d ezde&j(                        d ezde&j(                  d%      d ezde&j*                        d ezde&j*                  d%      d ezde&j,                        d ezde&j,                  d%      d ezde$j.                        d ezde$j.                  d%      d ezde&j0                        d ezde&j0                  d%      d ezde&j2                         ezde&j2                  d%       ezde&j4                         ezde&j4                  d%      d  ezde&j6                         ezde&j8                         ezde&j6                  d%       ezde&j8                  d%      e|d	Zi de j<                  de>de?de@deAdeBdeCdeDdeEdeFdeGdeHdeId(eJdeKdeLdeMi deNdeOdeQd,eTdeUd+eVdeXdeYdeZdeOde\de]de^de_de`deadebecedeeefegehejele#j>                  edȜ
ZeedɜZemeieSe[ePeWeRedʜZd˄ Zd̄ Zd̈́ Zd΄ ZddτZddЄZdф Zd҄ Zdӄ ZdԄ Zy(  zDefine methods which are dynamically added to JAX's Arrays and Tracers.

This is done dynamically in order to avoid circular imports.
    )annotationsregister_jax_array_methodsN)wraps)Any)CallableSequence)api)core)dtypes)literals)_ensure_index_tuple)	ArrayImpl)lax)slicing)
xla_client)array_api_metadata)array_creation)indexing)	lax_numpy)tensor_contractions)
reductions)ufuncs)PartitionSpec)Sharding)canonicalize_shardingNamedSharding)scatter)Array	ArrayLikeDimSize	DTypeLikeShapeStaticScalar)safe_zipsafe_mapF)wherec               6    t        j                  | ||||      S )zTest whether all array elements along a given axis evaluate to True.

  Refer to :func:`jax.numpy.all` for the full documentation.
  axisoutkeepdimsr&   )r   allselfr)   r*   r+   r&   s        W/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/numpy/array_methods.py_allr0   D        
4S85	QQ    c               6    t        j                  | ||||      S )zTest whether any array elements along a given axis evaluate to True.

  Refer to :func:`jax.numpy.any` for the full documentation.
  r(   )r   anyr-   s        r/   _anyr5   L   r1   r2   c                4    t        j                  | |||      S )zjReturn the index of the maximum value.

  Refer to :func:`jax.numpy.argmax` for the full documentation.
  r)   r*   r+   )r   argmaxr.   r)   r*   r+   s       r/   _argmaxr:   T        
		$TsX	FFr2   c                4    t        j                  | |||      S )zjReturn the index of the minimum value.

  Refer to :func:`jax.numpy.argmin` for the full documentation.
  r7   )r   argminr9   s       r/   _argminr>   \   r;   r2   c                2    t        j                  | ||      S )z{Return the indices that partially sort the array.

  Refer to :func:`jax.numpy.argpartition` for the full documentation.
  )kthr)   )r   argpartition)r.   r@   r)   s      r/   _argpartitionrB   d   s    
 
		#D	99r2   T)kindorderstable
descendingc               8    t        j                  | |||||      S )zlReturn the indices that sort the array.

  Refer to :func:`jax.numpy.argsort` for the full documentation.
  r)   rC   rD   rE   rF   )r   argsortr.   r)   rC   rD   rE   rF   s         r/   _argsortrK   k   s&     
		4dU"(Z
A Ar2   copyc                4    t        j                  | |||      S )a3  Copy the array and cast to a specified dtype.

  This is implemented via :func:`jax.lax.convert_element_type`, which may
  have slightly different behavior than :meth:`numpy.ndarray.astype` in
  some cases. In particular, the details of float-to-int and int-to-float
  casts are implementation dependent.
  )rL   device)r   astype)r.   dtyperL   rN   s       r/   _astyperQ   t   s     
		$D	@@r2   c                4    t        j                  | |||      S )zConstruct an array choosing from elements of multiple arrays.

  Refer to :func:`jax.numpy.choose` for the full documentation.
  )choicesr*   mode)r   choose)r.   rS   r*   rT   s       r/   _chooserV      s    
 
		$St	DDr2   minmaxc                2    t        j                  | ||      S )z|Return an array whose values are limited to a specified range.

  Refer to :func:`jax.numpy.clip` for full documentation.
  )rW   rX   )r   clip)r.   rW   rX   s      r/   _clipr[      s    
 
#3	//r2   )r*   size
fill_valuec               8    t        j                  || ||||      S )zxReturn selected slices of this array along given axis.

  Refer to :func:`jax.numpy.compress` for full documentation.
  )r)   r*   r\   r]   )r   compress)r.   	conditionr)   r*   r\   r]   s         r/   	_compressra      s$     
		It$C!%*
> >r2   c                ,    t        j                  |       S )zlReturn the complex conjugate of the array.

  Refer to :func:`jax.numpy.conj` for the full documentation.
  )r   conjr.   s    r/   _conjre      s    
 
T	r2   c                ,    t        j                  |       S )zqReturn the complex conjugate of the array.

  Refer to :func:`jax.numpy.conjugate` for the full documentation.
  )r   	conjugaterd   s    r/   
_conjugaterh      s    
 
		$	r2   c                ,    t        j                  |       S )z]Return a copy of the array.

  Refer to :func:`jax.numpy.copy` for the full documentation.
  )r   rL   rd   s    r/   _copyrj      s    
 
	r2   c                4    t        j                  | |||      S )zpReturn the cumulative product of the array.

  Refer to :func:`jax.numpy.cumprod` for the full documentation.
  r)   rP   r*   )r   cumprodr.   r)   rP   r*   s       r/   _cumprodro      s     
		Dt5c	BBr2   c                4    t        j                  | |||      S )zkReturn the cumulative sum of the array.

  Refer to :func:`jax.numpy.cumsum` for the full documentation.
  rl   )r   cumsumrn   s       r/   _cumsumrr      s     
		4d%S	AAr2   c                4    t        j                  | |||      S )zsReturn the specified diagonal from the array.

  Refer to :func:`jax.numpy.diagonal` for the full documentation.
  )offsetaxis1axis2)r   diagonal)r.   rt   ru   rv   s       r/   	_diagonalrx      s    
 
		DuE	JJr2   	precisionpreferred_element_typec               4    t        j                  | |||      S )zgCompute the dot product of two arrays.

  Refer to :func:`jax.numpy.dot` for the full documentation.
  ry   )r   dot)r.   brz   r{   s       r/   _dotr      s     
	 	 qIVl	mmr2   Cout_shardingc               2    t        j                  | ||      S )zlFlatten array into a 1-dimensional shape.

  Refer to :func:`jax.numpy.ravel` for the full documentation.
  rD   r   )r   ravel)r.   rD   r   s      r/   _flattenr      s    
 
U	FFr2   c                ,    t        j                  |       S )z'Return the imaginary part of the array.)r   imagrd   s    r/   _imag_propertyr          	T	r2   c                    t        j                  t        j                  | d      }t	        j
                  | j                  t        j                        rt        d|j                         |j                  | S )zFCopy an element of an array to a standard Python scalar and return it.z/This occurred in the item() method of jax.Array)contextz$No Python scalar type for arr.dtype=)
r
   concrete_or_errornpasarrayr   
issubdtyperP   extended	TypeErroritem)r.   argsarrs      r/   _itemr      sZ    rzz49jk#tzz6??3
;=
>>	4r2   c                .    | j                   j                  S )z%Length of one array element in bytes.)rP   itemsizerd   s    r/   _itemsize_propertyr      s    			r2   c                ,    t        j                  |       S )zfCompute the (batched) matrix transpose.

  Refer to :func:`jax.numpy.matrix_transpose` for details.
  )r   matrix_transposerd   s    r/   _matrix_transpose_propertyr      s    
 
	#	#D	))r2   c                8    t        j                  | |||||      S )zyReturn the maximum of array elements along a given axis.

  Refer to :func:`jax.numpy.max` for the full documentation.
  r)   r*   r+   initialr&   )r   rX   r.   r)   r*   r+   r   r&   s         r/   _maxr      "     
4S8 'u
6 6r2   c               8    t        j                  | |||||      S )zwReturn the mean of array elements along a given axis.

  Refer to :func:`jax.numpy.mean` for the full documentation.
  )r)   rP   r*   r+   r&   )r   mean)r.   r)   rP   r*   r+   r&   s         r/   _meanr      s"     
D3"*%
9 9r2   c                8    t        j                  | |||||      S )zyReturn the minimum of array elements along a given axis.

  Refer to :func:`jax.numpy.min` for the full documentation.
  r   )r   rW   r   s         r/   _minr      r   r2   c                Z    t        j                  |       | j                  j                  z  S )z2Total bytes consumed by the elements of the array.)r   r\   rP   r   rd   s    r/   _nbytes_propertyr     s    	,,	,,r2   )r]   r\   c               2    t        j                  | ||      S )ztReturn indices of nonzero elements of an array.

  Refer to :func:`jax.numpy.nonzero` for the full documentation.
  )r\   r]   )r   nonzero)r.   r]   r\   s      r/   _nonzeror     s     
		4dz	BBr2   c           
     <    t        j                  | |||||||      S )zyReturn product of the array elements over a given axis.

  Refer to :func:`jax.numpy.prod` for the full documentation.
  )r)   rP   r*   r+   r   r&   promote_integers)r   prodr.   r)   rP   r*   r+   r   r&   r   s           r/   _prodr     s)     
D3!(HX
Z Zr2   c                4    t        j                  | |||      S )zrReturn the peak-to-peak range along a given axis.

  Refer to :func:`jax.numpy.ptp` for the full documentation.
  r7   )r   ptpr9   s       r/   _ptpr     s     
4S8	DDr2   c                ,    t        j                  |       S )z"Return the real part of the array.)r   realrd   s    r/   _real_propertyr   &  r   r2   )total_repeat_lengthr   c               6    t        j                  | ||||      S )znConstruct an array from repeated elements.

  Refer to :func:`jax.numpy.repeat` for the full documentation.
  )repeatsr)   r   r   )r   repeat)r.   r   r)   r   r   s        r/   _repeatr   *  s#     
		$d.A'3
5 5r2   r   c                  d}t        | t        |      dk(  r|d   n|      }|dk(  rt        j                  | |d|      S |dk(  rt	        t        | j                        ddd         }t        |d	      }|dn;|j                  |j                  j                  |j                  ddd   
            }t        j                  | |ddd   ||      j                  S |dk(  rt        d      t        d| d      )z|Returns an array containing the same data with a new shape.

  Refer to :func:`jax.numpy.reshape` for full documentation.
  T   r   r   Nr   Fzjnp.reshape)
partitions)specAz&np.reshape order=A is not implemented.z'Unexpected value for 'order' argument: .)_compute_newshapelenr   reshapelistrangendimr   updater   TNotImplementedError
ValueError)r.   rD   r   r   __tracebackhide__newshapedimss          r/   _reshaper   5  s    tD	QT!WDI(
c\;;tXt,GG|dii 2&'D(}EL$,*=*=""))\5F5Ftt5L)M +> +O  ;;tXdd^TMOOO|
F
GG
>ugQG
HHr2   c                2    t        j                  | ||      S )zgRound array elements to a given decimal.

  Refer to :func:`jax.numpy.round` for full documentation.
  )decimalsr*   )r   round)r.   r   r*   s      r/   _roundr   K  s    
 
c	::r2   scan)methodc               6    t        j                  | ||||      S )zqPerform a binary search within a sorted array.

  Refer to :func:`jax.numpy.searchsorted` for full documentation.)sidesorterr   )r   searchsorted)r.   vr   r   r   s        r/   _searchsortedr   R  s    
 
		ad6&	QQr2   c               8    t        j                  | |||||      S )z_Return a sorted copy of an array.

  Refer to :func:`jax.numpy.sort` for full documentation.
  rH   )r   sortrJ   s         r/   _sortr   Y  s"     
4d%%*
> >r2   c                0    t        j                  | |      S )zmRemove one or more length-1 axes from array.

  Refer to :func:`jax.numpy.squeeze` for full documentation.
  )r)   )r   squeeze)r.   r)   s     r/   _squeezer   b  s    
 
		4d	++r2   )r&   
correctionc          
     <    t        j                  | |||||||      S )zoCompute the standard deviation along a given axis.

  Refer to :func:`jax.numpy.std` for full documentation.
  r)   rP   r*   ddofr+   r&   r   )r   stdr.   r)   rP   r*   r   r+   r&   r   s           r/   _stdr   i  s'     
4u#DS[#

< <r2   c           	     :    t        j                  | ||||||      S )zpSum of the elements of the array over a given axis.

  Refer to :func:`jax.numpy.sum` for full documentation.
  )r)   rP   r*   r+   r&   r   )r   sumr   s           r/   _sumr   s  s'     
4u##6F
H Hr2   c                2    t        j                  | ||      S )z\Swap two axes of an array.

  Refer to :func:`jax.numpy.swapaxes` for full documentation.
  )ru   rv   )r   swapaxes)r.   ru   rv   s      r/   	_swapaxesr   }  s    
 
		DU	;;r2   c           
     <    t        j                  | |||||||      S )zZTake elements from an array.

  Refer to :func:`jax.numpy.take` for full documentation.
  )r)   r*   rT   unique_indicesindices_are_sortedr]   )r   take)r.   indicesr)   r*   rT   r   r   r]   s           r/   _taker     s)     
tW4StTb*<
U Ur2   )streamc               H    |t        d      t        j                  | |      S )aK  Return a copy of the array on the specified device

  Args:
    device: :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.
    stream: not implemented, passing a non-None value will lead to an error.
  Returns:
    copy of array placed on the specified device or devices.
  z$stream argument of array.to_device())r   r	   
device_put)r.   rN   r   s      r/   
_to_devicer     s'     
D
EE	f	%%r2   c                8    t        j                  | |||||      S )zaReturn the sum along the diagonal.

  Refer to :func:`jax.numpy.trace` for full documentation.
  )rt   ru   rv   rP   r*   )r   trace)r.   rt   ru   rv   rP   r*   s         r/   _tracer     s     
fEeY\	]]r2   c                    |sd}n2t        |      dk(  r|d   |d   nt        |d         }nt        |      }t        j                  | |      S )ztReturns a copy of the array with axes transposed.

  Refer to :func:`jax.numpy.transpose` for full documentation.
  Nr   r   )r   r   r   	transpose)r.   r   r)   s      r/   
_transposer    sQ    
 
D
4yA~1go47+>tAw+GDt$D			T4	((r2   c                ,    t        j                  |       S )z]Compute the all-axis array transpose.

  Refer to :func:`jax.numpy.transpose` for details.
  )r   r   rd   s    r/   _transpose_propertyr    s    
 
		T	""r2   c          
     <    t        j                  | |||||||      S )zeCompute the variance along a given axis.

  Refer to :func:`jax.numpy.var` for full documentation.
  r   )r   varr   s           r/   _varr    s(     
4u#D!):
O Or2   c                    }	 t               t        j                        t              D cg c]  \  }}t	        |      t
        u s|dk(  s|! }}}t        |      dkD  rt        d|       |r|\  }g d| |dz   d }t        d g  j                  |D              rp j                  t        j                  |      z  dk7  rKt        d j                   d j                   d	| d
t        j                  |       d j                   
      t        j                   j                  |      }|g d| ||dz   d S t        d g  j                  D              ra j                  t        j                        k7  r?t        d j                   d j                   d	| dt        j                         d	      t         fdD              S #  gY xY wc c}}w )z)Fixes a -1 value in newshape, if present.r   r   z>can only specify one unknown axis size with a `-1` value, got Nc              3  <   K   | ]  }t        |t                y wN
isinstanceint.0ds     r/   	<genexpr>z$_compute_newshape.<locals>.<genexpr>  s     C1Jq#C   r   zcannot reshape array of shape z (size z) into shape z. because the product of specified axis sizes (z) does not evenly divide c              3  <   K   | ]  }t        |t                y wr	  r
  r  s     r/   r  z$_compute_newshape.<locals>.<genexpr>  s     @1Jq#@r  )c              3     K   | ]=  }t        j                  |d       r!t        j                  j                         n| ? yw)r   N)r
   definitely_equaldivide_shape_sizesshape)r  r  r   r   s     r/   r  z$_compute_newshape.<locals>.<genexpr>  sF      I:;$''2. ''		8<<456 Is   AA)iterr
   canonicalize_shape	enumeratetyper  r   r   r,   r  r\   mathr   cancel_divide_tracerstuple)r   r   orig_newshapeir  neg1sother_sizesszs   ``      r/   r   r     s   -N $$X.("8,
KAQ3171
K%
KZ!^
 (/+ , ,
	BA2HRaL28AaCD>2KC(B#))(Bk(BCC499[))Q.6syyk
 S$$1? 3//3yy/E.F G++.88*6 7 7 
	#	#CII{	;B	~1x|1R1(1Q34.11@(?#))(?h(?@@DIIh''6syyk
 S$$1?'$))H:M9NaQ R R	 I?GI 
I I1zH
Ks   G) G4G4G4)G1c                   |t        d      || S t        j                  |d      }t        j                  | j                        }t        j                  |      }| j
                  dk(  r>||k7  rt        d      t        t        j                  | d      |      j                         S | j                  d   |z  |z  dk7  rt        d      | j                  |k(  r| S | j                  t        k(  rt        | j                  d	      |      S t        j                  | j                  t         j"                        rg | j                  dd | j                  d   d
z  }t        j$                  | j                        j                  }t'        j(                  |       j*                  }t-        j.                  |||      j0                  dddd
f   j3                  | j4                        j0                  dddd
f   j3                  | j6                        } t        | |      S |t        k(  r-t        | t         j8                        j                  t              S t        j                  |t         j"                        rPt        | t        j$                  |      j                        j                  |      }|dddd
f   d|dddd
f   z  z   S ||k  rN||z  }	 | j:                  g | j                  dd | j                  d   |	z  |	 }t        j<                  ||      S ||kD  rTt        j<                  | |      } |j:                  g |j                  dd |j                  d   |j                  d   z   S t        j<                  | |      S )a  Return a bitwise copy of the array, viewed as a new dtype.

  This is fuller-featured wrapper around :func:`jax.lax.bitcast_convert_type`.

  If the source and target dtype have the same bitwidth, the result has the same
  shape as the input array. If the bitwidth of the target dtype is different
  from the source, the size of the last axis of the result is adjusted
  accordingly.

  >>> jnp.zeros([1,2,3], dtype=jnp.int16).view(jnp.int8).shape
  (1, 2, 6)
  >>> jnp.zeros([1,2,4], dtype=jnp.int8).view(jnp.int16).shape
  (1, 2, 2)

  Conversions involving booleans are not well-defined in all situations. With
  regards to the shape of result as explained above, booleans are treated as
  having a bitwidth of 8. However, when converting to a boolean array, the input
  should only contain 0 or 1 bytes. Otherwise, results may be unpredictable or
  may change depending on how the result is used.

  This conversion is guaranteed and safe::

    >>> jnp.array([1, 0, 1], dtype=jnp.int8).view(jnp.bool_)
    Array([ True, False,  True], dtype=bool)

  However, there are no guarantees about the results of any expression involving
  a view such as this: ``jnp.array([1, 2, 3], dtype=jnp.int8).view(jnp.bool_)``.
  In particular, the results may change between JAX releases and depending on
  the platform. To safely convert such an array to a boolean array, compare it
  with `0`::

    >>> jnp.array([1, 2, 0], dtype=jnp.int8) != 0
    Array([ True,  True, False], dtype=bool)

  Args:
    dtype: An optional output dtype. If not specified, the output dtype is the
      same as the input dtype.
    type: Not implemented; accepted for NumPy compatibility.
  Returns:
    The array, viewed as the new dtype. Unlike NumPy, the array may or may not
    be a copy of the input array.
  Nz1`type` argument of array.view() is not supported.viewr   zDview() of a 0d array is only supported if the itemsize is unchanged.r   r   zuWhen changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.uint8   r   .r   y              ?)r   r   !check_and_canonicalize_user_dtypeitemsize_bitsrP   r   r   _viewr   expand_dimsr   r  boolrO   r   r   r   complexfloatingfinfor
   typeofshardingr   zerosatsetr   r   r'  r   bitcast_convert_type)
r.   rP   r  nbits_in	nbits_out	new_shape	new_dtypenew_shardingr*   factors
             r/   r,  r,    s    V 

Q
RR
]K

2
25&
A%!!$**-(""5))	YY!^9]^^t,e4<<>>
jjnx9,1
 Q R R 
ZZ5K 
ZZ4W%u--$**b&8&896$**Sb/64::b>A#56I

+11I;;t$--L  ILQRQTT	3tyy>RQTT	3tyy> 	 u
d]rxx ''--%!3!34
iooe,22
3
:
:5
ACsADqDy>BS!$Q$Y/// 	("F
$,,
J

3B
JB6)A
J6
JC##C//)

"
"4
/C3;;F		#2F		"		"(EFF##D%00r2   c                    t        d      )z8Not implemented: Use :meth:`~jax.Array.flatten` instead.zRJAX Arrays do not implement the arr.flat property: consider arr.flatten() instead.r   rd   s    r/   _notimplemented_flatr?  J  s     > 	? ?r2   c                      fd}|S )Nc                (   t        |d      r|j                         }r|| fn| |f}t        |t              r | S t	        |      t
        v r@t        d dt	        |d         j                  dt	        |d         j                        t        S )N__jax_array__z unsupported operand type(s) for z: r   z and r   )	hasattrrB  r  _accepted_binop_typesr  _rejected_binop_typesr   __name__NotImplemented)r.   otherr   	binary_opopcharswaps      r/   deferring_binary_opz7_defer_to_unrecognized_arg.<locals>.deferring_binary_op\  s    uo&!!#e E4=tUmD%./ E{++8d1g//2%T!W8N8N7QS T Tr2    )rJ  rI  rK  rL  s   ``` r/   _defer_to_unrecognized_argrN  Z  s     
r2   c                L    d}t        |j                  t        |                   )NzJAX arrays are immutable and do not support in-place item assignment. Instead of x[idx] = y, use x = x.at[idx].set(y) or another .at[] method: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ndarray.at.html)r   formatr  )r.   r   xmsgs       r/   _unimplemented_setitemrS  j  s$    
R# 	#**T$Z())r2   c                j    t        j                  | |xs d      }||j                  t              S |S )Nr   )r   )r   r   rO   r  )numberndigitsr*   s      r/   _operator_roundrW  p  s-    A6##OC44r2   c                $    ~| j                         S r	  )rL   )r.   memos     r/   	_deepcopyrZ  u  s    
	r2   c                R    t        d |D              rdd l}|j                  S t        S )Nc              3  <   K   | ]  }t        |t                y wr	  )
issubclass_HANDLED_ARRAY_TYPES)r  ts     r/   r  z#__array_module__.<locals>.<genexpr>  s     <A+	,<r  r   )r,   	jax.numpynumpyrG  )r.   typesjaxs      r/   __array_module__rd    s#    <e<<99r2   )r   r(     )static_argnumsc                    g }t        |||      D ]F  \  }}}t        j                  | ||      }|rt        j                  ||      }|j                  |       H |S )zExtracts multiple slices from `arr`.

  This is used to shard Array arguments to pmap. It's implemented as a
  Array method here to avoid circular imports.
  )ziplax_slicingslicer   r   append)	r.   start_indiceslimit_indicesremoved_dimsresultsstartslimitsremovedsliceds	            r/   _multi_slicert    sb     '!$]M<!P ffgtVV4F{{67+fNN6	
 
.r2   c                    d}t        j                  | d| j                  d   z        D cg c]  }t        j                  ||       c}S c c}w )Nr&  )r   r   )r   splitr  r   )rQ  r   r_  s      r/   _unstackrw    s>    	$(+		!TAGGAJ5F(G	H1#++a
	HH	Hs   Ac              #    K   || j                   d   kD  r|  y t        j                  | j                   d   |      \  }}t        |      D ]  }t	        j
                  | ||z  |         |rt	        j
                  | ||z  |       y y w)Nr   )r  r   divmodr   ri  dynamic_slice_in_dim)rQ  r\   
num_chunkstailr   s        r/   _chunk_iterr}    s     	AGGAJ
G}}QWWQZ6J: @,,QD$??@,,Q
T0A4HH s   B
Bc                .    t        j                  | |      S r	  )r   rewriting_take)r.   r   s     r/   _getitemr    s    		 	 t	,,r2   c                  8    e Zd ZU dZdZded<   d	dZd
dZddZy)_IndexUpdateHelpera  Helper property for index update functionality.

  The ``at`` property provides a functionally pure equivalent of in-place
  array modifications.

  In particular:

  ==============================  ================================
  Alternate syntax                Equivalent In-place expression
  ==============================  ================================
  ``x = x.at[idx].set(y)``        ``x[idx] = y``
  ``x = x.at[idx].add(y)``        ``x[idx] += y``
  ``x = x.at[idx].subtract(y)``   ``x[idx] -= y``
  ``x = x.at[idx].multiply(y)``   ``x[idx] *= y``
  ``x = x.at[idx].divide(y)``     ``x[idx] /= y``
  ``x = x.at[idx].power(y)``      ``x[idx] **= y``
  ``x = x.at[idx].min(y)``        ``x[idx] = minimum(x[idx], y)``
  ``x = x.at[idx].max(y)``        ``x[idx] = maximum(x[idx], y)``
  ``x = x.at[idx].apply(ufunc)``  ``ufunc.at(x, idx)``
  ``x = x.at[idx].get()``         ``x = x[idx]``
  ==============================  ================================

  None of the ``x.at`` expressions modify the original ``x``; instead they return
  a modified copy of ``x``. However, inside a :py:func:`~jax.jit` compiled function,
  expressions like :code:`x = x.at[idx].set(y)` are guaranteed to be applied in-place.

  Unlike NumPy in-place operations such as :code:`x[idx] += y`, if multiple
  indices refer to the same location, all updates will be applied (NumPy would
  only apply the last update, rather than applying all updates.) The order
  in which conflicting updates are applied is implementation-defined and may be
  nondeterministic (e.g., due to concurrency on some hardware platforms).

  By default, JAX assumes that all indices are in-bounds. Alternative out-of-bound
  index semantics can be specified via the ``mode`` parameter (see below).

  Args:
    mode: string specifying out-of-bound indexing mode. Options are:

      - ``"promise_in_bounds"``: (default) The user promises that indices are in bounds.
        No additional checking will be performed. In practice, this means that
        out-of-bounds indices in ``get()`` will be clipped, and out-of-bounds indices
        in ``set()``, ``add()``, etc. will be dropped.
      - ``"clip"``: clamp out of bounds indices into valid range.
      - ``"drop"``: ignore out-of-bound indices.
      - ``"fill"``: alias for ``"drop"``.  For `get()`, the optional ``fill_value``
        argument specifies the value that will be returned.

      See :class:`jax.lax.GatherScatterMode` for more details.
    wrap_negative_indices: If True (default) then negative indices indicate position
      from the end of the array, similar to Python and NumPy indexing. If False, then
      negative indices are considered out-of-bounds and behave according to the
      ``mode`` parameter.
    fill_value: Only applies to the ``get()`` method: the fill value to return for
      out-of-bounds slices when ``mode`` is ``'fill'``. Ignored otherwise. Defaults
      to ``NaN`` for inexact types, the largest negative value for signed types, the
      largest positive value for unsigned types, and ``True`` for booleans.
    indices_are_sorted: If True, the implementation will assume that the (normalized)
      indices passed to ``at[]`` are sorted in ascending order, which can lead to more
      efficient execution on some backends. If True but the indices are not actually
      sorted, the output is undefined.
    unique_indices: If True, the implementation will assume that the (normalized) indices
      passed to ``at[]`` are unique, which can result in more efficient execution on some
      backends. If True but the indices are not actually unique, the output is undefined.

  Examples:
    >>> x = jnp.arange(5.0)
    >>> x
    Array([0., 1., 2., 3., 4.], dtype=float32)
    >>> x.at[2].get()
    Array(2., dtype=float32)
    >>> x.at[2].add(10)
    Array([ 0.,  1., 12.,  3.,  4.], dtype=float32)

    By default, out-of-bound indices are ignored in updates, but this behavior
    can be controlled with the ``mode`` parameter:

    >>> x.at[10].add(10)  # dropped
    Array([0., 1., 2., 3., 4.], dtype=float32)
    >>> x.at[20].add(10, mode='clip')  # clipped
    Array([ 0.,  1.,  2.,  3., 14.], dtype=float32)

    For ``get()``, out-of-bound indices are clipped by default:

    >>> x.at[20].get()  # out-of-bounds indices clipped
    Array(4., dtype=float32)
    >>> x.at[20].get(mode='fill')  # out-of-bounds indices filled with NaN
    Array(nan, dtype=float32)
    >>> x.at[20].get(mode='fill', fill_value=-1)  # custom fill value
    Array(-1., dtype=float32)

    Negative indices count from the end of the array, but this behavior can
    be disabled by setting ``wrap_negative_indices = False``:

    >>> x.at[-1].set(99)
    Array([ 0.,  1.,  2.,  3., 99.], dtype=float32)
    >>> x.at[-1].set(99, wrap_negative_indices=False, mode='drop')  # dropped!
    Array([0., 1., 2., 3., 4.], dtype=float32)
  arrayr   r  c                    || _         y r	  r  )r.   r  s     r/   __init__z_IndexUpdateHelper.__init__  s	    DJr2   c                .    t        | j                  |      S r	  )_IndexUpdateRefr  )r.   indexs     r/   __getitem__z_IndexUpdateHelper.__getitem__  s    4::u--r2   c                "    d| j                   dS )Nz_IndexUpdateHelper(r  r  rd   s    r/   __repr__z_IndexUpdateHelper.__repr__  s     a00r2   N)r  r   )r  scatter.Indexreturnr  r  str)	rF  
__module____qualname____doc__	__slots____annotations__r  r  r  rM  r2   r/   r  r    s$    aD )	,.1r2   r  c                     e Zd ZU dZdZded<   ded<   ddZddZd	d	d
d
d
dd	 	 	 	 	 	 	 ddZd	d	d
d
dd	 	 	 	 	 	 	 	 	 ddZ	d	d	d
dd	 	 	 	 	 	 	 	 	 ddZ
d	d	d
d
dd	 	 	 	 	 	 	 	 	 	 	 ddZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZeZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZd	d	d
dd	 	 	 	 	 	 	 	 	 ddZy
) r  a  Helper object to call indexed update functions for an (advanced) index.

  This object references a source array and a specific indexer into that array.
  Methods on this object return copies of the source array that have been
  modified at the positions specified by the indexer.
  r  r  r   r  r  r  c                     || _         || _        y r	  r  )r.   r  r  s      r/   r  z_IndexUpdateRef.__init__-  s    DJDJr2   c                <    d| j                   d| j                  dS )Nz_IndexUpdateRef(z, r  r  rd   s    r/   r  z_IndexUpdateRef.__repr__1  s    djj^2djj^1==r2   FNT)r   r   rT   r]   r   wrap_negative_indicesc          
         |$t        |t        t        f      sJ t        |d      }t	        j
                  | j                  | j                  ||||||      S )az  Equivalent to ``x[idx]``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexing <numpy.doc.indexing>` ``x[idx]``. This function differs from
    the usual array indexing syntax in that it allows additional keyword
    arguments ``indices_are_sorted`` and ``unique_indices`` to be passed.

    See :func:`jax.numpy.ndarray.at` for details.
    z.get)r   r   rT   r]   normalize_indicesr   )r  r   r   r   r   r  r  r  )r.   r   r   rT   r]   r   r  s          r/   getz_IndexUpdateRef.get4  s[     }m&DEEE*<@l""4::tzz6H2@t.85J0<> >r2   )r   r   rT   r   r  c                   |$t        |t        t        f      sJ t        |d      }t	        j
                  | j                  | j                  |t        j                  |||||	      S )zPure equivalent of ``x[idx] = y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:`indexed assignment <numpy.doc.indexing>` ``x[idx] = y``.

    See :func:`jax.numpy.ndarray.at` for details.
    z.setr   r   rT   r   r  )	r  r   r   r   r   _scatter_updater  r  ri  r.   valuesr   r   rT   r   r  s          r/   r5  z_IndexUpdateRef.setL  sb     }m&DEEE*<@l""

DJJ(;(;-n/	1 1r2   )r   r   rT   r  c          
         fd}t        j                  | j                  | j                  t	        j
                  | j                        |||||      S )a@  Pure equivalent of ``func.at(x, idx)`` for a unary ufunc ``func``.

    Returns the value of ``x`` that would result from applying the unary
    function ``func`` to ``x`` at the given indices. This is similar to
    ``x.at[idx].set(func(x[idx]))``, but differs in the case of repeated indices:
    in ``x.at[idx].apply(func)``, repeated indices result in the function being
    applied multiple times.

    Note that in the current implementation, ``scatter_apply`` is not compatible
    with automatic differentiation.

    See :func:`jax.numpy.ndarray.at` for details.
    c                N    t        j                  | ||fd|j                  i|S )Nupdate_shape)ri  scatter_applyr  )rQ  r   yr   kwargsfuncs        r/   _scatter_applyz-_IndexUpdateRef.apply.<locals>._scatter_applyr  s)    &&q'4^AGG^W]^^r2   r   r   rT   r  )r   r  r  r  r   _zero)r.   r  r   r   rT   r  r  s    `     r/   applyz_IndexUpdateRef.applya  sE    "_""

DJJ		$** 5~-n%:< <r2   c                   |$t        |t        t        f      sJ t        |d      }t	        j
                  | j                  | j                  |t        j                  |||||	      S )zPure equivalent of ``x[idx] += y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>` ``x[idx] += y``.

    See :func:`jax.numpy.ndarray.at` for details.
    z.addr  )
r  r   r   r   r   r  r  r  ri  scatter_addr  s          r/   addz_IndexUpdateRef.addy  sb     }m&DEEE*<@l""

DJJ(?(?-n/	1 1r2   c          
         t        j                  | j                  | j                  |t        j
                  ||||      S )zPure equivalent of ``x[idx] -= y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>` ``x[idx] -= y``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )r   r  r  r  ri  scatter_subr.   r  r   r   rT   r  s         r/   subtractz_IndexUpdateRef.subtract  s;     ""4::tzz6#.#:#:6H2@t5J	L Lr2   c          
         t        j                  | j                  | j                  |t        j
                  ||||      S )zPure equivalent of ``x[idx] *= y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>` ``x[idx] *= y``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )r   r  r  r  ri  scatter_mulr  s         r/   multiplyz_IndexUpdateRef.multiply  s<     ""4::tzz6#.#:#:6H2@(,@U	W Wr2   c                   t        j                  | j                  t        j                  t        j                  | j                        | j                  |t        j                  ||||            S )zPure equivalent of ``x[idx] /= y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>` ``x[idx] /= y``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )
r   divider  r   r  r   	ones_liker  ri  r  r  s         r/   r  z_IndexUpdateRef.divide  s[     ==
jjn66tzzBDJJPV)551C-;$0E	GH Hr2   c                   t        j                  | j                  t        j                  t        j                  | j                        | j                  |t        j                  ||||            S )zPure equivalent of ``x[idx] **= y``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>` ``x[idx] **= y``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )
r   powerr  r   r  r   r  r  ri  r  r  s         r/   r  z_IndexUpdateRef.power  s[     <<
jjn66tzzBDJJPV)551C-;$0E	GH Hr2   c          
         t        j                  | j                  | j                  |t        j
                  ||||      S )a	  Pure equivalent of ``x[idx] = minimum(x[idx], y)``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>`
    ``x[idx] = minimum(x[idx], y)``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )r   r  r  r  ri  scatter_minr  s         r/   rW   z_IndexUpdateRef.min  ;     ""4::tzz6#.#:#:6H2@t5J	L Lr2   c          
         t        j                  | j                  | j                  |t        j
                  ||||      S )a	  Pure equivalent of ``x[idx] = maximum(x[idx], y)``.

    Returns the value of ``x`` that would result from the NumPy-style
    :mod:indexed assignment <numpy.doc.indexing>`
    ``x[idx] = maximum(x[idx], y)``.

    See :func:`jax.numpy.ndarray.at` for details.
    r  )r   r  r  r  ri  scatter_maxr  s         r/   rX   z_IndexUpdateRef.max  r  r2   )r  r   r  r  r  )r   r.  r   r.  rT   *str | lax_slicing.GatherScatterMode | Noner]   ArrayLike | Noner   $NamedSharding | PartitionSpec | Noner  r.  )r  r   r   r.  r   r.  rT   r  r   r  r  r.  r  None)r  zCallable[[ArrayLike], Array]r   r.  r   r.  rT   r  r  r.  r  r   )r  r   r   r.  r   r.  rT   r  r   r  r  r.  r  r   )r  r   r   r.  r   r.  rT   r  r  r.  r  r   )rF  r  r  r  r  r  r  r  r  r5  r  r  r  r  mulr  r  rW   rX   rM  r2   r/   r  r  !  s    !)	,	> /4E=A)-?C(,	>:>&> => "&	>0 BG!&=A?C(,	11:1 =1 "&	1 26	1, (-U?C*.< $<>B<<< $(< 49<2 &+5=A?C(,	1"1<@1:1 =1 "&	1 27	1, +0BF-1L#'LAEL?L '+L 7<L$ +0BF-1W#'WAEW?W '+W 7<W  	# ).e@D+/H!%H?CH=H %)H 5:H( (-U?C*.H $H>BH<H $(H 49H( &+5=A(,L"L<@L:L "&L 27L& &+5=A(,L"L<@L:L "&L 27Lr2   r  getitemsetitemdeepcopynegc                ,    t        j                  |       S r	  )r   negativerd   s    r/   <lambda>r         food+ r2   posc                ,    t        j                  |       S r	  )r   positiverd   s    r/   r  r    r  r2   eqz==nez!=lt<lez<=gt>gez>=absc                ,    t        j                  |       S r	  )r   r  rd   s    r/   r  r    s    fjj& r2   r  +radd)rK  sub-rsubr  *rmultruediv/rtruedivfloordivz//	rfloordivry  rdivmodmod%rmodpowz**rpowmatmul@rmatmuland&randor|^c                ,    t        j                  |       S r	  )r   bitwise_notrd   s    r/   r  r  !  s    ++D1 r2   z<<z>>)	rorxorrxorinvertlshiftrshiftrlshiftrrshiftr   __array_namespace__r,   r4   r8   r=   rA   rI   rO   rU   rZ   r_   rc   rg   rm   rq   rw   r}   flattenr   r   r   r   r   r   r   r   r   r   r   r   r   )
r   r   r   	to_devicer   r   r  r%  _splitrt  )r}  rw  )flatr   mTr   r   nbytesr   r4  c                   t         j                         D ]  \  }}t        | d| t        |               t        j                         D ]%  \  }}t        | |t        j                  |             ' t        j                         D ]%  \  }}t        | |t        j                  |             ' t        | dt        t                     y )N__array_module)
_array_operatorsitemssetattrstaticmethod_array_methodsr
   aval_method_array_propertiesaval_propertyrd  )shaped_arrayoperator_namefunctionmethod_namer   	prop_nameprops          r/   _set_shaped_array_attributesr  j  s    
 "2!7!7!9 GmXLAm_-|H/EFG ,113 Ak6L+t'7'7'?@A*002 ?oiL)T%7%7%=>?	,6F)GHr2   c                      fd}|S )Nc                D     t        | j                  d       | g| S )Nr	  )getattraval)r.   r   names     r/   opz%_forward_operator_to_aval.<locals>.opy  s&    )7499$j)$666r2   rM  )r  r  s   ` r/   _forward_operator_to_avalr   x  s    7	)r2   c                      fd}|S )Nc                \    d} t        | j                        j                  | g|i |S )NT)r  r  fun)r.   r   r  r   r  s       r/   methz%_forward_method_to_aval.<locals>.meth~  s1    '7499d#''>t>v>>r2   rM  )r  r$  s   ` r/   _forward_method_to_avalr%  }  s    ? 
+r2   c                $     t          fd       }|S )Nc                N    t        | j                        j                  |       S r	  )r  r  fget)r.   r  s    r/   r  z'_forward_property_to_aval.<locals>.prop  s    499d#((..r2   )property)r  r  s   ` r/   _forward_property_to_avalr*    s    / /	+r2   c                    t         D ]!  }||vst        | d| dt        |             # t        D ]  }||vst        | |t	        |              t
        D ]  }||vst        | |t        |              y N__)r  r  r   r  r%  r  r*  )tracerexcluder  r  r  s        r/   _set_tracer_aval_forwardingr0    s    ' XmG#f=/,.G.VWX $ Ik'!fk#:;#GHI % Gifi!:9!EFGr2   c                b     fd}t         j                         D ]  \  }} |d| d|        t        j                         D ]  \  }} |||        t        j                         D ]  \  }}	 ||t	        |	              t
        j                         D ]  \  }
}t         |
|        y )Nc                <    | v ry r| v rt        | |       y y r	  )r  )	attr_nametarget
array_implr/  includes     r/   maybe_setattrz1_set_array_base_attributes.<locals>.maybe_setattr  s.    yG3i7*j)V, +r2   r-  )r  r  r  r  r)  _impl_only_array_methodsr  )r5  r6  r/  r7  r  r  r  r   r  r  r  r  s   ```         r/   _set_array_base_attributesr9    s    - "2!7!7!9 4mXB}oR((34+113 'k6+v&'*002 -oi)Xd^,- -224 $jdDJd#$r2   c                &    t        | dt               y )Nrd  )r  rd  )r5  s    r/   _set_array_attributesr;    s    	*(*:;r2   c                T     t         j                  t        |       fd              }|S )Nc                      t        d       )NzCannot call abstract method r>  )r   r  r  s     r/   r   z%_make_abstract_method.<locals>.method  s      <TFC
DDr2   )abcabstractmethodr   )r  r  r   s   `  r/   _make_abstract_methodr@    s.    ;E  E	-r2   c                X   t         j                         D ]$  \  }}t        | d| dt        d| d|             & t        j                         D ]  \  }}t        | |t        ||              t
        j                         D ]%  \  }}t        | |t        t        ||                   ' y r,  )r  r  r  r@  r  r  r)  )	basearrayr  r  r  r   r  r  s          r/   _set_array_abstract_methodsrC    s    !1!7!7!9 EmXIM?"-!B}oR"8(CEE ,113 8k6I{!+v688 +002 >oiIy*9d;<>>r2   c                     t        t        j                         t        t        dh       t        t        j                  h t        d       t        t               t        t               y)z9Call this function once to register methods of JAX arraysr  )r/  r4  N)r  r
   ShapedArrayr9  r   r0  Tracerr8  r;  rC  r   rM  r2   r/   r   r     sF    t//0Y@dkk3T5M3Tt3TU	"e$r2   )NNF)r.   r   r)   reductions.Axisr*   r  r+   r.  r&   r  r  r   )NNN)
r.   r   r)   
int | Noner*   r  r+   zbool | Noner  r   )r   )r.   r   r@   r  r)   r  r  r   )r.   r   r)   rH  rC   r  rD   r  rE   r.  rF   r.  r  r   )FN)
r.   r   rP   DTypeLike | NonerL   r.  rN   zxc.Device | Sharding | Noner  r   )Nraise)
r.   r   rS   zSequence[ArrayLike]r*   r  rT   r  r  r   )NN)r.   r   rW   r  rX   r  r  r   r	  )r.   r   r`   r   r)   rH  r*   r  r\   rH  r]   r   r  r   )r.   r   r  r   )
r.   r   r)   rG  rP   rI  r*   r  r  r   )r   r   r   )
r.   r   rt   r  ru   r  rv   r  r  r   )
r.   r   r~   r   rz   zlax.PrecisionLiker{   rI  r  r   )r   )r.   r   rD   r  r  r   )r.   r   r   r  r  zbool | int | float | complex)r.   r   r  r  )r.   r   )NNFNN)r.   r   r)   rG  r*   r  r+   r.  r   r  r&   r  r  r   )NNNF)r.   r   r)   rG  rP   rI  r*   r  r+   r.  r&   r  r  r   )r.   r   r]   z(None | ArrayLike | tuple[ArrayLike, ...]r\   rH  r  ztuple[Array, ...])NNNFNNT)r.   r   r)   rG  rP   rI  r*   r  r+   r.  r   r  r&   r  r   r.  r  r   )
r.   r   r)   rG  r*   r  r+   r.  r  r   )r.   r   r   r   r)   rH  r   rH  r   r  r  r   )r.   r   r   r   rD   r  r  r   )r   N)r.   r   r   r  r*   r  r  r   )leftN)r.   r   r   r   r   r  r   r  r   r  r  r   )r.   r   r)   rG  r  r   )NNNr   F)r.   r   r)   rG  rP   rI  r*   r  r   r  r+   r.  r&   r  r   zint | float | Noner  r   )r.   r   ru   r  rv   r  r  r   )NNNFFN)r.   r   r   r   r)   rH  r*   r  rT   z
str | Noner   r.  r   r.  r]   zStaticScalar | Noner  r   )r.   r   rN   zxc.Device | Shardingr   zint | Any | None)r   r   r   NN)r.   r   rt   zint | ArrayLikeru   r  rv   r  rP   rI  r*   r  r  r   )r.   r   r   r   r  r   )r   r   r   zDimSize | Shaper  r"   )r.   r   rP   rI  r  r  r  r   )F)rU  r   rV  rH  r  r   )r.   r   rY  r   r  r   )
r.   r   rl  tuple[tuple[int, ...]]rm  rL  rn  rL  r  list[Array])rQ  r   r  rM  )rM  )r  
__future__r   __all__r>  	functoolsr   r  typingr   collections.abcr   r   ra  r   jax._srcr	   r
   r   r   jax._src.api_utilr   jax._src.arrayr   jax._src.laxr   r   ri  jax._src.libr   xcjax._src.numpyr   r   r   r   r   r   r   jax._src.pjitr   jax._src.shardingr   jax._src.sharding_implsr   r   jax._src.opsr   jax._src.typingr   r   r    r!   r"   r#   jax._src.utilr$   r%   map
unsafe_maprh  
unsafe_zipr0   r5   r:   r>   rB   rK   rQ   rV   r[   ra   re   rh   rj   ro   rr   rx   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  r  r  r   r,  r?  r  floatcomplexgenericndarrayTypedNdArrayrD  r   r  r5  dictrE  rN  rS  rW  rZ  rF  _JAX_ARRAY_TYPESr^  rd  jitrt  rw  r}  r  r  r  equal	not_equalless
less_equalgreatergreater_equalr  r  r  true_dividefloor_dividery  r  r  r  bitwise_and
bitwise_orbitwise_xor
left_shiftright_shiftr  r  rv  r  r8  r  r  r   r%  r*  r0  r9  r;  r@  rC  r   rM  r2   r/   <module>rx     s  "
 #'
( 
    .      1 $  / ) - ) # $ . % ! ' & H   U U ,CZCZ AER>BRR+;RGLR AER>BRR+;RGLR ?C$(G!G-2G ?C$(G!G-2G:AUY UAA.2A?DA @E26	A/	A;@	AE0 "&>6:!%q>>/3>>3<>EJ>  SWCC"'C RVBB!&BK GK48n!1n=BnGD G* AE=A#'66*:6 6,16 PT-29$(99&*9!9-29 AE=A#'66*:6 6,16- UY $CC):C PT-2FJ#'	Z	Z&*	Z#	Z3C	Z !	Z -2	Z AEEE$)E	5.2AE	5!+	5>	5JO	5 47T II,; :@-1RDJR*R>AROTR>dTe>>&*>?C>PU>, OS;@<#'$<<!$<48< <5G<SX< OSOSBFHH%)H<LH H;?HKPH< QU\a,0UU37UUYU)U5:U +/&'&  ST7;^"^04^@E^)# OS;@O#'$OO!$O48O O5GOSXOI@a1H? 	JJJJ	  uc40  *5
 KK+ '2::-7  	  6 6  6 ;F !& I 	II-
o1 o1dXL XLt,X,#, 	%, i	,
 	+, 	+, "46, "4)9)9:, "34, "4):):;, "37, "4)=)=>, 	&, 	#C	4, 	
$S&**4
@,  	#C	9!," 	
$S&//
E#,$ 	#C	9%,& 	
$S&//
E',( 'V-?-?@),* (f.@.@tL+,, (v/B/BC-,. )$0C0C$O/,0 &x?1,2 '&--dK3,4 	#C	45,6 	
$S&**4
@7,8 	#D&,,	79,: 	
$T6<<d
C;,< &s,?,F,FG=,> '-@-G-GdS?,@ 	#C););	<A,B 	
$S&*<*<4
HC,D "3(9(9:E,F 
$C):):	F	#C););	<
$S&*<*<4
H1&tV->->?&tV-?-?@'f.?.?dK'f.@.@tLW, \/+??// / G	/
 G/ -/ X/ G/ G/ 	%/ i/ 	%/ z/ 	%/ X/  G!/" i#/$ %/& X'/( 	%)/* +/, 	%-/. //0 X1/2 	%3/4 5/6 
87/8 G9/: X;/< 
6=/> -?/@ 	%A/B XC/D E/F 

	
 OO]/d   "

 	 I
	G$&<	>%r2   