Ë
    ßGìj‡½ ã            	      óæ  — d dl mZ d dlmZ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 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 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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/m0Z0 d dl1m2Z2m3Z3m4Z4 d dl5m6Z6 d dlm7Z7 d dl8m9Z9m:Z:m;Z; d dl<m=Z= e:Z>e:Z?e;Z@e;ZAe;ZBeeC   ZDejŠ                  ZEejŒ                  ZFd¬d„ZGd d!œ	 	 	 d­d"„ZHd#„ ZId®d%„ZJd&„ ZK G d'„ d(«      ZLeeMeLeEef   ZNd¯d)„ZO	 	 	 	 d°d*„ZPdd+œ	 	 	 d±d,„ZQdd+œ	 	 	 d±d-„ZRd²d.„ZSdHd³d0„ZTdHd´d1„ZUdµd2„ZVd¶d3„ZWd·d4„ZXd¸d5„ZYd¹d6„ZZdd+œ	 dºd7„Z[d»d8„Z\d9„ Z]	 	 d¼dd;œ	 	 	 	 	 d½d<„Z^d=„ Z_d:e`d>d?fdd;œ	 	 	 	 	 	 	 	 	 d¾d@„Za eedA¬B«      d¿dC„«       ZbeCfdd;œ	 	 	 	 	 	 	 	 	 dÀdD„Zc eedA¬B«      d¿dE„«       Zd	 	 dÁdd;œ	 	 	 	 	 	 	 dÂdF„ZedG„ Zf eedH¬B«      d¿dI„«       Zg	 	 	 	 	 dÃ	 	 	 	 	 	 	 	 	 	 	 	 	 dÄdL„Zhd:e`fdd;œ	 	 	 	 	 dÅdM„Zi eedN¬B«      d¿dO„«       Zj eedN¬B«      d¿dP„«       Zk	 	 	 dÆ	 	 	 	 	 	 	 	 	 	 	 dÇdQ„Zl eedR¬B«      d¿dS„«       Zmde`fdd;œ	 	 	 	 	 	 	 	 	 dÈdT„Zn eedA¬B«      d¿dU„«       Zo ejà                  dV«      ddWf	 	 	 	 	 	 	 dÉdX„Zq eed$dKg¬Y«      dÊdZ„«       Zrde`f	 	 	 	 	 	 	 	 	 dËd[„Zsd¿d\„Ztd:e`f	 	 	 	 	 dÅd]„Zu eedN¬B«      d¿d^„«       Zvde`f	 	 	 	 	 	 	 dÌd_„Zw eed`¬B«      d¿da„«       Zxd:e`f	 	 	 	 	 dÅdb„Zy eedN¬B«      d¿dc„«       ZzdÍdd„Z{de„ Z|d dfœdg„Z}dh„ Z~ ejþ                  di«      Z€e€�j                  e}«       dj„ Z‚e€�j                  e‚«        e!�j                  e€ddk„ «        e#�j
                  e€ e#�j                   ee}dJ¬f«      d ¬l«      «        e#�j
                  e€ e#�j                   ee}dJ¬f«      d ¬l«      dm¬n«       e~e"�j                  e€<   de`f	 	 	 	 	 	 	 dÎdo„Zˆde`f	 	 	 	 	 	 	 dÎdp„Z‰ eedq¬Y«      dÏd¿dr„«       ZŠ eeds¬B«      d¿dt„«       Z‹ eeds¬B«      d¿du„«       ZŒ eed`¬B«      d¿dv„«       Z�deCf	 	 	 	 	 	 	 dÐdw„ZŽd:e`dfdd;œ	 	 	 	 	 	 	 dÑdx„Z� eedy¬B«      d¿dz„«       Z�	 	 	 	 dÒ	 	 	 	 	 	 	 	 	 	 	 	 	 dÓd{„Z‘d:e`f	 	 	 	 	 dÅd|„Z’ eedN¬B«      d¿d}„«       Z“d:e`f	 	 	 	 	 dÅd~„Z” eedN¬B«      d„ «       Z•de`f	 	 	 	 	 	 	 dÔd€„Z– eed`¬B«      d¿d�„«       Z—d:e`f	 	 	 	 	 	 	 dÕd‚„Z˜ eed`¬B«      d¿dƒ„«       Z™de`f	 	 	 	 	 	 	 dÖd„„Zš eed`¬B«      d¿d…„«       Z›de`f	 	 	 	 	 	 	 	 	 d×d†„Zœ eedA¬B«      d¿d‡„«       Z�d:eCf	 	 	 	 	 dØdˆ„Zž eedN¬B«      d¿d‰„«       ZŸd:e`f	 	 	 	 	 dÅdŠ„Z  eedN¬B«      d¿d‹„«       Z¡d:e`f	 	 	 	 	 	 	 	 	 dÙdŒ„Z¢ eedA¬B«      d¿d�„«       Z£d:e`f	 	 	 	 	 	 	 	 	 dÚdŽ„Z¤ eedA¬B«      d¿d�„«       Z¥d:e`df	 	 	 	 	 	 	 	 	 	 	 dÛd�„Z¦d:e`f	 	 	 	 	 	 	 	 	 dÜd‘„Z§d/d:e`f	 	 	 	 	 	 	 	 	 dÝd’„Z¨de`f	 	 	 	 	 	 	 dÞd“„Z© eed`¬B«      d¿d”„«       Zªde`f	 	 	 	 	 	 	 dßd•„Z« eed`¬B«      d¿d–„«       Z¬deCf	 	 	 	 	 	 	 dàd—„Z­ eed`¬B«      d¿d˜„«       Z®de`f	 	 	 	 	 	 	 	 	 	 	 dád™„Z¯ eedšdJ¬›«      d¿dœ„«       Z° ejà                  d�«      de`f	 	 	 	 	 	 	 dâdž„Z± eed`dJ¬›«      d¿dŸ„«       Z²d „ Z³ eedRdJ¬›«      d¡„ «       Z´ eedRdJ¬›«      d¢„ «       Zµ eedAdJ¬›«      d¿d£„«       Z¶de`f	 	 	 	 	 	 	 	 	 	 	 dãd¤„Z· ejþ                  d¥«      Z¸ e�jr                  e¸«       e¸�j                  d¦„ «        e"�jt                  e¸«        e#�j
                  e¸d§„ «       de`d�d¨œ	 	 	 	 	 	 	 	 	 	 	 däd©„Z»dª„ Z¼d«„ Z½y)åé    )Úannotations)ÚHashableÚSequence)ÚpartialN)Úindex)ÚUnion)Úconfig)Úcore)Údispatch)Údtypes)Únumpy)Úprng)Ú
xla_bridge)Úget_abstract_mesh)ÚNamedShardingÚPartitionSpec)ÚjitÚvmap)Úad)Úbatching)Úmlir)Úcontrol_flow)Úlax)Úspecial)Úeinsum)Úlinalg)Ú_convert_and_clip_integer)Ú
_arraylikeÚcheck_arraylikeÚpromote_dtypes_inexact)Ú	auto_axes)Úcanonicalize_sharding)ÚArrayÚ	ArrayLikeÚ	DTypeLike)Úcanonicalize_axisc                ó.   — t        j                  | | «      S ©N)r   Úne©Úxs    úSC:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\jax/_src/random.pyÚ_isnanr-   E   s   € Ü	�‰��1‹Ðó    F©Úallow_batchedc               óž  — t        |t        «      r3t        j                  |j                  t        j
                  «      r|}d}nÕt        |«      r³t        j                  |t        «       ¬«      }d}t        j                  j                  dk(  rt        d«      ‚t        j                  j                  dk(  rt        j                  dd¬«       nLt        j                   j                  r2t        j                  d	t"        «       nt%        d
t'        |«      › �«      ‚|s0|j(                  r$t        | › dt+        j,                  |«      › d�«      ‚||fS )NF©ÚimplTÚerrorz±Legacy uint32 key array passed as key to jax.random function. Please create keys using jax.random.key(). If use of a raw key array was intended, set jax_legacy_prng_key="allow".Úwarné   )Ú
stacklevelzjRaw arrays as random keys to jax.random functions are deprecated. Assuming valid threefry2x32 key for now.zunexpected PRNG key type z: accepts a single key, but was given a key array of shape ú" != (). Use jax.vmap for batching.)Ú
isinstancer#   r   Ú
issubdtypeÚdtypeÚprng_keyr   r   Úrandom_wrapÚdefault_prng_implr	   Úlegacy_prng_keyÚvalueÚ
ValueErrorÚwarningsr5   Úenable_custom_prngÚFutureWarningÚ	TypeErrorÚtypeÚndimÚnpÚshape)ÚnameÚkeyr0   Úwrapped_keyÚwrappeds        r,   Ú_check_prng_keyrN   I   s$  € ä�”UÔ¤× 1Ñ 1°#·)±)¼V¿_¹_Ô MØ€KØ�GÜ�#„ä×"Ñ" 3Ô->Ó-@ÔA€KØ€GÜ×Ñ×#Ñ# wÒ.Üð	9ó:ð :ô 
×	Ñ	×	%Ñ	%¨Ò	/Ü‡m�mð	9àEFöHô 
×	"Ñ	"×	(Ò	(ä‡m�mð5ä
õô
 Ð/´°S³	¨{Ð;Ó
<Ð<á
˜[×-Ò-Ü
˜�vð Ü!Ÿx™x¨›}˜oÐ-OðQó Rð Rð 
�gÐ	Ðr.   c                óÌ   — t        j                  |j                  t         j                  «      sJ ‚t        j
                  j                  r|S | rt        j                  |«      S |S r(   )	r   r:   r;   r<   r	   rC   r@   r   Úrandom_unwrap)Úwas_wrappedrK   s     r,   Ú_return_prng_keysrR   l   sL   € ä	×	Ñ	˜3Ÿ9™9¤f§o¡oÔ	6Ð6Ð	6Ü×Ñ×$Ò$Ø€Já&1Œ4×Ñ˜cÓ"Ð:°sÐ:r.   rI   c                ó’   — t        j                  | j                  t         j                  «      sJ ‚t	        j
                  | ||¬«      S )N©Ú	bit_widthrI   )r   r:   r;   r<   r   Úrandom_bits)rK   rU   rI   s      r,   Ú_random_bitsrW   u   s5   € Ü	×	Ñ	˜3Ÿ9™9¤f§o¡oÔ	6Ð6Ð	6Ü	×	Ñ	˜#¨¸%Ô	@Ð@r.   c                 óŽ   — t         j                  j                  } | t        j                  v sJ | «       ‚t        j                  |    S )z–Get the default PRNG implementation.

  The default implementation is determined by ``config.jax_default_prng_impl``,
  which specifies it by name.
  )r	   r>   r@   r   Úprngs)Ú	impl_names    r,   r>   r>   |   s;   € ô ×&Ñ&×,Ñ,€)Ø	”d—j‘jÑ	 Ð+ )Ó+Ð	 Ü	�‰�IÑ	Ðr.   c                  óH   — e Zd ZU dZdgZded<   d„ Zd
d„Zd
d„Zdd„Z	dd„Z
y	)ÚPRNGSpecz$Specifies a PRNG key implementation.Ú_implÚPRNGImplc                ó   — || _         y r(   )r]   )Úselfr3   s     r,   Ú__init__zPRNGSpec.__init__“   s	   € Ø€D…Jr.   c                ó6   — d| j                   j                  ›d�S )Nz	PRNGSpec(Ú))r]   rJ   ©r`   s    r,   Ú__repr__zPRNGSpec.__repr__–   s   € Ø�t—z‘z—‘Ð)¨Ð+Ð+r.   c                ó,   — t        | j                  «      S r(   )Ústrr]   rd   s    r,   Ú__str__zPRNGSpec.__str__™   s   € Üˆt�z‰z‹?Ðr.   c                ó,   — t        | j                  «      S r(   )Úhashr]   rd   s    r,   Ú__hash__zPRNGSpec.__hash__œ   s   € Ü�—
‘
ÓÐr.   c                óX   — t        |t        «      xr | j                  |j                  k(  S r(   )r9   r\   r]   )r`   Úothers     r,   Ú__eq__zPRNGSpec.__eq__Ÿ   s!   € Ü�eœXÓ&ÒD¨4¯:©:¸¿¹Ñ+DÐDr.   N)Úreturnrg   )ro   Úint)ro   Úbool)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__Ú__annotations__ra   re   rh   rk   rn   © r.   r,   r\   r\   �   s+   … Ù,àˆi€)Ø	ƒ/òó,óóôEr.   r\   c                ó¦  — | €
t        «       S t        | «      t        u r| S t        | «      t        u r| j                  S t        | «      t
        u rk| t        j                  v rt        j                  |    S dj                  d„ t        j                  j                  «       D «       «      }t        d| › d|› d�«      ‚t        | «      }t        d|› d�«      ‚)Nz, c              3  ó(   K  — | ]
  }d |› d �–— Œ y­w)Ú"Nrx   )Ú.0Úss     r,   Ú	<genexpr>z$resolve_prng_impl.<locals>.<genexpr>·   s   è ø€ Ð=Ñ+< a˜1˜Q˜C˜qœÑ+<ùs   ‚z"unrecognized PRNG implementation "z". Did you mean one of: Ú?zunrecognized type z$ for specifying PRNG implementation.)r>   rF   r^   r\   r]   rg   r   rY   ÚjoinÚkeysrA   rE   )Ú	impl_specÚkeys_fmtÚts      r,   Úresolve_prng_implr…   ¨   sÈ   € ØÐÜÓÐÜ	ˆ)ƒ_œÑ ð
 ÐÜ	ˆ)ƒ_œÑ Ø�?‰?ÐÜ	ˆ)ƒ_œÑØ”D—J‘JÑÜ�Z‰Z˜	Ñ"Ð"à�y‰yÑ=¬4¯:©:¯?©?Ô+<Ó=Ó=€HÜ
Ð9¸)¸ð E-Ø-5¨J°að9ó :ð :ô ˆ9ƒo€!ÜÐ& q cÐ)MÐNÓOÐOr.   c                óH  — t        |«      }t        |d«      r<t        j                  |j                  t        j
                  «      rt        | › d�«      ‚t        j                  |«      r$t        | › dt        j                  |«      › d�«      ‚t        j                  ||¬«      S )Nr;   z1 accepts a scalar seed, but was given a PRNG key.z8 accepts a scalar seed, but was given an array of shape z! != (). Use jax.vmap for batchingr2   )r…   Úhasattrr   r:   r;   r<   rE   rH   rG   rI   r   Úrandom_seed)Ú	ctor_nameÚseedr‚   r3   s       r,   Ú_keyr‹   ¿   s—   € ä	˜9Ó	%€$ÜˆT�7Ô¤× 1Ñ 1°$·*±*¼f¿o¹oÔ NÜ
Øˆ+ÐFÐGóIð Iä‡W�WˆT„]Ü
Øˆ+ð Ü—‘˜$“Ð Ð Að	CóDð Dô 
×	Ñ	˜$ TÔ	*Ð*r.   r2   c               ó   — t        d| |«      S )ai  Create a pseudo-random number generator (PRNG) key given an integer seed.

  The result is a scalar array containing a key, whose dtype indicates
  the default PRNG implementation, as determined by the optional
  ``impl`` argument or, otherwise, by the ``jax_default_prng_impl``
  config flag at the time when this function is called.

  Args:
    seed: a 64- or 32-bit integer used as the value of the key.
    impl: optional string specifying the PRNG implementation (e.g.
      ``'threefry2x32'``)

  Returns:
    A scalar PRNG key array, consumable by random functions as well as ``split``
    and ``fold_in``.
  rK   )r‹   ©rŠ   r3   s     r,   rK   rK   Ë   s   € ô$ 
ˆe�T˜4Ó	 Ð r.   c               ó0   — t        dt        d| |«      «      S )aì  Create a legacy PRNG key given an integer seed.

  This function produces old-style legacy PRNG keys, which are arrays
  of dtype ``uint32``. For more, see the note in the `PRNG keys
  <https://docs.jax.dev/en/latest/jax.random.html#prng-keys>`_
  section. When possible, :func:`jax.random.key` is recommended for
  use instead.

  The resulting key does not carry a PRNG implementation. The returned
  key matches the implementation given by the optional ``impl``
  argument or, otherwise, determined by the ``jax_default_prng_impl``
  config flag. Callers must ensure that same implementation is set as
  the default when passing this key as an argument to other functions
  (such as ``jax.random.split`` and ``jax.random.normal``).

  Args:
    seed: a 64- or 32-bit integer used as the value of the key.
    impl: optional string specifying the PRNG implementation (e.g.
      ``'threefry2x32'``)

  Returns:
    A PRNG key, consumable by random functions as well as ``split``
    and ``fold_in``.
  TÚPRNGKey)rR   r‹   r�   s     r,   r�   r�   ß   s   € ô4 
˜4¤ i°°tÓ!<Ó	=Ð=r.   c                óü   — t        d| «      \  } }t        j                  |«      r"t        dt        j                  |«      › d�«      ‚t        j                  | t        j                  |d¬«      «      }t        ||«      S )ac  Folds in data to a PRNG key to form a new PRNG key.

  Args:
    key: a PRNG key (from ``key``, ``split``, ``fold_in``).
    data: a 32-bit integer representing data to be folded into the key.

  Returns:
    A new PRNG key that is a deterministic function of the inputs and is
    statistically safe for producing a stream of new pseudo-random values.
  Úfold_inz9fold_in accepts a scalar, but was given an array ofshape r8   Úuint32©r;   )
rN   rH   rG   rE   rI   r   Úrandom_fold_inÚjnpÚasarrayrR   )rK   ÚdatarM   Úkey_outs       r,   r‘   r‘   ü   st   € ô ! ¨CÓ0�,€#€wÜ‡W�WˆT„]Ü
ð ÜŸX™X d›^Ð,Ð,NðPó Qð Qä×Ñ ¤S§[¡[°¸XÔ%FÓG€'Ü	˜7 GÓ	,Ð,r.   r6   c                ó  — t        j                  | j                  t         j                  «      sJ ‚| j                  rt        d| j                  › d�«      ‚t        |t        «      rt        |«      n|f}t        j                  | |¬«      S )Nz?split accepts a single key, but was given a key array of shape r8   ©rI   )r   r:   r;   r<   rG   rE   rI   r9   r   Útupler   Úrandom_split)rK   ÚnumrI   s      r,   Ú_splitrž     sx   € ô 
×	Ñ	˜3Ÿ9™9¤f§o¡oÔ	6Ð6Ð	6Ø‡X‚XÜ
ð Ø ŸY™Y˜KÐ'IðKó Lð Lä" 3¬Ô1Œ%�Œ*¸°v€%Ü	×	Ñ	˜3 eÔ	,Ð,r.   c                óL   — t        d| «      \  }}t        |t        ||«      «      S )aK  Splits a PRNG key into `num` new keys by adding a leading axis.

  Args:
    key: a PRNG key (from ``key``, ``split``, ``fold_in``).
    num: optional, a positive integer (or tuple of integers) indicating
      the number (or shape) of keys to produce. Defaults to 2.

  Returns:
    An array-like object of `num` new PRNG keys.
  Úsplit)rN   rR   rž   )rK   r�   Ú	typed_keyrM   s       r,   r    r      s)   € ô ' w°Ó4Ñ€)ˆWÜ	˜7¤F¨9°cÓ$:Ó	;Ð;r.   c                óÖ   — t        j                  | j                  t         j                  «      sJ ‚t	        j
                  t        j                  | j                  «      }|j                  S r(   )	r   r:   r;   r<   ÚtypingÚcastr   ÚKeyTyr]   )r�   Ú
keys_dtypes     r,   Ú	_key_implr§   )  sD   € Ü	×	Ñ	˜4Ÿ:™:¤v§¡Ô	7Ð7Ð	7Ü�{‰{œ4Ÿ:™: t§z¡zÓ2€*Ø	×	Ñ	Ðr.   c                ó~   — t        | «      }|j                  t        j                  v r|j                  S t	        |«      S r(   )r§   rJ   r   rY   r\   )r�   r3   s     r,   Ú	_key_specr©   .  s-   € Ü	�4‹€$Ø—i‘i¤4§:¡:Ñ-ˆ�‰ÐA´8¸D³>ÐAr.   c                ó:   — t        d| d¬«      \  }}t        |«      S )NÚkey_implTr/   )rN   r©   )r�   Ú
typed_keysÚ_s      r,   r«   r«   2  s   € Ü! *¨dÀ$ÔG�-€*ˆaÜ	�:Ó	Ðr.   c                óŒ   — t        j                  | j                  t         j                  «      sJ ‚t	        j
                  | «      S r(   )r   r:   r;   r<   r   rP   )r�   s    r,   Ú	_key_datar¯   7  s1   € Ü	×	Ñ	˜4Ÿ:™:¤v§¡Ô	7Ð7Ð	7Ü	×	Ñ	˜DÓ	!Ð!r.   c                ó:   — t        d| d¬«      \  } }t        | «      S )z9Recover the bits of key data underlying a PRNG key array.Úkey_dataTr/   )rN   r¯   )r�   r­   s     r,   r±   r±   ;  s   € ä˜J¨¸DÔA�'€$ˆÜ	�4‹Ðr.   c               óF   — t        |«      }t        j                  | |¬«      S )aÿ  Wrap an array of key data bits into a PRNG key array.

  Args:
    key_bits_array: a ``uint32`` array with trailing shape corresponding to
      the key shape of the PRNG implementation specified by ``impl``.
    impl: optional, specifies a PRNG implementation, as in ``random.key``.

  Returns:
    A PRNG key array, whose dtype is a subdtype of ``jax.dtypes.prng_key``
      corresponding to ``impl``, and whose shape equals the leading shape
      of ``key_bits_array.shape`` up to the key bit dimensions.
  r2   )r…   r   r=   )Úkey_bits_arrayr3   Úimpl_objs      r,   Úwrap_key_datarµ   A  s!   € ô ˜tÓ$€(Ü	×	Ñ	˜.¨xÔ	8Ð8r.   c                ó|   — |r:t        j                  |g|¢­Ž }||k7  rd}t        |j                  | ||«      «      ‚y y )Nz·{} parameter shapes must be broadcast-compatible with shape argument, and the result of broadcasting the shapes must equal the shape argument, but got result {} for shape argument {}.)r   Úbroadcast_shapesrA   Úformat)rJ   rI   Úparam_shapesÚshape_Úmsgs        r,   Ú_check_shaper¼   V  sM   € ÙÜ×!Ñ! %Ð7¨,Ò7€FØ�‚ðL€cô �s—z‘z $¨°Ó6Ó7Ð7ð	 ð r.   c                óf   — t        | fi |¤Ž}|€|S t        |||j                  j                  ¬«      S )N)Úout_shardingÚaxes)r   r!   ÚmeshÚexplicit_axes)Úfr¾   Úhoist_kwargsÚf_s       r,   Úmaybe_auto_axesrÅ   `  s<   € ÜˆqÑ!�LÑ!€"ØÐØ€Iä�R lØ&×+Ñ+×9Ñ9ô;ð ;r.   rx   )r¾   c               óš  — t        d| «      \  } }|€t        j                  «       }nt        j                  |«       t        j                  |t
        j                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        |d|«      }|j                  dz  } t        t        |||¬«      | «      S )a±  Sample uniform bits in the form of unsigned integers.

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ``()``.
    dtype: optional, an unsigned integer dtype for the returned values (default
      ``uint64`` if ``jax_enable_x64`` is true, otherwise ``uint32``).

  Returns:
    A random array with the specified shape and dtype.
  Úbitsz<dtype argument to `bits` must be an unsigned int dtype, got é   rT   )rN   r   Údefault_uint_dtypeÚcheck_user_dtype_supportedr:   rH   ÚunsignedintegerrA   Úcanonicalize_dtyper
   Úcanonicalize_shapeÚ"canonicalize_sharding_for_samplersÚitemsizerÅ   rW   )rK   rI   r;   r¾   r­   rU   s         r,   rÇ   rÇ   i  sÇ   € ô" ˜6 3Ó'�&€#€qØ
€]Ü×%Ñ%Ó'�Eä
×%Ñ% eÔ,Ü	×	Ñ	˜5¤"×"4Ñ"4Ô	5Ü
ð Ø!˜7ð$ó %ð %ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü3°LÀ&È%ÓP€,Ø�n‰n˜qÑ €)ð
;Œœ |Ø#,°Eô
;Ø;>ó
@ð @r.   c                óz   — t        | |«      } t        «       }|j                  r| €|st        |t	        «       «      } | S r(   )r"   r   Úare_all_axes_explicitr   ÚP)r¾   rJ   rI   Úcur_meshs       r,   rÎ   rÎ   Š  s:   € Ü& |°TÓ:€,ÜÓ €(Ø×#Ò#¨Ð(<ÁUä  ¬1«3Ó/€LØ	Ðr.   ç        ç      ð?c               óR  — t        d| «      \  } }t        j                  |«       t        j                  |«      }t        |d|«      }t        j                  |t        j                  «      st        d|› �«      ‚t        j                  |«      } t        t        |||¬«      | ||«      S )a„  Sample uniform random values in [minval, maxval) with given shape/dtype.

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).
    minval: optional, a minimum (inclusive) value broadcast-compatible with shape for the range (default 0).
    maxval: optional, a maximum (exclusive) value broadcast-compatible with shape for the range (default 1).

  Returns:
    A random array with the specified shape and dtype.
  Úuniformz7dtype argument to `uniform` must be a float dtype, got ©rI   r;   )rN   r   rÊ   r
   rÍ   rÎ   r:   rH   ÚfloatingrA   rÌ   rÅ   Ú_uniform)rK   rI   r;   ÚminvalÚmaxvalr¾   r­   s          r,   r×   r×   “  s¨   € ô* ˜9 cÓ*�&€#€qÜ×#Ñ# EÔ*Ü
×
!Ñ
! %Ó
(€%Ü3°LÀ)ÈUÓS€,ä	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð Ø!˜7ð$ó %ð %ä
×
#Ñ
# EÓ
*€%ð
3Œœ <Ø$¨Eô
3Ø36¸Àó
Hð Hr.   )é   é   )Ústatic_argnumsc           	     óÈ  — t        d|«       t        j                  |t        j                  «      st        d«      ‚t        j                  ||«      }t        j                  ||«      }t        j                  |t        |«      «      }t        j                  |t        |«      «      }t        j                  |«      }|j                  |j                  }}|dvrt        d|› d�«      ‚|}|dk  rd}t        | ||«      }	t        |   }
||k7  rt        j                  |	|
«      }	t        j                  t        j                   |	t        j"                  ||z
  |
«      «      t        j"                  d|«      j%                  |
«      «      }t        j&                  ||«      t        j"                  d|«      z
  }t        j(                  |t        j*                  |||z
  z  |z   |«      «      S )Nr×   z+uniform only accepts floating point dtypes.©rÈ   é   é    é@   z7uniform only accepts 8-, 16-, 32-, or 64-bit dtypesgot Ú.rÈ   rÕ   )r¼   r   r:   rH   rÙ   rE   r   Úconvert_element_typeÚbroadcast_to_rankÚlenÚfinforÇ   ÚnmantrW   ÚUINT_DTYPESÚ
bitwise_orÚshift_right_logicalÚarrayÚviewÚbitcast_convert_typeÚmaxÚreshape)rK   rÛ   rÜ   rI   r;   ré   Únbitsrê   Úrng_bitsrÇ   Ú
uint_dtypeÚ
float_bitsÚfloatss                r,   rÚ   rÚ   ´  sž  € äˆy˜%Ô Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ÐAÓ
BÐBä×#Ñ# F¨EÓ2€&Ü×#Ñ# F¨EÓ2€&Ü× Ñ  ¬¨U«Ó4€&Ü× Ñ  ¬¨U«Ó4€&ä
�,‰,�uÓ
€%Ø—‘˜UŸ[™[ˆ€%à
�/Ñ!Ü
Ø
AÀ%ÀÈÐJóð ð €(Ø
ˆQ‚YØ€HÜ	�c˜8 UÓ	+€$Ü˜5Ñ!€*Ø�ÒÜ×#Ñ# D¨*Ó5€Dô �~‰~Ü	×Ñ˜d¤B§H¡H¨X¸Ñ-=¸zÓ$JÓKÜ‡h�hˆs�EÓ×Ñ 
Ó+ó€*ô ×#Ñ# J°Ó6¼¿¹À"ÀeÓ9LÑL€&Ü	�‰ØÜ	‡k�k�&˜F V™OÑ,¨vÑ5°uÓ=ó
?ð ?r.   c               óÀ  — t        d| «      \  } }t        j                  |«       t        j                  |«      }t	        j
                  |«      }t        |d|«      }t        j                  |t        j                  «      st        d|› �«      ‚t        j                  j                  �rt        j                  |«      }|}|j                  dk  rÌt        j                   d«      }t#        j$                  |«      j'                  d«      j)                  t+        |j,                  «      t+        |j.                  «      «      }t#        j$                  |«      j'                  d«      j)                  t+        |j,                  «      t+        |j.                  «      dz   «      } t1        t2        |||¬«      | ||«      j'                  |«      S  t1        t2        |||¬«      | ||«      S )aë  Sample uniform random values in [minval, maxval) with given shape/dtype.

  Args:
    key: a PRNG key used as the random key.
    shape: a tuple of nonnegative integers representing the shape.
    minval: int or array of ints broadcast-compatible with ``shape``, a minimum
      (inclusive) value for the range.
    maxval: int or array of ints broadcast-compatible with ``shape``, a maximum
      (exclusive) value for the range.
    dtype: optional, an int dtype for the returned values (default int64 if
      jax_enable_x64 is true, otherwise int32).

  Returns:
    A random array with the specified shape and dtype.

  .. note::

     :func:`randint` uses a modulus-based computation that is known to produce
     slightly biased values in some cases. The magnitude of the bias scales as
     ``(maxval - minval) * ((2 ** nbits ) % (maxval - minval)) / 2 ** nbits``:
     in words, the bias goes to zero when ``(maxval - minval)`` is a power of 2,
     and otherwise the bias will be small whenever ``(maxval - minval)`` is
     small compared to the range of the sampled type.

     To reduce this bias, 8-bit and 16-bit values will always be sampled at 32-bit and
     then cast to the requested type. If you find yourself sampling values for which
     this bias may be problematic, a possible alternative is to sample via uniform::

       def randint_via_uniform(key, shape, minval, maxval, dtype):
         u = jax.random.uniform(key, shape, minval=minval - 0.5, maxval=maxval - 0.5)
         return u.round().astype(dtype)

     But keep in mind this method has its own biases due to floating point rounding
     errors, and in particular there may be some integers in the range
     ``[minval, maxval)`` that are impossible to produce with this approach.
  Úrandintú)randint only accepts integer dtypes, got rã   Úint32é   rØ   )rN   r   rÊ   rÌ   r
   rÍ   rÎ   r:   rH   ÚintegerrE   r	   Úsafer_randintr@   ÚiinforÇ   r;   r•   r–   ÚastypeÚcliprp   Úminrñ   rÅ   Ú_randint)	rK   rI   rÛ   rÜ   r;   r¾   r­   ÚinfoÚdtype_for_samplings	            r,   rù   rù   Ý  sx  € ôV ˜9 cÓ*�&€#€qÜ×#Ñ# EÔ*Ü
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü3°LÀ)ÈUÓS€,ä	×	Ñ	˜5¤"§*¡*Ô	-Ü
Ð?À¸wÐGÓ
HÐHô ×Ñ×ÓÜ�<‰<˜Ó€DØÐØ‡y�y�2‚~äŸ8™8 GÓ,ÐÜ�{‰{˜6Ó"×)Ñ)¨'Ó2×7Ñ7¼¸D¿H¹H»ÄsÈ4Ï8É8Ã}ÓU€fÜ�{‰{˜6Ó"×)Ñ)¨'Ó2×7Ñ7¼¸D¿H¹H»ÄsÈ4Ï8É8Ã}ÐWXÑGXÓY€fàYŒ?œ8 \¸ÐFXÔYØˆV�Vóß#™V E›]ð+ð 
KŒœ <°uÀEÔ	JØ	ˆ6�6ó
ð r.   c           
     óZ  ‡‡— t        d‰t        j                  |«      t        j                  |«      «       t        j                  |t        j
                  «      st        d|› �«      ‚t        d||«       t        j                  |«      }t        j                  |«      }t        j                  |j                  t        j
                  «      s|j                  t        «      }t        j                  |j                  t        j
                  «      s|j                  t        «      }t        j                  |t        t        j                   t        j"                  |«      j$                  |«      |j                  «      «      }t        ||«      }t        ||«      }t        j&                  |t)        ‰«      «      }t        j&                  |t)        ‰«      «      }t        j"                  |«      j*                  Š‰dvrt        d|› �«      ‚t-        | «      \  }}ˆˆfd„} ||«       ||«      }
}	t.        ‰   }t        j0                  ||z
  |«      }t        j2                  ||k  t        j4                  |d«      |«      }t        j2                  |||kD  z  t        j6                  |t        j8                  |d«      «      |«      }t        j:                  t        j8                  |d‰dz  z  «      |«      }t        j:                  t        j<                  ||«      |«      }t        j6                  t        j<                  t        j:                  |	|«      |«      t        j:                  |
|«      «      }t        j:                  ||«      }t        j6                  |t        j0                  ||«      «      S )Nrù   rú   rá   z9randint only accepts 8-, 16-, 32-, or 64-bit dtypes, got c                ó   •— t        | ‰‰«      S r(   )rW   )rK   ró   rI   s    €€r,   Ú<lambda>z_randint.<locals>.<lambda>R  s   ø€ ”l 3¨¨uÔ5r.   rü   r6   )r¼   rH   rI   r   r:   rý   rE   r   r•   r–   r;   r   rp   r   Úgtr   rî   rÿ   rñ   rç   rè   rÇ   rž   rë   ræ   ÚselectÚ	full_likeÚaddÚ_constÚremÚmul)rK   rÛ   rÜ   rI   r;   Úmaxval_out_of_rangeÚk1Úk2ÚrbitsÚhigher_bitsÚ
lower_bitsÚunsigned_dtypeÚspanÚ
multiplierÚrandom_offsetró   s      `           @r,   r  r  !  sº  ù€ ô& ˆy˜%¤§¡¨&Ó!1´2·8±8¸FÓ3CÔDÜ	×	Ñ	˜5¤"§*¡*Ô	-Ü
Ð?À¸wÐGÓ
HÐHä�)˜V VÔ,Ü�;‰;�vÓ€&Ü�;‰;�vÓ€&Ü	×	Ñ	˜6Ÿ<™<¬¯©Ô	4Ø�]‰]œ3Ó€FÜ	×	Ñ	˜6Ÿ<™<¬¯©Ô	4Ø�]‰]œ3Ó€Fô Ÿ™Ø
Ô%¤c§i¡i´·±¸UÓ0C×0GÑ0GÈÓ&OÐQW×Q]ÑQ]Ó^ó`Ðô % V¨UÓ3€&Ü$ V¨UÓ3€&Ü× Ñ  ¬¨U«Ó4€&Ü× Ñ  ¬¨U«Ó4€&Ü
�,‰,�uÓ
×
"Ñ
"€%à
�/Ñ!Ü
ÐOÐPUÈwÐWÓ
XÐXô
 �#‹;�&€"€bÜ
5€%Ù! "›I¡u¨R£yˆz€+ä˜uÑ%€.Ü	×	!Ñ	! &¨6¡/°>Ó	B€$ô 
�‰�F˜fÑ$¤c§m¡m°D¸!Ó&<¸dÓ	C€$ô
 
�‰Ø˜6 F™?Ñ+Ü‡G�GˆD”#—*‘*˜T 1Ó%Ó&Øó

€$ô �w‰w”s—z‘z $¨¨e°q©jÑ(9Ó:¸DÓA€*Ü�w‰w”s—w‘w˜z¨:Ó6¸Ó=€*ä—'‘'œ#Ÿ'™'¤#§'¡'¨+°tÓ"<¸jÓIÜŸ'™' *¨dÓ3ó5€-ä—'‘'˜-¨Ó.€-Ü	�‰�œ×1Ñ1°-ÀÓGÓ	HÐHr.   c               óÞ  ‡‡— t        d| «      \  } }t        d|«       t        ‰t        j                  |«      xs d«      Št        |d«      }t        j                  |«      sst        j                  t        j                  |«      t        j                  «      st        d«      ‚t        j                  t        |d«      Š t        ˆˆfd„|«      | «      S  t        t        |‰|¬«      | |«      S )aô  Returns a randomly permuted array or range.

  Args:
    key: a PRNG key used as the random key.
    x: int or array. If x is an integer, randomly shuffle np.arange(x).
      If x is an array, randomly shuffle its elements.
    axis: int, optional. The axis which x is shuffled along. Default is 0.
    independent: bool, optional. If set to True, each individual vector along
      the given axis is shuffled independently. Default is False.

  Returns:
    A shuffled version of x or array range
  Úpermutationrü   z.x must be an integer or at least 1-dimensionalz&argument x of jax.random.permutation()c                óD   •— t        | t        j                  ‰«      ‰«      S r(   )Ú_shuffler•   Úarange)rK   ÚaxisÚrs    €€r,   r  zpermutation.<locals>.<lambda>Œ  s   ø€ ¤x°´S·Z±ZÀ³]ÀDÔ'Ir.   )r  Úindependent)rN   r   r&   rH   rG   r"   r:   r   r;   rý   rE   r
   Úconcrete_or_errorrp   rÅ   Ú_permutation)rK   r+   r  r!  r¾   r­   r   s     `   @r,   r  r  q  sÐ   ù€ ô& ˜=¨#Ó.�&€#€qÜ�- Ô#Ü	˜4¤§¡¨£¢¨qÓ	1€$Ü& |°]ÓC€,Ü	�‰�ŒÜ�=‰=œŸ™ 1›¤r§z¡zÔ2ÜÐFÓGÐGÜ×Ñœs AÐ'OÓP€Að)Œ?ÔIØ'ó)Ø),ó.ð .ð
FŒÜ�L t¸ô
FØFIÈ1ó
Nð Nr.   c                óÜ   — |st        j                  |«      dk(  rt        | ||«      S t        | t        j                  |j
                  |   «      d«      }t        j                  |||d¬«      S )Nrü   r   T)Úunique_indices)rH   rG   r  r•   r  rI   Útake)rK   r+   r  r!  Úinds        r,   r#  r#  ‘  sV   € Ù”B—G‘G˜A“J !’OÜ�C˜˜DÓ!Ð!Ü�”c—j‘j §¡¨¡Ó/°Ó3€#Ü	�‰�!�S˜$¨tÔ	4Ð4r.   ©r6   c                ó,  — d}t        j                  t        j                  «      j                  }t        j                  |j                  «      st        d|j                  › �«      ‚t        t        j                  |t        j                  t	        d|j                  «      «      z  t        j                  |«      z  «      «      }t        |«      D ]A  }t        | «      \  } }t        |d|j                  «      }t!        j"                  |||«      \  }}ŒC |S )NrÝ   zSshape polymorphism for `permutation` or `shuffle` for arrays of non-constant size: rü   rã   )r   rÿ   rH   r’   rñ   r
   Úis_constant_dimÚsizeÚNotImplementedErrorrp   ÚceilÚlogÚrangerž   rW   rI   r   Úsort_key_val)	rK   r+   r  ÚexponentÚ	uint32maxÚ
num_roundsr­   ÚsubkeyÚ	sort_keyss	            r,   r  r  ˜  sÛ   € ð  €(Ü�l‰lœ2Ÿ9™9Ó%×)Ñ)€)Ü	×	Ñ	˜aŸf™fÔ	%Ü
ð	-Ø-.¯V©V¨Hð	6ó7ð 7ô ”2—7‘7˜8¤b§f¡f¬S°°A·F±F«^Ó&<Ñ<¼r¿v¹vÀiÓ?PÑPÓQÓR€*ä�Ö€aÜ˜“+�K€CˆÜ˜V R¨¯©Ó1€IÜ×Ñ˜I q¨$Ó/�D€A�qð ð
 
€(r.   TÚmodec                óø  — t        d| «      \  } }t        |t        «      st        d|› �«      ‚t	        d|«       t        j                  |«      }|j                  dk(  rt        j                  t        |d«      }	n%t        ||j                  «      }|j                  |   }	t        j                  |«      }
|
dk(  r!t        j                  ||j                   ¬«      S |	dk  rt#        d«      ‚|s|
|	kD  rt#        d|
› d|	› d	�«      ‚|€y|r8t%        | |d|	«      }|j                  dk(  r|nt        j&                  |||«      }�nkt)        d
«      f|z  t)        |
«      fz   }t+        | |j                  dk(  r|	n||«      |   }�n,t	        d|«       t-        |«      \  }|j                  |	fk7  rt#        d|j                  › d|	› d�«      ‚|r`t        j.                  |«      }|d   dt1        | ||j                   ¬«      z
  z  }t        j2                  ||«      j5                  t        «      }n]t7        | |	f|j                   |¬«      t        j8                  |«      z   }t;        j<                  ||
¬«      d   j5                  t        «      }|j                  dk(  r|nt        j&                  |||«      }|j?                  |j                  dk(  r|«      S |j                  d| tA        |«      z   |j                  |dz   d
 z   «      S )aS  Generates a random sample from a given array.

  .. warning::
    If ``p`` has fewer non-zero elements than the requested number of samples,
    as specified in ``shape``, and ``replace=False``, the output of this
    function is ill-defined. Please make sure to use appropriate inputs.

  Args:
    key: a PRNG key used as the random key.
    a : array or int. If an ndarray, a random sample is generated from
      its elements. If an int, the random sample is generated as if a were
      arange(a).
    shape : tuple of ints, optional. Output shape.  If the given shape is,
      e.g., ``(m, n)``, then ``m * n`` samples are drawn.  Default is (),
      in which case a single value is returned.
    replace : boolean.  Whether the sample is with or without replacement.
      Default is True.
    p : 1-D array-like, The probabilities associated with each entry in a.
      If not given the sample assumes a uniform distribution over all
      entries in a.
    axis: int, optional. The axis along which the selection is performed.
      The default, 0, selects by row.
    mode: optional, "high" or "low" for how many bits to use in the gumbel sampler
      when `p is None` and `replace = False`. The default is determined by the
      ``use_high_dynamic_range_gumbel`` config, which defaults to "low". With mode="low",
      in float32 sampling will be biased for choices with probability less than about
      1E-7; with mode="high" this limit is pushed down to about 1E-14. mode="high"
      approximately doubles the cost of sampling.

  Returns:
    An array of shape `shape` containing samples from `a`.
  Úchoicez<shape argument of jax.random.choice must be a sequence, got r   z)The error occurred in jax.random.choice()r“   z4a must be greater than 0 unless no samples are takenz"Cannot take a larger sample (size z) than population (size z) when 'replace=False'NzOp must be None or a 1D vector with the same size as a.shape[axis]. p has shape z and a.shape[axis] is rå   éÿÿÿÿrü   )r;   r6  )Úk)!rN   r9   r   rE   r   r•   r–   rG   r
   r"  rp   r&   rI   ÚmathÚprodÚzerosr;   rA   rù   r&  Úslicer  r    Úcumsumr×   Úsearchsortedr   Úgumbelr.  r   Útop_krò   r›   )rK   ÚarI   ÚreplaceÚpr  r6  r­   ÚarrÚn_inputsÚn_drawsr'  ÚresultÚslicesÚp_arrÚp_cumlr   Úgs                     r,   r8  r8  ¸  sÈ  € ôN ˜8 SÓ)�&€#€qÜ	�Eœ8Ô	$Ü
ð Ø ˜'ð#ó $ð $ä�(˜AÔÜ�‰�A‹€#Ø‡X�X�‚]Ü×%Ñ%¤c¨1Ð.YÓZ�Hä˜T 3§8¡8Ó,€DØ�y‰y˜‰€HÜ�I‰I�eÓ€'Ø�‚\Ü�9‰9�U #§)¡)Ô,Ð,Ø�‚]Ü
ÐKÓ
LÐLÙ	�W˜xÒ'Ü
Ø
,¨W¨Ið 6Ø$˜:Ð%;ð	=ó>ð >ð €YÙÜ�C˜  8Ó,€cØ—h‘h !’m‰s¬¯©°#°s¸DÓ)A‚fä�d“ˆ~ Ñ$¬¨g«Ð'8Ñ8€fÜ˜3¨C¯H©H¸ªM¡¸sÀDÓIÈ&ÑQ‚fä�H˜aÔ Ü# AÓ&�F€EØ‡{�{�x�kÒ!ÜðØŸ™˜Ð%;¸H¸:ÀQðHóIð Iñ Ü�z‰z˜%Ó €fØ
�‰*˜œG C¨°f·l±lÔCÑCÑ
D€aÜ×Ñ˜V QÓ'×.Ñ.¬sÓ3�cô ��x�k¨¯©¸4Ô
@Ä3Ç7Á7È5Ã>Ñ
Q€aÜ�I‰I�a˜7Ô# AÑ&×-Ñ-¬cÓ2€cØ—H‘H ’M‰S¤s§x¡x°°S¸$Ó'?€Fà	�‰ §¡¨Q¢˜ó 
Oð OØŸ	™	 ! DÐ)¬E°%«LÑ8¸3¿9¹9ÀTÈ!ÁVÀWÐ;MÑMó
Oð Or.   c               óN  — t        d| «      \  } }t        j                  |«      }t        |d|«      }t	        j
                  |«       t	        j                  |t        j                  «      st        d|› �«      ‚t	        j                  |«      } t        t        |||¬«      | «      S )aY  Sample standard normal random values with given shape and float dtype.

  The values are returned according to the probability density function:

  .. math::
     f(x) = \frac{1}{\sqrt{2\pi}}e^{-x^2/2}

  on the domain :math:`-\infty < x < \infty`

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  ÚnormalzAdtype argument to `normal` must be a float or complex dtype, got rØ   )rN   r
   rÍ   rÎ   r   rÊ   r:   rH   ÚinexactrA   rÌ   rÅ   Ú_normal)rK   rI   r;   r¾   r­   s        r,   rO  rO    s˜   € ô0 ˜8 SÓ)�&€#€qÜ
×
!Ñ
! %Ó
(€%Ü3°LÀ(ÈEÓR€,Ü×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§*¡*Ô	-Ü
ð Ø!˜7ð$ó %ð %ä
×
#Ñ
# EÓ
*€%Ø	IŒœ ,°eÀ5Ô	IÈ#Ó	NÐNr.   )rü   r6   c                ó¬  — t        j                  |t        j                  «      r¤t        j                  t        j
                  d«      |«      }t        | «      \  }}t        j                  d|«      j                  j                  }t        |||«      j                  |«      }t        |||«      j                  |«      }|d|z  z   |z  S t        | ||«      S )Nr6   r   y              ð?)r   r:   rH   Úcomplexfloatingrî   Úsqrtrž   Úrealr;   Ú_normal_realr   )	rK   rI   r;   Úsqrt2Úkey_reÚkey_imÚ
real_dtypeÚ_reÚ_ims	            r,   rQ  rQ  2  s­   € ä×Ñ�uœb×0Ñ0Ô1Ü�H‰H”R—W‘W˜Q“Z Ó'€Eä˜C“[�N€FˆFÜ—‘˜!˜UÓ#×(Ñ(×.Ñ.€JÜ
�v˜u jÓ
1×
8Ñ
8¸Ó
?€CÜ
�v˜u jÓ
1×
8Ñ
8¸Ó
?€CØ�"�s‘(‰N˜eÑ#Ð#ä˜˜U EÓ*Ð*r.   c                ó„  — t        d|«       t        j                  t        j                  d|«      t        j                  d|«      |¬«      }t        j                  d|«      }t	        | ||||«      }t        j                  t        j                  t        j                  d«      |«      t        j                  |«      «      S )NrO  ç      ð¿rÔ   r“   rÕ   r6   )
r¼   rH   Ú	nextafterrî   r×   r   r  rT  Úlax_specialÚerf_inv)rK   rI   r;   ÚloÚhiÚus         r,   rV  rV  ?  s…   € äˆx˜ÔÜ	‡|�|”B—H‘H˜S %Ó(¬"¯(©(°2°uÓ*=ÀUÔK€"Ü	‡x�x��EÓ€"Üˆc�5˜%  RÓ(€!Ü	�‰”—‘œ"Ÿ'™' !›* eÓ,¬k×.AÑ.AÀ!Ó.DÓ	EÐEr.   c                óT  — t        d| «      \  } }t        j                  |«       t        ||«      \  }}|dvrt	        d«      ‚|€|j
                  }t        j                  |t        j                  «      st	        d|› �«      ‚|�t        j                  |«      }t        | |||||«      S )a0  Sample multivariate normal random values with given mean and covariance.

  The values are returned according to the probability density function:

  .. math::
     f(x;\mu, \Sigma) = (2\pi)^{-k/2} \det(\Sigma)^{-1}e^{-\frac{1}{2}(x - \mu)^T \Sigma^{-1} (x - \mu)}

  where :math:`k` is the dimension, :math:`\mu` is the mean (given by ``mean``) and
  :math:`\Sigma` is the covariance matrix (given by ``cov``).

  Args:
    key: a PRNG key used as the random key.
    mean: a mean vector of shape ``(..., n)``.
    cov: a positive definite covariance matrix of shape ``(..., n, n)``. The
      batch shape ``...`` must be broadcast-compatible with that of ``mean``.
    shape: optional, a tuple of nonnegative integers specifying the result
      batch shape; that is, the prefix of the result shape excluding the last
      axis. Must be broadcast-compatible with ``mean.shape[:-1]`` and
      ``cov.shape[:-2]``. The default (None) produces a result batch shape by
      broadcasting together the batch shapes of ``mean`` and ``cov``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).
    method: optional, a method to compute the factor of ``cov``.
      Must be one of 'svd', 'eigh', and 'cholesky'. Default 'cholesky'. For
      singular covariance matrices, use 'svd' or 'eigh'.
  Returns:
    A random array with the specified dtype and shape given by
    ``shape + mean.shape[-1:]`` if ``shape`` is not None, or else
    ``broadcast_shapes(mean.shape[:-1], cov.shape[:-2]) + mean.shape[-1:]``.
  Úmultivariate_normal>   ÚsvdÚeighÚcholeskyz1method must be one of {'svd', 'eigh', 'cholesky'}zCdtype argument to `multivariate_normal` must be a float dtype, got )rN   r   rÊ   r    rA   r;   r:   rH   rÙ   r
   rÍ   Ú_multivariate_normal)rK   ÚmeanÚcovrI   r;   Úmethodr­   s          r,   rf  rf  H  s²   € ôH Ð0°#Ó6�&€#€qÜ×#Ñ# EÔ*Ü$ T¨3Ó/�)€$ˆØÐ.Ñ.Ü
ÐHÓ
IÐIØ
€]Ø�J‰J€EÜ	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,à
ÐÜ×#Ñ# EÓ*€EÜ	˜c 4¨¨e°U¸FÓ	CÐCr.   )rÝ   rÞ   é   c                óz  — t        j                  |«      dk\  s/d}t        |j                  t        j                  |«      «      «      ‚t        j                  |«      dk\  s/d}t        |j                  t        j                  |«      «      «      ‚|j                  d   }t        j                  |«      dd  ||fk7  r1d}t        |j                  |t        j                  |«      ¬«      «      ‚|€1t        j                  |j                  d d |j                  d d «      }n(t        d	||j                  d d |j                  d d «       |d
k(  r:t        j                  |«      \  }}	}
|t        j                  |	dd d d …f   «      z  }nS|dk(  r9t        j                  |«      \  }}|t        j                  |dd d d …f   «      z  }nt        j                  |«      }t        | ||j                  dd  z   |«      }t        j                   d«      5  |t#        j$                  d||«      z   }d d d «       |S # 1 sw Y   S xY w)Nrü   z@multivariate_normal requires mean.ndim >= 1, got mean.ndim == {}r6   z>multivariate_normal requires cov.ndim >= 2, got cov.ndim == {}r9  éþÿÿÿz^multivariate_normal requires cov.shape == (..., n, n) for n={n}, but got cov.shape == {shape}.)ÚnrI   rO  rg  .rh  Úallowz...ij,...j->...i)rH   rG   rA   r¸   rI   r   r·   r¼   Ú
jnp_linalgrg  r•   rT  rh  ri  rO  r	   Únumpy_rank_promotionÚ
jnp_einsumr   )rK   rk  rl  rI   r;   rm  r»   rq  rd  r}   r­   ÚfactorÚwÚvÚnormal_samplesrI  s                   r,   rj  rj  z  sÙ  € ä	�‰�‹˜!Ò	Ø
L€CÜ
�S—Z‘Z¤§¡¨£Ó.Ó
/Ð/Ü	�‰�‹˜Ò	Ø
J€CÜ
�S—Z‘Z¤§¡¨£Ó-Ó
.Ð.Ø
‡j�j��n€!Ü‡X�Xˆcƒ]�2�3Ð˜A˜q˜6Ò!ð+€Cä
�S—Z‘Z !¬2¯8©8°C«=�ZÓ9Ó
:Ð:à
€]Ü× Ñ  §¡¨C¨R °#·)±)¸C¸R°.ÓA�Eä�˜5 $§*¡*¨S¨b /°3·9±9¸S¸b°>ÔBàˆu‚_Ü—‘˜sÓ#�I€Qˆˆ1Ø”—‘˜!˜C ¢q˜L™/Ó*Ñ*�FØ�ÒÜ�_‰_˜SÓ!�F€QˆØ”—‘˜!˜C ¢q˜L™/Ó*Ñ*�Fä× Ñ  Ó%€FÜ˜#˜u t§z¡z°"°# Ñ6¸Ó>€.Ü×"Ñ" 7Õ+Ø”J×%Ñ%Ð&8¸&À.ÓQÑQ€F÷ ,à	€-÷ ,à	€-ús   ÈH0È0H:c               óT  — |�t        j                  |«      }t        d| «      \  } }t        |d«      }t	        j
                  |«       t	        j                  |t        j                  «      st        d|› �«      ‚t	        j                  |«      } t        t        |||¬«      | ||«      S )a�  Sample truncated standard normal random values with given shape and dtype.

  The values are returned according to the probability density function:

  .. math::
     f(x) \propto e^{-x^2/2}

  on the domain :math:`\rm{lower} < x < \rm{upper}`.

  Args:
    key: a PRNG key used as the random key.
    lower: a float or array of floats representing the lower bound for
      truncation. Must be broadcast-compatible with ``upper``.
    upper: a float or array of floats representing the  upper bound for
      truncation. Must be broadcast-compatible with ``lower``.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``lower`` and ``upper``. The
      default (None) produces a result shape by broadcasting ``lower`` and
      ``upper``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and shape given by ``shape`` if
    ``shape`` is not None, or else by broadcasting ``lower`` and ``upper``.
    Returns values in the open interval ``(lower, upper)``.
  Útruncated_normalz@dtype argument to `truncated_normal` must be a float dtype, got rØ   )r
   rÍ   rN   r"   r   rÊ   r:   rH   rÙ   rA   rÌ   rÅ   Ú_truncated_normal)rK   ÚlowerÚupperrI   r;   r¾   r­   s          r,   r{  r{  ›  s°   € ðB ÐÜ×#Ñ# EÓ*€EÜÐ-¨sÓ3�&€#€qÜ& |Ð5GÓH€,Ü×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%ð
3ŒÔ*¨LØ$¨Eô
3Ø36¸¸uó
Fð Fr.   c                óø  — |€=t        j                  t        j                  |«      t        j                  |«      «      }n4t	        d|t        j                  |«      t        j                  |«      «       t        j
                  t        j                  d«      |«      }t        j                  ||«      }t        j                  ||«      }t        j                  ||z  «      }t        j                  ||z  «      }t        j                  |t        j                  «      st        d«      ‚t        | ||||¬«      }|t        j                  |«      z  }	t!        j"                  |	t        j$                  t        j&                  |«      t        j
                  t        j(                  |¬«      «      t        j$                  t        j&                  |«      t        j
                  t        j(                   |¬«      «      «      S )Nr{  r6   z4truncated_normal only accepts floating point dtypes.©rÛ   rÜ   r“   )r   r·   rH   rI   r¼   rî   rT  ræ   r`  Úerfr   r:   rÙ   rE   r×   ra  r•   r  r_  Ústop_gradientÚinf)
rK   r}  r~  rI   r;   rW  rC  Úbrd  Úouts
             r,   r|  r|  È  sY  € à
€]Ü× Ñ ¤§¡¨%£´"·(±(¸5³/ÓB�EäÐ# U¬B¯H©H°U«O¼R¿X¹XÀe»_ÔMä
�(‰(”2—7‘7˜1“:˜uÓ
%€%Ü
×
"Ñ
" 5¨%Ó
0€%Ü
×
"Ñ
" 5¨%Ó
0€%Ü‡o�o�e˜e‘mÓ$€!Ü‡o�o�e˜e‘mÓ$€!Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ÐJÓ
KÐKÜˆc�5˜%¨°!Ô4€!Ø”×#Ñ# AÓ&Ñ&€#ô 
�‰Ø	Ü	‡m�m”C×%Ñ% eÓ,¬b¯h©h´r·v±vÀUÔ.KÓLÜ	‡m�m”C×%Ñ% eÓ,¬b¯h©h¼¿¹°wÀeÔ.LÓMó
Oð Or.   ç      à?Úlowc                óŽ  — |�t        j                  |«      }|dvrt        d|›d�«      ‚t        d| «      \  } }t	        j
                  t        j                  |«      «      }t	        j                  |t        j                  «      sd}t        |j                  |«      «      ‚t        j                  ||«      }t        | |||¬«      S )aT  Sample Bernoulli random values with given shape and mean.

  The values are distributed according to the probability mass function:

  .. math::
     f(k; p) = p^k(1 - p)^{1 - k}

  where :math:`k \in \{0, 1\}` and :math:`0 \le p \le 1`.

  Args:
    key: a PRNG key used as the random key.
    p: optional, a float or array of floats for the mean of the random
      variables. Must be broadcast-compatible with ``shape``. Default 0.5.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Must be broadcast-compatible with ``p.shape``. The default (None)
      produces a result shape equal to ``p.shape``.
    mode: optional, "high" or "low" for how many bits to use when sampling.
      default='low'. Set to "high" for correct sampling at small values of
      `p`. When sampling in float32, bernoulli samples with mode='low' produce
      incorrect results for p < ~1E-7. mode="high" approximately doubles the
      cost of sampling.

  Returns:
    A random array with boolean dtype and shape given by ``shape`` if ``shape``
    is not None, or else ``p.shape``.
  ©Úhighr‡  z	got mode=z, expected 'high' or 'low'Ú	bernoulliz=bernoulli probability `p` must have a floating dtype, got {}.©r6  )r
   rÍ   rA   rN   r   rÌ   r   r;   r:   rH   rÙ   rE   r¸   ræ   Ú
_bernoulli)rK   rE  rI   r6  r­   r;   r»   s          r,   r‹  r‹  à  s¯   € ð< ÐÜ×#Ñ# EÓ*€EØ	�Ñ Ü
�z˜D˜7Ð"<Ð=Ó
>Ð>Ü˜;¨Ó,�&€#€qÜ
×
#Ñ
#¤C§I¡I¨a£LÓ
1€%Ü	×	Ñ	˜5¤"§+¡+Ô	.Ø
I€CÜ
�C—J‘J˜uÓ%Ó
&Ð&Ü	×Ñ˜q %Ó(€!Ü	�C˜˜E¨Ô	-Ð-r.   )Ústatic_argnamesc                óp  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        j                  |«      }|dk(  rBt        | dg|¢­|«      \  }}|dt        j                  |«      j                   z  z  }|||z
  k  S t        | |t        j                  |«      «      |k  S )Nr‹  rŠ  r6   )	rH   rI   r¼   r   r;   r×   r   ré   rê   )rK   rE  rI   r6  r;   Úu1Úu2s          r,   r�  r�    sŸ   € à
€]ä�H‰H�Q‹K�Eä�˜e¤R§X¡X¨a£[Ô1Ü
�)‰)�A‹,€%à	ˆV‚^Ü�S˜1˜+˜u™+ uÓ-�F€Bˆàˆ!”—‘˜UÓ#×)Ñ)Ð)Ñ
)Ñ)€BØ��B‘‰;Ðä�3˜œsŸy™y¨›|Ó,¨qÑ0Ð0r.   c                ó$  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | ||||«      S )a
  Sample Beta random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x;a,b) \propto x^{a - 1}(1 - x)^{b - 1}

  on the domain :math:`0 \le x \le 1`.

  Args:
    key: a PRNG key used as the random key.
    a: a float or array of floats broadcast-compatible with ``shape``
      representing the first parameter "alpha".
    b: a float or array of floats broadcast-compatible with ``shape``
      representing the second parameter "beta".
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``a`` and ``b``. The default
      (None) produces a result shape by broadcasting ``a`` and ``b``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and shape given by ``shape`` if
    ``shape`` is not None, or else by broadcasting ``a`` and ``b``.
  Úbetaz4dtype argument to `beta` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_beta)rK   rC  r„  rI   r;   r­   s         r,   r“  r“    s‹   € ô< ˜6 3Ó'�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	ˆs�A�q˜% Ó	'Ð'r.   c                ó°  — |€=t        j                  t        j                  |«      t        j                  |«      «      }n4t	        d|t        j                  |«      t        j                  |«      «       t        d| ||«      \  } \  }}t        j                  ||«      }t        j                  ||«      }t        | «      \  }}t        j                  ||«      }t        j                  ||«      }t        ||||«      }t        ||||«      }t        j                  ||«      }	t        j                  ||	z
  «      }
t        j                  ||	z
  «      }|
|
|z   z  S )Nr“  zjax.random.beta)r   r·   rH   rI   r¼   Úrandom_insert_pvaryræ   rž   r•   Úbroadcast_toÚloggammarñ   Úexp)rK   rC  r„  rI   r;   Úkey_aÚkey_bÚlog_gamma_aÚlog_gamma_bÚlog_maxÚgamma_a_scaledÚgamma_b_scaleds               r,   r”  r”  F  s  € Ø
€]Ü× Ñ ¤§¡¨!£¬b¯h©h°q«kÓ:�Eä�˜¤§¡¨£¬R¯X©X°a«[Ô9ä#Ð$5°s¸A¸qÓA�+€#�vˆˆ1ä	×Ñ˜q %Ó(€!Ü	×Ñ˜q %Ó(€!Ü˜“�,€%ˆÜ	×Ñ�q˜%Ó €!Ü	×Ñ�q˜%Ó €!Ü˜  5¨%Ó0€+Ü˜  5¨%Ó0€+ä�G‰G�K Ó-€'Ü—7‘7˜;¨Ñ0Ó1€.Ü—7‘7˜;¨Ñ0Ó1€.Ø	˜>¨NÑ:Ñ	;Ð;r.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||«      S )aK  Sample Cauchy random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x) \propto \frac{1}{x^2 + 1}

  on the domain :math:`-\infty < x < \infty`

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  Úcauchyz6dtype argument to `cauchy` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_cauchy©rK   rI   r;   r­   s       r,   r¢  r¢  \  s�   € ô, ˜8 SÓ)�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	��e˜UÓ	#Ð#r.   c                ó^  — t        d|«       t        | ||t        j                  |«      j                  d¬«      }t        j                  |t        j                  «      }t        j                  t        j                  |t        j                  |t        j                  |d«      «      «      «      S )Nr¢  rÕ   r€  r†  )r¼   r×   r   ré   Úepsr   r  rH   ÚpiÚtanr  Úsub)rK   rI   r;   rd  r§  s        r,   r£  r£  {  sq   € äˆx˜ÔÜˆc�5˜%¬¯©°UÓ(;×(?Ñ(?ÈÔK€!Ü
‡z�z�!”R—U‘UÓ€"Ü	�‰”—‘˜œSŸW™W Q¬¯
©
°1°cÓ(:Ó;Ó<Ó	=Ð=r.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )aŠ  Sample Dirichlet random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(\{x_i\}; \{\alpha_i\}) \propto \prod_{i=1}^k x_i^{\alpha_i - 1}

  Where :math:`k` is the dimension, and :math:`\{x_i\}` satisfies

  .. math::
     \sum_{i=1}^k x_i = 1

  and :math:`0 \le x_i \le 1` for all :math:`x_i`.

  Args:
    key: a PRNG key used as the random key.
    alpha: an array of shape ``(..., n)`` used as the concentration
      parameter of the random variables.
    shape: optional, a tuple of nonnegative integers specifying the result
      batch shape; that is, the prefix of the result shape excluding the last
      element of value ``n``. Must be broadcast-compatible with
      ``alpha.shape[:-1]``. The default (None) produces a result shape equal to
      ``alpha.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and shape given by
    ``shape + (alpha.shape[-1],)`` if ``shape`` is not None, or else
    ``alpha.shape``.
  Ú	dirichletz9dtype argument to `dirichlet` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú
_dirichlet)rK   ÚalpharI   r;   r­   s        r,   r«  r«  ƒ  sŠ   € ôF ˜;¨Ó,�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�C˜  uÓ	-Ð-r.   )r6   rÝ   c                ó¤  — ddl m} t        j                  |«      dk\  s/d}t	        |j                  t        j                  |«      «      «      ‚|€t        j                  |«      d d }n#t        d|t        j                  |«      d d «       t        j                  ||«      }t        | ||t        j                  |«      dd  z   |«      } ||d«      S )Nr   )Úsoftmaxrü   z8dirichlet requires alpha.ndim >= 1, got alpha.ndim == {}r9  r«  )Újax._src.nn.functionsr¯  rH   rG   rA   r¸   rI   r¼   r   ræ   r˜  )rK   r­  rI   r;   r¯  r»   Úlog_gamma_sampless          r,   r¬  r¬  °  s±   € å+ä	�‰�‹˜1Ò	Ø
D€CÜ
�S—Z‘Z¤§¡¨£Ó/Ó
0Ð0à
€]Ü�H‰H�U‹O˜C˜RÐ �Eä�˜e¤R§X¡X¨e£_°S°bÐ%9Ô:ä
×
"Ñ
" 5¨%Ó
0€%ô ˜s E¨5´2·8±8¸E³?À2À3Ð3GÑ+GÈÓOÐÙ	Ð" BÓ	'Ð'r.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||«      S )a<  Sample Exponential random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x) = e^{-x}

  on the domain :math:`0 \le x < \infty`.

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  Úexponentialz;dtype argument to `exponential` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_exponentialr¤  s       r,   r³  r³  Ä  s�   € ô, ˜=¨#Ó.�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�c˜5 %Ó	(Ð(r.   c                óª   — t        d|«       t        | ||«      }t        j                  t        j                  t        j                  |«      «      «      S )Nr³  )r¼   r×   r   ÚnegÚlog1p©rK   rI   r;   rd  s       r,   r´  r´  ã  s:   € äˆ}˜eÔ$Üˆc�5˜%Ó €!ä	�‰”—‘œ3Ÿ7™7 1›:Ó&Ó	'Ð'r.   c                ó6  ‡‡‡‡‡‡‡‡— t        j                  |d«      Št        j                  |d«      Št        j                  |d«      }t        j                  |d«      Št        j                  |d«      Št        j                  |d«      }t        j                  |d«      Št        j                  |«      Št        j                  ‰t        t        j                  |«      j                  «      «      Št        j                  ‰t        t        j                  |«      j                  «      «      Št        j                  ‰t        t        j                  |«      j                  «      «      Št        j                  |t        t        j                  |«      j                  «      «      }t        j                  |‰«      }|}t        j                  ||t        j                  |‰«      «      }t        j                  ||«      Št        j                  |t        j                  ‰«      «      Šˆˆˆˆfd„}ˆˆˆˆˆfd	„}t        | «      \  } }	t        j                   ||| ‰‰|f«      \  }
}
}}
|r¶t        j"                  t%        |	d
‰¬«      «      }t        j                  ||dk(  z  ‰t        j&                  |t        j                  ‰|«      «      «      }t        j                  t        j                  t        j(                  ‰«      t        j(                  |«      «      |«      S dt+        |	d
‰¬«      z
  }t        j                  |‰t        j,                  |t        j                  ‰|«      «      «      }t        j&                  t        j&                  ‰|«      |«      S )Nr   rü   r6   r9  r†  gUUUUUUÕ?gmÅþ²{ò ?c                ó  •— | \  }}}}t        j                  t        j                  |t        j                  ‰t        j                  ‰	t        j                  ||«      «      «      «      t        j                  t        j
                  |«      t        j                  t        j                  |‰«      t        j                  ‰t        j                  t        j                  ‰|«      t        j
                  |«      «      «      «      «      «      }|S r(   )r   Úbitwise_andÚger©  r  r.  r  )
ÚkXVUr­   ÚXÚVÚUÚcondÚdÚoneÚone_over_twoÚsqueeze_consts
         €€€€r,   Ú_cond_fnz_gamma_one.<locals>._cond_fn  s¸   ø€ Ø�J€A€qˆ!ˆQô �?‰?Ü�‰ˆq”#—'‘'˜#œsŸw™w }´c·g±g¸aÀ³mÓDÓEÓFÜ�‰Œs�w‰w�q‹zœ3Ÿ7™7¤3§7¡7¨1¨lÓ#;Ü#&§7¡7¨1¬c¯g©g´c·g±g¸cÀ1³oÜ69·g±g¸a³jó/Bó $CóDó 	EóF€Dð
 €Kr.   c                ó&  •— ˆˆˆfd„}| d   }t        |d«      \  }}}t        j                  ˆfd„||‰‰f«      \  }}}t        j                  ||«      }t        j                  t        j                  ||«      |«      }	t        |d‰¬«      }
|||	|
fS )Nc                ó¤   •— | d   }t        |«      \  }}t        |d‰¬«      }t        j                  ‰t        j                  |‰«      «      }|||fS )Nr   rx   r“   )rž   rO  r   r  r  )ÚkxvrK   r4  r+   rx  Úcr;   rÃ  s        €€€r,   Ú	_next_kxvz/_gamma_one.<locals>._body_fn.<locals>._next_kxv  sM   ø€ Ø�‰F€cÜ˜3“K�k€cˆ6Ü
�˜ 5Ô
)€aÜ
�'‰'�#”s—w‘w˜q !“}Ó
%€aØ�!�QˆYÐr.   r   rÝ   c                ó6   •— t        j                  | d   ‰«      S )Nr6   )r   Úle)rÉ  Úzeros    €r,   r  z._gamma_one.<locals>._body_fn.<locals>.<lambda>#  s   ø€ ´c·f±f¸SÀ¹VÀTÔ6Jr.   rx   r“   )rž   Úlax_control_flowÚ
while_loopr   r  r×   )r½  rË  rK   Úx_keyÚU_keyr­   r+   rx  r¾  r¿  rÀ  rÊ  r;   Ú	minus_onerÃ  rÎ  s              €€€€€r,   Ú_body_fnz_gamma_one.<locals>._body_fn  s�   ø€ öð ˆq‰'€CÜ˜s A›Ñ€Cˆ�Ü×)Ñ)Ó*JØ*3°e¸TÀ9Ð5MóO�G€A€qˆ!ä�‰��1‹€AÜ�‰”—‘˜˜1“˜qÓ!€AÜ��r Ô'€AØ��1�aˆ<Ðr.   rx   r“   )r   r  r;   r
   Úpvaryr›   ÚtypeofÚvmar¼  r
  r  r©  ÚdivrT  rž   rÏ  rÐ  r¶  r³  r  r.  r×   Úpow)rK   r­  Ú	log_spaceÚtwoÚone_over_threeÚ
boost_maskÚ
alpha_origrÆ  rÔ  r4  r­   r¿  Úlog_samplesÚ	log_boostÚsamplesÚboostrÊ  rÂ  r;   rÓ  rÃ  rÄ  rÅ  rÎ  s                   @@@@@@@@r,   Ú
_gamma_onerã  ë  s‹  ÿ€ ô 
�‰�E˜1Ó	€$Ü�
‰
�5˜!Ó€#Ü�
‰
�5˜!Ó€#Ü�j‰j˜ Ó#€)Ü—‘˜E 3Ó'€,Ü—:‘:˜e WÓ-€.Ü—*‘*˜U FÓ+€-Ü
�)‰)�EÓ
€%ä	�‰�Dœ%¤§¡¨EÓ 2× 6Ñ 6Ó7Ó	8€$Ü�
‰
�3œœdŸk™k¨%Ó0×4Ñ4Ó5Ó6€#Ü�j‰j˜¤E¬$¯+©+°eÓ*<×*@Ñ*@Ó$AÓB€)Ü�
‰
�3œœdŸk™k¨%Ó0×4Ñ4Ó5Ó6€#ô �v‰v�e˜SÓ!€*Ø€*Ü
�*‰*�Z ¬¯©°°sÓ(;Ó
<€%ä	‡g�gˆe�^Ó$€!Ü	‡g�gˆnœcŸh™h q›kÓ*€!÷
÷ð ô$ �s“�+€#€vÜ×*Ñ*Ø�˜3  c¨3Ð/ó1�*€!€Qˆˆ1áÜ—'‘'œ+ f¨b¸Ô>Ó?€KÜ—
‘
˜:¨¸Ñ)9Ñ:¸DÜŸ7™7 ;´·±¸¸ZÓ0HÓIóK€Iä�7‰7”3—7‘7œ3Ÿ7™7 1›:¤s§w¡w¨q£zÓ2°IÓ>Ð>à”'˜& "¨EÔ2Ñ2€GÜ�J‰J�z 3Ü—w‘w˜w¬¯©°°ZÓ(@ÓAóC€Eä�7‰7”3—7‘7˜1˜a“= %Ó(Ð(r.   c               ó”  ‡— t        j                  | d«      }t        j                  |d«      }|r—t        j                  |«      }t        j                  | d«      }t        j
                  |t        j                  |j                  «      j                  «      }t        j                  t        j                  ||«      ||«      }d„ Šnt        j                  Št        j                  «       j                   dk(  rt#        j$                  ˆfd„||f«      }n t'        ‰«      ||«      }|j                  t)        j*                  |«      «      S )Nr9  r   c                ó4   — t        j                  | |«      |z  S r(   )r`  Úrandom_gamma_grad)r­  Úsamples     r,   r  z_gamma_grad.<locals>.<lambda>E  s   € Ü×%Ñ% e¨VÓ4°vÒ=r.   Úcpuc                ó   •—  ‰| Ž S r(   rx   )ÚargsÚ
gamma_grads    €r,   r  z_gamma_grad.<locals>.<lambda>J  s
   ø€ ©j¸$Ñ.?r.   )r•   rò   r   r™  r  r  r   ré   r;   Útinyr
  Úeqr`  ræ  r   Úget_backendÚplatformrÏ  Úmapr   rH   rI   )	rç  rC  rÚ  rá  ÚalphasrÎ  rì  Úgradsrë  s	           @r,   Ú_gamma_gradró  :  só   ø€ Ü�K‰K˜ Ó#€'Ü�;‰;�q˜"Ó€&Ùô �g‰g�gÓ€GÜ�:‰:�f˜aÓ €DÜ�=‰=˜¤&§,¡,¨w¯}©}Ó"=×"BÑ"BÓC€DÜ�j‰jœŸ™ ¨Ó.°°gÓ>€Gñ?�Jô ×.Ñ.€JÜ×ÑÓ×&Ñ&¨%Ò/Ü× Ñ Ó!?À&È'ÐARÓS�EàŒD�Ó˜V WÓ-€EØ	�‰”r—x‘x “{Ó	#Ð#r.   )Úuse_vmapc               óâ  ‡— t        j                  |«      }t        j                  || j                  d  «      }| j                  «       } t        t        d¬«      ||«      }|j                  «       }|j                  «       }|r=t        | «      t        j                  u r" t        t        t        ‰¬«      «      ||«      }nt        j                  ˆfd„||f«      }t        j                   ||«      S )N)r   N)Úin_axes©rÚ  c                ó   •— t        | d‰iŽS )NrÚ  )rã  )rê  rÚ  s    €r,   r  z_gamma_impl.<locals>.<lambda>\  s   ø€ ”Z Ð;°Ò;r.   )rH   rI   r;  r<  rG   Úflattenr   rž   r§   r   Úthreefry_prng_implr   rã  rÏ  rð  r•   rò   )	rK   rC  rÚ  rô  Úa_shapeÚsplit_countr�   rñ  rá  s	     `      r,   Ú_gamma_implrý  O  sº   ø€ ä�H‰H�Q‹K€'Ü—	‘	˜' #§(¡( )Ð,Ó-€+Ø	�‰‹€$Ø	(ŒŒf˜iÔ	(¨¨{Ó	;€$Ø	�‰‹€$Ø�9‰9‹;€&á”)˜C“.¤D×$;Ñ$;Ñ;Ø<Œd”7œ:°Ô;Ó<¸TÀ6ÓJ�Gä×"Ñ"Û;¸dÀF¸^óM€Gô 
�‰�W˜gÓ	&Ð&r.   c               óÞ   — | \  }}|\  }}t        d„ t        | |«      D «       «      }t        j                  |||«      }t        j                  |||«      }t        j                  |||¬«      dfS )Nc              3  óF   K  — | ]  \  }}|€Œ	|j                   |   –— Œ y ­wr(   rš   )r|   r„   Úis      r,   r~   z'_gamma_batching_rule.<locals>.<genexpr>c  s&   è ø€ ð MÙ:‘T�Q˜¸a¹m€a‡g�gˆa…jÑ:ùs   ‚
!�!r÷  r   )ÚnextÚzipr   Úbdim_at_frontÚrandom_gamma_pÚbind)Úbatched_argsÚ
batch_dimsrÚ  r:  rC  ÚbkÚbar+  s           r,   Ú_gamma_batching_ruler
  `  sz   € Ø	�$€!€QØ�&€"€bÜ	ñ MÜ  ¨zÔ:óMó 
M€$ä×Ñ˜Q  DÓ)€!Ü×Ñ˜Q  DÓ)€!Ü	×	Ñ	˜Q ¨YÐ	Ó	7¸Ð	:Ð:r.   Úrandom_gammac                ó4   — t        j                  d| |«       |S )Nr  )r
   Ústandard_vma_rule)rK   rC  r­   s      r,   Ú_random_gamma_abstract_evalr  l  s   € Ü×Ñ˜¨¨aÔ0Ø	
€(r.   c                ó"   — | t        ||fi |¤Žz  S r(   )ró  )ÚtangentÚansrK   rC  Úkwdss        r,   r  r  s  s   € ¨´;¸sÀAÑ3NÈÑ3NÒ)Nr.   )Úmultiple_resultsrè  )rï  c                ó$  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||¬«      S )a  Sample Gamma random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x;a) \propto x^{a - 1} e^{-x}

  on the domain :math:`0 \le x < \infty`, with :math:`a > 0`.

  This is the standard gamma density, with a unit scale/rate parameter.
  Dividing the sample output by the rate is equivalent to sampling from
  *gamma(a, rate)*, and multiplying the sample output by the scale is equivalent
  to sampling from *gamma(a, scale)*.

  Args:
    key: a PRNG key used as the random key.
    a: a float or array of floats broadcast-compatible with ``shape``
      representing the parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``a``. The default (None)
      produces a result shape equal to ``a.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``a.shape``.

  See Also:
    loggamma : sample gamma values in log-space, which can provide improved
      accuracy for small values of ``a``.
  Úgammaú5dtype argument to `gamma` must be a float dtype, got rØ   ©rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_gamma©rK   rC  rI   r;   r­   s        r,   r  r  |  sŠ   € ôH ˜7 CÓ(�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	��Q˜e¨5Ô	1Ð1r.   c                ó&  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||d¬«      S )aV  Sample log-gamma random values with given shape and float dtype.

  This function is implemented such that the following will hold for a
  dtype-appropriate tolerance::

    np.testing.assert_allclose(jnp.exp(loggamma(*args)), gamma(*args), rtol=rtol)

  The benefit of log-gamma is that for samples very close to zero (which occur frequently
  when `a << 1`) sampling in log space provides better precision.

  Args:
    key: a PRNG key used as the random key.
    a: a float or array of floats broadcast-compatible with ``shape``
      representing the parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``a``. The default (None)
      produces a result shape equal to ``a.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``a.shape``.

  See Also:
    gamma : standard gamma sampler.
  r˜  r  T©rI   r;   rÚ  r  r  s        r,   r˜  r˜  «  s‹   € ô> ˜: sÓ+�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	��Q˜e¨5¸DÔ	AÐAr.   r  c                óN  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        j                  ||«      }t        j                  |«      |k7  rt        j                  ||«      }t        d| |«      \  } \  }t        j                  | ||¬«      S )Nr  r÷  )
rH   rI   r¼   r   ræ   r•   r—  r–  r  r  )rK   rC  rI   r;   rÚ  s        r,   r  r  Õ  sˆ   € à
€]Ü�H‰H�Q‹K�Eä�˜%¤§¡¨!£Ô-ä	×Ñ˜q %Ó(€!Ü‡X�Xˆaƒ[�EÒÜ×Ñ˜˜EÓ"€AÜ! '¨3°Ó2�)€#�tˆÜ	×	Ñ	˜S !¨yÐ	Ó	9Ð9r.   )r6   rÝ   rÞ   c                ó   ‡‡‡— ˆˆfd„}ˆˆfd„}t        j                  ‰d|‰«      }t        j                  ‰dt        j                  ‰«      }t	        j
                  ||d|| |f«      d   }	|	dz
  j                  |«      S )Nc                óÞ   •— | \  }}}}t        |«      \  }}t        j                  |‰ kD  |dz   |«      }t        |‰t        j
                  «      }|dz   |||t        j                  |«      z   fS ©Nrü   )rž   r   r
  r×   rH   Úfloat32r•   r.  )	Úcarryr   r:  ÚrngÚlog_prodr4  rd  ÚlamrI   s	          €€r,   Úbody_fnz_poisson_knuth.<locals>.body_fné  sl   ø€ ØÑ€A€qˆ#ˆxÜ˜“+�K€CˆÜ�
‰
�8˜s˜d‘? A¨¡E¨1Ó-€AÜ�˜œrŸz™zÓ*€AØˆq‰5�!�S˜(¤S§W¡W¨Q£ZÑ/Ð/Ð/r.   c                óL   •— | d   | d   }}|‰ kD  j                  «       |‰k  z  S )Nr   rÝ   ©Úany)r!  r   r#  r$  Ú	max_iterss      €€r,   Úcond_fnz_poisson_knuth.<locals>.cond_fnð  s2   ø€ Ø˜‘(˜E !™H€x€AØ˜�t‰O× Ñ Ó" a¨)¡mÑ4Ð4r.   r   rü   )r   r  rH   r   rÏ  rÐ  r   )
rK   r$  rI   r;   r)  r%  r*  Úk_initÚlog_rate_initr:  s
    `` `     r,   Ú_poisson_knuthr-  ã  sq   ú€ õ0õ5ô �=‰=˜˜a ¨Ó.€&Ü—-‘-  Q¬¯
©
°EÓ:€-Ü×!Ñ! '¨7°Q¸ÀÀ]Ð4SÓTÐUVÑW€!Ø
ˆa‰%�‰˜Ó	Ðr.   c                óÆ  ‡‡‡‡
‡‡‡‡— t        j                  ‰«      Šddt        j                  ‰«      z  z   Šdd‰z  z   Š
dd‰dz
  z  z   Šdd	‰d
z
  z  z
  Šˆ
ˆˆˆˆˆˆfd„}ˆfd„}t        j                  ‰d‰j                  ‰«      }t        j                  ‰dt        j                  d«      ‰«      }t        j                  ||d||| f«      d   }	|	j                  |«      S )Ng˜nƒÀÊí?ç=
×£p=@gh‘í|?5®¿g[¶Ö	m™?g$—ÿ�~ûñ?grŠŽäòò?g333333@grùé·¯í?gB>èÙ¬ú@r6   c                ó(  •— | \  }}}}t        |d«      \  }}}t        |‰‰j                  «      dz
  }t        |‰‰j                  «      }dt        |«      z
  }	t	        j
                  d‰z  |	z  ‰z   |z  ‰z   dz   «      }
t	        j                  |‰z  ‰|	|	z  z  ‰z   z  «      }‰ |
‰z  z   t        j                  |
dz   «      z
  }|	dk\  |‰k  z  }|
dk  |	dk  ||	kD  z  z  }||k  }|| |z  z  }t	        j                  ||
|«      }||z  }|dz   |||fS )	NrÝ   r†  r6   g…ëQ¸…Û?rü   çìQ¸…ë±?r   g9´Èv¾ŸŠ?)
rž   r×   r;   Úabsr   Úfloorr.  r`  Úlgammar
  )r!  r   Úk_outÚacceptedrK   Úsubkey_0Úsubkey_1rd  rx  Ú	u_shiftedr:  r}   r„   Úaccept1ÚrejectÚaccept2ÚacceptrC  r„  Ú	inv_alphar$  Úlog_lamrI   Úv_rs                    €€€€€€€r,   r%  z#_poisson_rejection.<locals>.body_fn  sF  ø€ Ø#Ñ€A€uˆh˜Ü$ S¨!›nÑ€Cˆ�8ä�˜% §¡Ó+¨cÑ1€AÜ�˜% §¡Ó+€AØ”c˜!“f‘€Iä�	‰	�1�q‘5˜9Ñ$ qÑ(¨AÑ-°Ñ3°dÑ:Ó;€AÜ�‰��I‘  i°)Ñ&;Ñ!<¸qÑ!@ÑAÓB€AØ	ˆˆq�7‰{Ñœ[×/Ñ/°°A±Ó6Ñ6€Aà˜DÑ  Q¨#¡XÑ.€GØ�!‰e˜ UÑ*¨q°9©}Ñ=Ñ>€FØ�1‰f€GØ˜˜ 'Ñ)Ñ*€Fä�J‰J�v˜q %Ó(€EØ�Ñ€Hàˆq‰5�%˜ 3Ð&Ð&r.   c                ó@   •— | \  }}}}| j                  «       |‰k  z  S r(   r'  )r!  r   r5  r6  rK   r)  s        €r,   r*  z#_poisson_rejection.<locals>.cond_fn  s)   ø€ Ø#Ñ€A€uˆh˜ØˆI�?‰?Ó  I¡Ñ.Ð.r.   r9  Frq   r   rü   )	r   r.  rT  r  r;   rH   rÏ  rÐ  r   )rK   r$  rI   r;   r)  r%  r*  r+  r6  r:  rC  r„  r>  r?  r@  s    `` `     @@@@@r,   Ú_poisson_rejectionrB  ú  sÔ   ÿ€ ô
 �G‰G�C‹L€'Øˆd”S—X‘X˜c“]Ñ"Ñ"€!Øˆw˜‰{Ñ€!Ø�v  S¡Ñ)Ñ)€)Ø�˜1˜q™5Ñ!Ñ!€#÷'ò 'ô,/ô �=‰=˜˜b #§)¡)¨UÓ3€&Ü�]‰]˜3 ¤r§x¡x°Ó'7¸Ó?€(Ü×!Ñ! '¨7°Q¸ÀÈ#Ð4NÓOÐPQÑR€!Ø	
�‰�%‹Ðr.   c                óè  — t        |«      |dk  z  }t        j                  ||t        j                  |d«      «      }t        j                  |t        j                  |d«      |«      }|j	                  t        j                  |«      j                  «      }t        j                  |t        | ||||«      t        | ||||«      «      }t        j                  |dk(  t        j                  |«      |«      S )Né
   rÔ   g     jø@r   )r-   r   r
  r  rF   r   rÿ   rñ   r-  rB  r•   Ú
zeros_like)	rK   r$  rI   r;   Ú	use_knuthÚ	lam_knuthÚlam_rejectionr)  rI  s	            r,   Ú_poissonrI  %  sÂ   € ô �S‹k˜S 2™XÑ&€)Ü�j‰j˜ C¬¯©°s¸CÓ)@ÓA€)ô —*‘*˜Y¬¯©°c¸3Ó(?ÀÓE€-Ø�j‰jœŸ™ eÓ,×0Ñ0Ó1€)Ü�:‰:ØÜ�3˜	 5¨%°Ó;Ü�s˜M¨5°%¸ÓCó€&ô
 
�‰�C˜1‘HœcŸn™n¨VÓ4°fÓ	=Ð=r.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  t
        j                  | j                  «      }|j                  }|t
        j                  urt        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }nt        j                  |«      }t!        j"                  ||«      }t%        j&                  |t        j(                  «      }t+        | |||«      S )a\  Sample Poisson random values with given shape and integer dtype.

  The values are distributed according to the probability mass function:

  .. math::
     f(k; \lambda) = \frac{\lambda^k e^{-\lambda}}{k!}

  Where `k` is a non-negative integer and :math:`\lambda > 0`.

  Args:
    key: a PRNG key used as the random key.
    lam: rate parameter (mean of the distribution), must be >= 0. Must be broadcast-compatible with ``shape``
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default (None) produces a result shape equal to ``lam.shape``.
    dtype: optional, a integer dtype for the returned values (default int64 if
      jax_enable_x64 is true, otherwise int32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape is not None, or else by ``lam.shape``.
  Úpoissonz<`poisson` is only implemented for the threefry2x32 RNG, not )rN   r   rÊ   r£   r¤   r   r¥   r;   r]   rú  r,  rÌ   r
   rÍ   rH   rI   r•   r—  r   ræ   r   rI  )rK   r$  rI   r;   r­   r¦   r«   s          r,   rK  rK  :  sß   € ô2 ˜9 cÓ*�&€#€qÜ×#Ñ# EÔ*ô �{‰{œ4Ÿ:™: s§y¡yÓ1€*Ø×Ñ€(Ø”T×,Ñ,Ñ,Ü
ð	Øˆjð	óð ô ×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*�Eä�H‰H�S‹M€EÜ×Ñ˜˜eÓ$€#Ü× Ñ  ¤b§j¡jÓ1€#Ü	�#�s˜E 5Ó	)Ð)r.   c               ó´  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }|€t        j                  j                  rdnd}|dvrt        d|z  «      ‚t        |d|«      } t        t        ||||¬«      | «      S )a¼  Sample Gumbel random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x) = e^{-(x + e^{-x})}

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).
    mode: optional, "high" or "low" for how many bits to use when sampling.
      The default is determined by the ``use_high_dynamic_range_gumbel`` config,
      which defaults to "low". When drawing float32 samples, with mode="low" the
      uniform resolution is such that the largest possible gumbel logit is ~16;
      with mode="high" this is increased to ~32, at approximately double the
      computational cost.

  Returns:
    A random array with the specified shape and dtype.
  rA  z6dtype argument to `gumbel` must be a float dtype, got rŠ  r‡  r‰  z*Must provide valid mode for gumbel got: %s)rI   r;   r6  )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   r	   Úuse_high_dynamic_range_gumbelr@   rÎ   rÅ   Ú_gumbel)rK   rI   r;   r6  r¾   r­   s         r,   rA  rA  g  s×   € ô: ˜8 SÓ)�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ø	€\Ü×9Ñ9×?Ò?‰6ÀU€DØ	�Ñ Ü
ÐAÀDÑHÓ
IÐIÜ3°LÀ(ÈEÓR€,ð
$Œœ ,°eÀ5Ø"ô
$Ø$'ó
)ð )r.   )rü   r6   rÝ   c                óÊ  — t        d|«       t        j                  |«      }|dk(  r|t        | ddd|z   |¬«      \  }}t	        j
                  |dk\  ||d|j                   z  |z  z   |j                  z   «      }t	        j                  t	        j                  | «       «       S t	        j                  t	        j                  t        | |j                  d||¬«      «       «       S )	NrA  rŠ  rÔ   rÕ   r(  )rÛ   rÜ   rI   r;   r†  r6   )
r¼   r   ré   rÚ   r•   Úwhererê   rì  r.  r·  )rK   rI   r;   r6  r  rŠ  r‡  r+   s           r,   rN  rN  “  sÔ   € äˆx˜ÔÜ	�‰�eÓ	€$Ø	ˆV‚^Ü˜ R°Ø# e™|°5ô:�I€Dˆ#ô 	�	‰	�$˜#‘+˜tØˆq�d—j‘j�MÑ! CÑ'Ñ'¨$¯)©)Ñ3ó	5€Aä�G‰G”S—Y‘Y ˜r“]�NÓ#Ð#Ð#ä�G‰G”S—W‘WÜ�˜TŸY™Y¨r¸ÀeÔLóNð Nó Oð Oð Or.   c                ó  — t        d| «      \  } }t        d|«       t        j                  |«      }t	        t        j                  |j                  |«      «      }|€|}n"t        j                  |«      }t        d||«       |dt        |«      t        |«      z
   }	|rÚ|dk\  r|t        |j                  «      z  }t        |t        |«      t        |«      z
  d «      }
|
j                  |t        |j                  «      z  |j                  |   «       t        j                  t        | g |	¢|
¢­|j                   |¬«      t#        j$                  |t	        t'        t        |	«      «      «      «      z   |¬«      S |t        | |j                  |j                   |¬«      z  }t)        j*                  |	«      }||j                  |   kD  rt-        d|› d|j                  |   › d�«      ‚t#        j.                  t        j0                  ||d	«      |«      \  }}|j                  ||fz   k(  sJ ‚||	|z   k(  sJ ‚|j2                  d
z
  gt'        |j2                  d
z
  «      ¢­}t#        j4                  |||«      }|j                  |k(  sJ ‚|S )aü  Sample random values from categorical distributions.

  Sampling with replacement uses the Gumbel max trick. Sampling without replacement uses
  the Gumbel top-k trick. See [1] for reference.

  Args:
    key: a PRNG key used as the random key.
    logits: Unnormalized log probabilities of the categorical distribution(s) to sample from,
      so that `softmax(logits, axis)` gives the corresponding probabilities.
    axis: Axis along which logits belong to the same categorical distribution.
    shape: Optional, a tuple of nonnegative integers representing the result shape.
      Must be broadcast-compatible with ``np.delete(logits.shape, axis)``.
      The default (None) produces a result shape equal to ``np.delete(logits.shape, axis)``.
    replace: If True (default), perform sampling with replacement. If False, perform
      sampling without replacement.
    mode: optional, "high" or "low" for how many bits to use in the gumbel sampler.
      The default is determined by the ``use_high_dynamic_range_gumbel`` config,
      which defaults to "low". With mode="low", in float32 sampling will be biased
      for events with probability less than about 1E-7; with mode="high" this limit
      is pushed down to about 1E-14. mode="high" approximately doubles the cost of
      sampling.

  Returns:
    A random array with int dtype and shape given by ``shape`` if ``shape``
    is not None, or else ``np.delete(logits.shape, axis)``.

  References:
    .. [1] Wouter Kool, Herke van Hoof, Max Welling. "Stochastic Beams and Where to Find
      Them: The Gumbel-Top-k Trick for Sampling Sequences Without Replacement".
      Proceedings of the 36th International Conference on Machine Learning, PMLR
      97:3499-3508, 2019. https://proceedings.mlr.press/v97/kool19a.html.
  ÚcategoricalNr   rŒ  ©r  z'Number of samples without replacement (z&) cannot exceed number of categories (z).r9  rü   )rN   r   r•   r–   r›   rH   ÚdeleterI   r
   rÍ   r¼   rè   ÚlistÚinsertÚargmaxrA  r;   r   Úexpand_dimsr/  r;  r<  rA   rB  ÚmoveaxisrG   rò   )rK   Úlogitsr  rI   rD  r6  r­   Ú
logits_arrÚbatch_shapeÚshape_prefixÚlogits_shaper:  ÚindicesÚ
dimensionss                 r,   rR  rR  ¤  sZ  € ôP ˜=¨#Ó.�&€#€qÜ�- Ô(Ü�{‰{˜6Ó"€*Ü”b—i‘i 
× 0Ñ 0°$Ó7Ó8€+Ø
€]Ø�Eä×#Ñ# EÓ*€EÜ�  {Ô3ØÐ3œ˜E›
¤3 {Ó#3Ñ3Ð4€,áØˆq‚yØ
Œc�*×"Ñ"Ó#Ñ#€dä˜œc %›j¬3¨{Ó+;Ñ;Ð<Ð=Ó>€LØ×Ñ˜œs :×#3Ñ#3Ó4Ñ4°j×6FÑ6FÀtÑ6LÔMÜ�:‰:ÜˆsÐ2�lÐ2 \Ñ2°J×4DÑ4DÈ4ÔPÜ�‰˜
¤E¬%´°LÓ0AÓ*BÓ$CÓDñ	Eàôð ð
 ”&˜˜j×.Ñ.°
×0@Ñ0@ÀtÔLÑL€JÜ�	‰	�,Ó€AØˆ:×Ñ˜DÑ!Ò!ÜØ
1°!°ð 5Ø!×'Ñ'¨Ñ-Ð.¨bð	2óð ô
 —‘œ3Ÿ<™<¨
°D¸"Ó=¸qÓA�J€A€wØ�=‰=˜K¨1¨$Ñ.Ò.Ð.Ð.Ø�L ;Ñ.Ò.Ð.Ð.à—,‘, Ñ"Ð=¤U¨7¯<©<¸!Ñ+;Ó%<Ñ=€JÜ�k‰k˜' 5¨*Ó5€GØ�=‰=˜EÒ!Ð!Ð!Ø€Nr.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||«      S )a  Sample Laplace random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
    f(x) = \frac{1}{2}e^{-|x|}

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  Úlaplacez7dtype argument to `laplace` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_laplacer¤  s       r,   rb  rb  ô  s�   € ô( ˜9 cÓ*�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�#�u˜eÓ	$Ð$r.   c           
     ó>  — t        d|«       t        | ||dt        j                  |«      j                  z   d¬«      }t        j                  t        j                  |«      t        j                  t        j                  t        j                  |«      «      «      «      S )Nrb  r^  rÕ   r€  )r¼   r×   r   ré   Úepsnegr   r  Úsignr·  r¶  r2  r¸  s       r,   rc  rc    si   € äˆy˜%Ô ÜØ	ˆ5�% ¤f§l¡l°5Ó&9×&@Ñ&@Ñ @ÈôM€!ä	�‰”—‘˜!“œcŸi™i¬¯©´·±¸³
Ó(;Ó<Ó	=Ð=r.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||«      S )a%  Sample logistic random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x) = \frac{e^{-x}}{(1 + e^{-x})^2}

  Args:
    key: a PRNG key used as the random key.
    shape: optional, a tuple of nonnegative integers representing the result
      shape. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  Úlogisticz8dtype argument to `logistic` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú	_logisticr¤  s       r,   rh  rh    s�   € ô( ˜: sÓ+�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�3˜˜uÓ	%Ð%r.   c                ó  — t        d|«       t        | ||t        j                  |«      j                  d¬«      }t        j                  t        j                  |«      t        j                  t        j                  |«      «      «      S )Nrh  rÕ   r€  )
r¼   r×   r   ré   rì  r   r©  r.  r·  r¶  )rK   rI   r;   r+   s       r,   ri  ri  6  sW   € äˆz˜5Ô!Üˆc�5˜%¬¯©°UÓ(;×(@Ñ(@ÈÔL€!Ü	�‰”—‘˜“œSŸY™Y¤s§w¡w¨q£zÓ2Ó	3Ð3r.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )a~  Sample Pareto random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x; b) = b / x^{b + 1}

  on the domain :math:`1 \le x < \infty` with :math:`b > 0`

  Args:
    key: a PRNG key used as the random key.
    b: a float or array of floats broadcast-compatible with ``shape``
      representing the parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``b``. The default (None)
      produces a result shape equal to ``b.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``b.shape``.
  Úparetoz6dtype argument to `pareto` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_pareto)rK   r„  rI   r;   r­   s        r,   rl  rl  =  s‰   € ô6 ˜8 SÓ)�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	��a˜ Ó	&Ð&r.   c                óÀ   — |€t        j                  |«      }nt        d|«       t        j                  ||«      }t        | ||«      }t        j                  ||z  «      S )Nrl  )rH   rI   r¼   r   ræ   r³  r™  )rK   r„  rI   r;   Úes        r,   rm  rm  b  sP   € à
€]Ü�H‰H�Q‹K�Eä�˜5Ô!ä	×Ñ˜q %Ó(€!Ü�#�u˜eÓ$€!Ü	�‰��Q‘‹Ðr.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | |||«      S )aÚ  Sample Student's t random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(t; \nu) \propto \left(1 + \frac{t^2}{\nu}\right)^{-(\nu + 1)/2}

  Where :math:`\nu > 0` is the degrees of freedom, given by the parameter ``df``.

  Args:
    key: a PRNG key used as the random key.
    df: a float or array of floats broadcast-compatible with ``shape``
      representing the degrees of freedom parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``df``. The default (None)
      produces a result shape equal to ``df.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``df.shape``.
  r„   z1dtype argument to `t` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_t©rK   ÚdfrI   r;   r­   s        r,   r„   r„   n  sƒ   € ô6 ˜3 Ó$�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	ˆC��U˜EÓ	"Ð"r.   c                ó~  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        j                  ||«      }t        | «      \  }}t        |||«      }t        j                  |d«      }t        j                  ||«      }t        ||||«      }	|t        j                  ||	z  «      z  S )Nr„   r6   )rH   rI   r¼   r   ræ   rž   rO  r  rØ  r  r•   rT  )
rK   rs  rI   r;   Úkey_nÚkey_grq  rÛ  Úhalf_dfrM  s
             r,   rq  rq  ’  s�   € à
€]Ü�H‰H�R‹L�Eä��eœRŸX™X b›\Ô*ä
×Ñ  EÓ*€"Ü˜“�,€%ˆÜˆU�E˜5Ó!€!Ü�
‰
�1�aÓ€#Ü�G‰G�B˜Ó€'ÜˆE�7˜E 5Ó)€!Ø	
ŒS�X‰X�g ‘kÓ"Ñ	"Ð"r.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )aÛ  Sample Chisquare random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x; \nu) \propto x^{\nu/2 - 1}e^{-x/2}

  on the domain :math:`0 < x < \infty`, where :math:`\nu > 0` represents the
  degrees of freedom, given by the parameter ``df``.

  Args:
    key: a PRNG key used as the random key.
    df: a float or array of floats broadcast-compatible with ``shape``
      representing the parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``df``. The default (None)
      produces a result shape equal to ``df.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``df.shape``.
  Ú	chisquarez9dtype argument to `chisquare` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú
_chisquarerr  s        r,   ry  ry  ¢  s‰   € ô8 ˜;¨Ó,�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�C˜˜U EÓ	*Ð*r.   c                ój  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        j                  ||«      }t        j
                  |d«      }t        j                  ||«      }t        | |||¬«      }t        j                  t        j                  |«      |«      }|S )Nry  r6   )rC  rI   r;   )rH   rI   r¼   r   ræ   r  rØ  r˜  r  r•   r™  )rK   rs  rI   r;   rÛ  rw  Úlog_gÚchi2s           r,   rz  rz  È  s‡   € à
€]Ü�H‰H�R‹L�Eä�˜e¤R§X¡X¨b£\Ô2Ü
×Ñ  EÓ*€"Ü�
‰
�2�qÓ€#Ü�G‰G�B˜Ó€'Ü
�3˜'¨°eÔ
<€%Ü	�‰”—‘˜“ Ó	%€$Ø	€+r.   c                ó$  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | ||||«      S )a-  Sample F-distribution random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
     f(x; \nu_1, \nu_2) \propto x^{\nu_1/2 - 1}\left(1 + \frac{\nu_1}{\nu_2}x\right)^{
      -(\nu_1 + \nu_2) / 2}

  on the domain :math:`0 < x < \infty`. Here :math:`\nu_1` is the degrees of
  freedom of the numerator (``dfnum``), and :math:`\nu_2` is the degrees of
  freedom of the denominator (``dfden``).

  Args:
    key: a PRNG key used as the random key.
    dfnum: a float or array of floats broadcast-compatible with ``shape``
      representing the numerator's ``df`` of the distribution.
    dfden: a float or array of floats broadcast-compatible with ``shape``
      representing the denominator's ``df`` of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``dfnum`` and ``dfden``.
      The default (None) produces a result shape equal to ``dfnum.shape``,
      and ``dfden.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``df.shape``.
  rÂ   z1dtype argument to `f` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_f)rK   ÚdfnumÚdfdenrI   r;   r­   s         r,   rÂ   rÂ   Ö  sŒ   € ôD ˜3 Ó$�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	ˆC�˜˜u eÓ	,Ð,r.   c                ót  — |€=t        j                  t        j                  |«      t        j                  |«      «      }n4t	        d|t        j                  |«      t        j                  |«      «       t        j
                  ||«      }t        j
                  ||«      }t        | «      \  }}t        ||||«      }t        ||||«      }t        j                  ||«      }t        j                  ||«      }t        j                  ||«      }	t        j                  ||«      }
t        j                  |	|
«      }|S )NrÂ   )r   r·   rH   rI   r¼   ræ   rž   ry  r•   r—  rØ  )rK   r€  r�  rI   r;   Úkey_dfdÚkey_dfnÚchi2_dfnÚchi2_dfdr�   ÚdenrÂ   s               r,   r  r    sò   € à
€]Ü×!Ñ!¤"§(¡(¨5£/´2·8±8¸E³?ÓC�Eä��eœRŸX™X e›_¬b¯h©h°u«oÔ>Ü
×
"Ñ
" 5¨%Ó
0€%Ü
×
"Ñ
" 5¨%Ó
0€%Ü˜C“[Ñ€'ˆ7Ü�w  u¨eÓ4€(Ü�w  u¨eÓ4€(ä
×
Ñ
˜5 %Ó
(€%Ü
×
Ñ
˜5 %Ó
(€%Ü�‰�˜%Ó €#Ü�‰�˜%Ó €#Ü	‡g�gˆc�3Ó€!Ø	
€(r.   c                ó¸   — t        d| «      \  } }t        j                  |«       t        j                  |«      }t	        j
                  |«      }t        | ||«      S )a  Sample from a Rademacher distribution.

  The values are distributed according to the probability mass function:

  .. math::
     f(k) = \frac{1}{2}(\delta(k - 1) + \delta(k + 1))

  on the domain :math:`k \in \{-1, 1\}`, where :math:`\delta(x)` is the dirac delta function.

  Args:
    key: a PRNG key.
    shape: The shape of the returned samples. Default ().
    dtype: The type used for samples.

  Returns:
    A jnp.array of samples, of shape `shape`. Each element in the output has
    a 50% change of being 1 or -1.

  Ú
rademacher)rN   r   rÊ   rÌ   r
   rÍ   Ú_rademacherr¤  s       r,   r‰  r‰    sQ   € ô, ˜<¨Ó-�&€#€qÜ×#Ñ# EÔ*Ü
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�S˜% Ó	'Ð'r.   c                ój   — t        | d|¬«      j                  |«      }d|z  dz
  j                  |«      S )Nr†  )rK   rE  rI   r6   rü   )r‹  r   )rK   rI   r;   Úbernoulli_sampless       r,   rŠ  rŠ  3  s8   € ä C¨3°eÔ<×CÑCÀEÓJÐØ
ÐÑ
 !Ñ
#×	+Ñ	+¨EÓ	2Ð2r.   c                ó  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||«      S )a…  Sample from a one sided Maxwell distribution.

  The values are distributed according to the probability density function:

  .. math::
     f(x) \propto x^2 e^{-x^2 / 2}

  on the domain :math:`0 \le x < \infty`.

  Args:
    key: a PRNG key.
    shape: The shape of the returned samples.
    dtype: The type used for samples.

  Returns:
    A jnp.array of samples, of shape `shape`.

  Úmaxwellz7dtype argument to `maxwell` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_maxwellr¤  s       r,   rŽ  rŽ  9  s�   € ô. ˜9 cÓ*�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�#�u˜eÓ	$Ð$r.   c                óV   — |dz   }t        | ||¬«      }t        j                  |d¬«      S )N)rÝ   )rK   rI   r;   r9  rS  )rO  rs  Únorm)rK   rI   r;   Únorm_rvss       r,   r�  r�  Z  s*   € à
�$‰,€%Ü˜ 5°Ô6€(Ü	�‰˜¨Ô	+Ð+r.   c                ó   — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||||«      S )ar  Sample from a double sided Maxwell distribution.

  The values are distributed according to the probability density function:

  .. math::
     f(x;\mu,\sigma) \propto z^2 e^{-z^2 / 2}

  where :math:`z = (x - \mu) / \sigma`, with the center :math:`\mu` specified by
  ``loc`` and the scale :math:`\sigma` specified by ``scale``.

  Args:
    key: a PRNG key.
    loc: The location parameter of the distribution.
    scale: The scale parameter of the distribution.
    shape: The shape added to the parameters loc and scale broadcastable shape.
    dtype: The type used for samples.

  Returns:
    A jnp.array of samples.

  Údouble_sided_maxwellzDdtype argument to `double_sided_maxwell` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_double_sided_maxwell)rK   ÚlocÚscalerI   r;   r­   s         r,   r”  r”  a  s†   € ô4 Ð1°3Ó7�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð $Ø$) 7ð,ó -ð -ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	˜s C¨°°uÓ	=Ð=r.   c                ó,  — t        j                  t        j                  |«      t        j                  |«      «      }|s|}||z   }t	        | «      \  }}t        |||¬«      }t        |||¬«      }	|	j                  |j                  k(  sJ ‚|	|z  |z  |z   S )NrØ   )r   r·   rH   rI   rž   rŽ  r‰  )
rK   r–  r—  rI   r;   Úparams_shapesÚmaxwell_keyÚrademacher_keyÚmaxwell_rvsÚrandom_signs
             r,   r•  r•  …  s�   € ä×&Ñ&¤r§x¡x°£}´b·h±h¸u³oÓF€-Ù	Ø€Eà
�-Ñ
€%Ü & s£Ñ€+ˆ~Ü˜¨5¸Ô>€+ä˜>°¸eÔD€+Ø	×	Ñ	˜k×/Ñ/Ò	/Ð/Ð	/à	�{Ñ	" UÑ	*¨SÑ	0Ð0r.   c                ó   — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }t        j                  |«      }t        | ||||«      S )a~  Sample from a Weibull distribution.

  The values are distributed according to the probability density function:

  .. math::
     f(x;\sigma,c) \propto x^{c - 1} \exp(-(x / \sigma)^c)

  on the domain :math:`0 < x < \infty`, where :math:`c > 0` is the concentration
  parameter, and :math:`\sigma > 0` is the scale parameter.

  Args:
    key: a PRNG key.
    scale: The scale parameter of the distribution.
    concentration: The concentration parameter of the distribution.
    shape: The shape added to the parameters loc and scale broadcastable shape.
    dtype: The type used for samples.

  Returns:
    A jnp.array of samples.

  Úweibull_minz;dtype argument to `weibull_min` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_weibull_min)rK   r—  ÚconcentrationrI   r;   r­   s         r,   rŸ  rŸ  •  s…   € ô4 ˜=¨#Ó.�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ü
×
!Ñ
! %Ó
(€%Ü	�c˜5 -°¸Ó	>Ð>r.   c                ó„   — t        | |dd|¬«      }t        j                  t        j                  | «       d|z  «      |z  S )Nr   rü   )rK   rI   rÛ   rÜ   r;   rÕ   )r×   r•   Úpowerr·  )rK   r—  r¡  rI   r;   Úrandom_uniforms         r,   r   r   ¹  sB   € äØ
�U 1¨Q°eô=€.ô 
�‰”C—I‘I˜~˜oÓ.Ð.°°MÑ0AÓ	BÀUÑ	JÐJr.   c                ó.  — |€|}n|}t        j                  |«      }t        d| «      \  } }t        j                  |«       t        d|«       t        j                  t        |d«      }t        j                  t        |d«      }t        | g |¢t        ||«      ‘t        ||«      ‘­|«      }t        j                  |«      \  }}	t        j                  |	«      }
|t        j                  t        j                   |
«      d«      z  }||k  r|j"                  S |S )a�  Sample uniformly from the orthogonal group O(n).

  If the dtype is complex, sample uniformly from the unitary group U(n).

  For unequal rows and columns, this samples a semi-orthogonal matrix instead.
  That is, if :math:`A` is the resulting matrix and :math:`A^*` is its conjugate
  transpose, then:

  - If :math:`n \leq m`, the rows are mutually orthonormal: :math:`A A^* = I_n`.
  - If :math:`m \leq n`, the columns are mutually orthonormal: :math:`A^* A = I_m`.

  Args:
    key: a PRNG key used as the random key.
    n: an integer indicating the number of rows.
    shape: optional, the batch dimensions of the result. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).
    m: an integer indicating the number of columns. Defaults to `n`.

  Returns:
    A random array of shape `(*shape, n, m)` and specified dtype.

  References:
    .. [1] Mezzadri, Francesco. (2007). "How to generate random matrices from
           the classical compact groups". Notices of the American Mathematical
           Society, 54(5), 592-604. https://arxiv.org/abs/math-ph/0609050.
  Ú
orthogonalz-The error occurred in jax.random.orthogonal()rp  )r
   rÍ   rN   r   rÊ   r¼   r"  r   rO  rñ   r  rs  ÚqrÚdiagonalr•   rX  rf  ÚmT)rK   rq  rI   r;   ÚmÚ_mr­   ÚzÚqr   rÂ  r+   s               r,   r¦  r¦  Â  sô   € ðD €YØ	
�Bà	
€BÜ
×
!Ñ
! %Ó
(€%Ü˜<¨Ó-�&€#€qÜ×#Ñ# EÔ*Üˆ|˜UÔ#Ü
×ÑœU AÐ'VÓW€!Ü×Ñœe RÐ)XÓY€"äˆSÐ2�EÐ2œ3˜q "›:Ð2¤s¨1¨b£zÑ2°EÓ:€!Ü	�‰�qÓ	�$€!€QÜ×Ñ˜!Ó€!ØŒ#�/‰/œ#Ÿ(™( 1›+ rÓ
*Ñ*€!àˆ‚VØ�4‰4€Kà€Hr.   c                ó   — t        j                  |«      }t        d| «      \  } }t        j                  |«       t        d|«       t        | «      }t        |d   d|z  ||«      }t        |d   ||«      }||d|z  z  z  S )au  Sample from the generalized normal distribution.

  The values are returned according to the probability density function:

  .. math::
     f(x;p) \propto e^{-|x|^p}

  on the domain :math:`-\infty < x < \infty`, where :math:`p > 0` is the
  shape parameter.

  Args:
    key: a PRNG key used as the random key.
    p: a float representing the shape parameter.
    shape: optional, the batch dimensions of the result. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified shape and dtype.
  Úgeneralized_normalr   rü   )	r
   rÍ   rN   r   rÊ   r¼   r    r  r‰  )rK   rE  rI   r;   r­   r�   rM  r   s           r,   r¯  r¯  ù  s„   € ô4 ×
!Ñ
! %Ó
(€%ÜÐ/°Ó5�&€#€qÜ×#Ñ# EÔ*ÜÐ# UÔ+Ü	ˆs‹€$ÜˆD�‰G�Q�q‘S˜% Ó'€!Ü��a‘˜% Ó'€!Ø	
ˆQ�1�q‘5‰\Ñ	Ðr.   c                óŠ  — t        j                  |«      }t        d| «      \  } }t        j                  |«       t        d|«       t        j                  t        |d«      }t        | «      \  }}t        ||g |¢|‘­|«      }t        |||«      }	|t        j                  |«      |z  j                  d«      |	z   d|z  z  d   z  S )a$  Sample uniformly from the unit Lp ball.

  Reference: https://arxiv.org/abs/math/0503650.

  Args:
    key: a PRNG key used as the random key.
    d: a nonnegative int representing the dimensionality of the ball.
    p: a float representing the p parameter of the Lp norm.
    shape: optional, the batch dimensions of the result. Default ().
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array of shape `(*shape, d)` and specified dtype.
  Úballz'The error occurred in jax.random.ball()r9  rü   ).N)r
   rÍ   rN   r   rÊ   r¼   r"  r   r    r¯  r³  r•   r2  Úsum)
rK   rÂ  rE  rI   r;   r­   r  r  rM  ro  s
             r,   r±  r±  	  s¹   € ô, ×
!Ñ
! %Ó
(€%Ü˜6 3Ó'�&€#€qÜ×#Ñ# EÔ*Üˆv�uÔÜ
×ÑœU AÐ'PÓQ€!Ü�‹:�&€"€bÜ˜˜Q  % ¨¡¨UÓ3€!Ü�"�e˜UÓ#€!Ø	
”—‘˜“
˜a‘×$Ñ$ RÓ(¨1Ñ,°!°a±%Ñ8¸)ÑDÑ	DÐDr.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )aÜ  Sample Rayleigh random values with given shape and float dtype.

  The values are returned according to the probability density function:

  .. math::
     f(x;\sigma) \propto xe^{-x^2/(2\sigma^2)}

  on the domain :math:`-\infty < x < \infty`, and where :math:`\sigma > 0` is the scale
  parameter of the distribution.

  Args:
    key: a PRNG key used as the random key.
    scale: a float or array of floats broadcast-compatible with ``shape``
      representing the parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``scale``. The default (None)
      produces a result shape equal to ``scale.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``scale.shape``.
  Úrayleighz8dtype argument to `rayleigh` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú	_rayleigh)rK   r—  rI   r;   r­   s        r,   r´  r´  =	  s‰   € ô8 ˜: sÓ+�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�3˜˜u eÓ	,Ð,r.   c                ó²  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        | ||«      }|j	                  |«      }t        j                  ||«      }t        j                  |«      }t        j                  |d«      }t        j                  t        j                  ||«      «      }t        j                  ||«      }|S )Nr´  rp  )rH   rI   r¼   r×   r   r•   r—  r   r.  r  rT  r  )	rK   r—  rI   r;   rd  Úlog_uÚn_twoÚsqrt_uÚrays	            r,   rµ  rµ  c	  s¡   € à
€]Ü�H‰H�U‹O�Eä�˜U¤B§H¡H¨U£OÔ4Üˆc�5˜%Ó €!Ø
�,‰,�uÓ
€%Ü
×
Ñ
˜5 %Ó
(€%Ü
�'‰'�!‹*€%Ü
�*‰*�U˜BÓ
€%Ü�8‰8”C—G‘G˜E 5Ó)Ó*€&Ü�‰��vÓ€#Ø	€*r.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )a  Sample Wald random values with given shape and float dtype.

  The values are returned according to the probability density function:

  .. math::
     f(x;\mu) = \frac{1}{\sqrt{2\pi x^3}} \exp\left(-\frac{(x - \mu)^2}{2\mu^2 x}\right)

  on the domain :math:`-\infty < x < \infty`, and where :math:`\mu > 0` is the location
  parameter of the distribution.


  Args:
    key: a PRNG key used as the random key.
    mean: a float or array of floats broadcast-compatible with ``shape``
      representing the mean parameter of the distribution.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``mean``. The default
      (None) produces a result shape equal to ``np.shape(mean)``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``mean.shape``.
  Úwaldz4dtype argument to `wald` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_wald)rK   rk  rI   r;   r­   s        r,   r¼  r¼  r	  s‰   € ô: ˜6 3Ó'�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	ˆs�D˜% Ó	'Ð'r.   c                ól  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        | d«      \  }}|j	                  |«      }t        j                  ||«      }t        |||«      }t        |||«      }t        j                  |d«      }t        j                  |d«      }	t        j                  |d«      }
t        j                  d|z  |z  |
|	z  z   «      }||
|z  dz  z   |dz  |z  z
  }t        j                  t        j                  ||||z   z  «      ||
|z  «      }|S )Nr¼  r6   rÞ   )rH   rI   r¼   rž   r   r•   r—  rO  r×   r   Úinteger_powrT  r
  rÍ  )rK   rk  rI   r;   r  r  rx  r¬  ÚyÚy_sqÚmean_sqÚ	sqrt_termr+   rw  s                 r,   r½  r½  ™	  s  € à
€]Ü�X‰X�d‹^�Eä�˜¤§¡¨£Ô/Ü�#�q‹>�&€"€bØ	�‰�UÓ	€$Ü	×	Ñ	˜$ Ó	&€$ÜˆR�˜Ó€!Üˆb�%˜Ó€!Ü	‡o�o�a˜Ó€!Ü	�‰˜˜AÓ	€$Ü�O‰O˜D !Ó$€'Ü�h‰h�q˜4‘x !‘| g°¡nÑ4Ó5€)Ø
ˆW�q‰[˜1‰_Ñ˜t a™x¨)Ñ3Ñ3€!Ü	‡j�j”—‘˜˜D D¨1¡HÑ-Ó.°°7¸Q±;Ó?€!Ø	
€(r.   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )ao  Sample Geometric random values with given shape and float dtype.

  The values are returned according to the probability mass function:

  .. math::
      f(k;p) = p(1-p)^{k-1}

  on the domain :math:`0 < p < 1`.

  Args:
    key: a PRNG key used as the random key.
    p: a float or array of floats broadcast-compatible with ``shape``
      representing the probability of success of an individual trial.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``p``. The default
      (None) produces a result shape equal to ``np.shape(p)``.
    dtype: optional, a int dtype for the returned values (default int64 if
      jax_enable_x64 is true, otherwise int32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``p.shape``.
  Ú	geometricz8dtype argument to `geometric` must be an int dtype, got )rN   r   rÊ   r:   rH   rý   rA   rÌ   r
   rÍ   Ú
_geometric)rK   rE  rI   r;   r­   s        r,   rÅ  rÅ  ¬	  s‰   € ô6 ˜;¨Ó,�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§*¡*Ô	-Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�C˜˜E 5Ó	)Ð)r.   c                óÎ  — |€t        j                  |«      }n t        d|t        j                  |«      «       t        d|«       t	        |«      \  }t        | ||j                  «      }t        j                  |«      }t        j                  | «      }t        j                  ||«      }t        j                  t        j                  ||«      «      dz   }|j                  |«      S )NrÅ  rü   )rH   rI   r¼   r   r    r×   r;   r   r.  r·  r•   r—  r3  rØ  r   )rK   rE  rI   r;   rd  r·  Úlog_one_minus_prM  s           r,   rÆ  rÆ  Ñ	  sª   € à
€]Ü�X‰X�a‹[�Eä�˜e¤R§X¡X¨a£[Ô1Ü�+˜qÔ!Ü˜aÓ �"€!Üˆc�5˜!Ÿ'™'Ó"€!Ü
�'‰'�!‹*€%Ü—I‘I˜q˜b“M€/Ü×$Ñ$ _°eÓ<€/Ü	‡i�i”—‘˜˜Ó/Ó0°1Ñ4€!Ø	
�‰�%‹Ðr.   c                ó&  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||||«      S )aá  Sample Triangular random values with given shape and float dtype.

  The values are returned according to the probability density function:

  .. math::
      f(x; a, b, c) = \frac{2}{c-a} \left\{ \begin{array}{ll} \frac{x-a}{b-a} & a \leq x \leq b \\ \frac{c-x}{c-b} & b \leq x \leq c \end{array} \right.

  on the domain :math:`a \leq x \leq c`.

  Args:
    key: a PRNG key used as the random key.
    left: a float or array of floats broadcast-compatible with ``shape``
      representing the lower limit parameter of the distribution.
    mode: a float or array of floats broadcast-compatible with ``shape``
      representing the peak value parameter of the distribution, value must
      fulfill the condition ``left <= mode <= right``.
    right: a float or array of floats broadcast-compatible with ``shape``
      representing the upper limit parameter of the distribution, must be
      larger than ``left``.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``left``,``mode`` and ``right``.
      The default (None) produces a result shape equal to ``left.shape``, ``mode.shape``
      and ``right.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape`` if
    ``shape`` is not None, or else by ``left.shape``, ``mode.shape`` and ``right.shape``.
  Ú
triangularz:dtype argument to `triangular` must be a float dtype, got )rN   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   Ú_triangular)rK   Úleftr6  ÚrightrI   r;   r­   s          r,   rÊ  rÊ  á	  sŽ   € ôH ˜<¨Ó-�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
ð #Ø#( 'ð+ó ,ð ,ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�S˜$  e¨U°EÓ	:Ð:r.   )rÞ   rn  )rß   Úinlinec           	     óº  — |€Qt        j                  t        j                  |«      t        j                  |«      t        j                  |«      «      }nHt	        d|t        j                  |«      t        j                  |«      t        j                  |«      «       t        j                  ||«      }t        j                  ||«      }t        j                  ||«      }||z
  ||z
  z  }t        | ||«      }|t        j                  |||z
  z  ||z
  z  «      z   }|t        j                  d|z
  ||z
  z  ||z
  z  «      z
  }	t        j                  ||k  ||	«      }
|
S )NrÊ  rü   )
r   r·   rH   rI   r¼   r•   r—  r×   rT  r
  )rK   rÌ  r6  rÍ  rI   r;   Úfcrd  Úout1Úout2Útris              r,   rË  rË  
  s  € ð €]Ü×!Ñ!¤"§(¡(¨4£.´"·(±(¸4³.Ä"Ç(Á(È5Ã/ÓR�Eä�˜u¤b§h¡h¨t£n´b·h±h¸t³nÄbÇhÁhÈuÃoÔVÜ	×	Ñ	˜$ Ó	&€$Ü	×	Ñ	˜$ Ó	&€$Ü
×
Ñ
˜5 %Ó
(€%Øˆt‰˜ ™Ñ%€"Üˆc�5˜%Ó €!Ø	”—‘˜˜e d™lÑ+¨t°d©{Ñ;Ó<Ñ	<€$Ø	”—‘˜1˜q™5 U¨T¡\Ñ2°e¸d±lÑCÓDÑ	D€$Ü�
‰
�1�r‘6˜4 Ó&€#Ø	€*r.   rü   c                ó"  — t        d| «      \  } }t        j                  |«       t        j                  |t        j
                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | |||«      S )ac   Sample lognormal random values with given shape and float dtype.

  The values are distributed according to the probability density function:

  .. math::
      f(x) = \frac{1}{x\sqrt{2\pi\sigma^2}}\exp\left(-\frac{(\log x)^2}{2\sigma^2}\right)

  on the domain :math:`x > 0`.

  Args:
    key: a PRNG key used as the random key.
    sigma: a float or array of floats broadcast-compatible with ``shape`` representing
      the standard deviation of the underlying normal distribution. Default 1.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. The default (None) produces a result shape equal to ``()``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by ``shape``.
  Ú	lognormalzDdtype argument to `lognormal` must be a float or complex dtype, got )rN   r   rÊ   r:   rH   rP  rA   rÌ   r
   rÍ   Ú
_lognormal)rK   ÚsigmarI   r;   r­   s        r,   rÕ  rÕ  !
  s‰   € ô2 ˜;¨Ó,�&€#€qÜ×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§*¡*Ô	-Ü
ð Ø!˜7ð$ó %ð %ä
×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�C˜  uÓ	-Ð-r.   c                óè   — |€t        j                  |«      }n t        d|t        j                  |«      «       t        j                  ||«      }t        | ||«      |z  }t        j                  |«      S )NrÊ  )rH   rI   r¼   r•   r—  rO  r   r™  )rK   r×  rI   r;   Úscaled_norms        r,   rÖ  rÖ  D
  s\   € à
€]Ü�X‰X�e‹_�Eä�˜u¤b§h¡h¨u£oÔ6Ü
×
Ñ
˜5 %Ó
(€%Ü�s˜E 5Ó)¨EÑ1€+Ü	�‰�Ó	Ðr.   c                ó–  — t        j                  g d¢| j                  ¬«      }| dk  }t        j                  t        j
                  | d«      | t        j
                  | d«      «      } | dz   | dz   z  }ddd	|z  z
  |z  z
  | dz   z  }t        j                  | «      } t        j                  ||t        j                  | d
¬«         |«      S )N)
gW
Ú¼qÀ´?g;¦>’›*¥?g¨€�&šWœ?g¨xýb&J•?gÒË?QN‘?gßë{kŒ?g^J.aM]ˆ?g?0{^€R…?gb«‡ô‚?g§CL��?r“   é	   rÔ   g      "@rü   gUUUUUUµ?glÁlÁf?g  J?rû   )	r•   rî   r;   r   Úclampr  r3  r
  r–   )r:  Ústirling_tail_valsÚuse_tail_valuesÚkp1sqÚapproxs        r,   Ú_stirling_approx_tailrá  O
  s¾   € Ü—y‘yòð �G‰GôÐð ˜‘F€/Ü	‡i�i”—
‘
˜1˜cÓ" A¤s§z¡z°!°SÓ'9Ó:€!Øˆq‰5�Q˜‘UÑ
€%Ø˜	 J°Ñ$6Ñ6¸%Ñ?Ñ?ÀAÈÁEÑJ€&Ü	‡i�i�ƒl€!Ü	�‰ØÐ)¬#¯+©+°a¸wÔ*GÑHÈ&ó
Rð Rr.   c                óØ  ‡‡‡‡‡— t         j                  j                  r0t        j                  ‰j
                  t        j                  «      sJ ‚t        j                  ‰ «      Šˆˆˆˆfd„}ˆˆfd„}t        j                  ‰d‰j
                  ‰«      }t        j                  ‰d‰j
                  ‰«      }	d||	| f}
t        j                  |||
«      d   }|dz
  j                  |«      S )Nc                ó  •— | \  }}}}t        |«      \  }}t        j                  |‰	k  |dz   |«      }t        |‰‰j                  «      }t        j                  t        j                  |«      ‰
z  «      }||z   }|dz   |||fS r  )r    r   r
  r×   r;   r•   r-  r.  )r!  r   Únum_geomÚgeom_sumrK   r4  Únum_geom_outrd  ÚgeomÚcountÚlog1minusprobÚprobrI   s            €€€€r,   r%  z$_binomial_inversion.<locals>.body_fno
  s‚   ø€ Ø!&Ñ€A€x�˜3Ü˜“*�K€FˆCÜ—:‘:˜h¨%Ñ/°¸A±¸xÓH€LÜ�˜˜tŸz™zÓ*€AÜ�8‰8”C—G‘G˜A“J Ñ.Ó/€DØ˜$‰€HØˆq‰5�, ¨#Ð-Ð-r.   c                óJ   •— | d   | d   }}|‰k  j                  «       |‰k  z  S ©Nr   r6   r'  )r!  r   rå  rè  r)  s      €€r,   r*  z$_binomial_inversion.<locals>.cond_fnx
  s1   ø€ Ø˜‘(˜E !™H€x€AØ˜Ñ×"Ñ"Ó$¨¨I©Ñ6Ð6r.   r   rü   )r	   Úenable_checksr@   r   r:   r;   rH   rÙ   r•   r·  r   r  rÏ  rÐ  r   )rK   rè  rê  rI   r;   r)  r%  r*  Únum_geom_initÚgeom_sum_initr!  r:  ré  s    ``` `      @r,   Ú_binomial_inversionrð  h
  s¶   ü€ ä×Ñ×ÒÜ×Ñ˜TŸZ™Z¬¯©Ô5Ð5Ð5ä—)‘)˜T˜EÓ"€-÷.õ7ô —-‘-  a¨¯©°UÓ;€-Ü—-‘-  a¨¯©°UÓ;€-Øˆm˜]¨CÐ
0€%Ü×!Ñ! '¨7°EÓ:¸1Ñ=€!Ø
ˆa‰%�‰˜Ó	Ðr.   c           
     óö  ‡‡‡‡‡‡‡‡‡‡‡— t        j                  ‰‰z  d‰z
  z  «      }dd|z  z   Šdd‰z  z   d‰z  z   Š‰‰z  dz   Šdd	‰z  z
  Š‰d‰z
  z  Šd
d‰z  z   |z  Št        j                  ‰dz   ‰z  «      Šˆˆˆˆˆˆˆˆˆˆf
d„}ˆfd„}t        j                  ‰d‰j
                  ‰«      }	d|	t        j                  ‰dt        «      | f}
t        j                  |||
«      d   j                  |«      S )Nrü   gffffffò?r/  gEØðôJY¶¿gaÃÓ+e™?ç{®Gáz„?r†  gq=
×£pí?gÍÌÌÌÌÌ@g¤p=
×£@gffffff@c                óV  •
— | \  }}}}t        |d«      \  }}}t        |‰‰j                  «      }t        |‰‰j                  «      }|dz
  }dt        j                  |«      z
  }	|	dk\  |‰k  z  }
t        j
                  d‰z  |	z  ‰z   |z  ‰z   «      }|dk  |‰kD  z  }t        j                  |‰z  ‰|	|	z  z  ‰z   z  «      }‰dz   t        j                  ‰dz   ‰‰‰z
  dz   z  z  «      z  ‰dz   t        j                  ‰‰z
  dz   ‰|z
  dz   z  «      z  z   |dz   t        j                  ‰‰|z
  dz   z  |dz   z  «      z  z   t        ‰«      z   t        ‰‰z
  «      z   t        |«      z
  t        ‰|z
  «      z
  }||k  }|
| |z  z  }t        j                  |||«      }||z  }|dz   |||fS )NrÝ   r†  r1  r6   r   rü   )
r    r×   r;   r•   r2  r3  r.  rá  r   r
  )r!  r   r5  r6  rK   r7  r8  rd  rx  Úusr:  r:  r;  Úubr<  r=  rC  r­  r„  rÊ  rè  rª  rê  r   rI   r@  s                   €€€€€€€€€€r,   r%  z_btrs.<locals>.body_fn�
  sí  ø€ Ø#Ñ€A€uˆh˜Ü# C¨›mÑ€Cˆ�8Ü�˜% §¡Ó,€AÜ�˜% §¡Ó,€AØ	ˆC‰€AØ	Œs�w‰w�q‹zÑ	€BØ�T‰z˜a 3™hÑ'€GÜ�	‰	�1�q‘5˜2‘: ‘> QÑ&¨Ñ*Ó+€AØ�!‰e˜˜E™	Ñ"€FÜ�‰��E‘	˜Q " r¡'™]¨QÑ.Ñ/Ó0€Aàˆ3�w”#—'‘'˜1˜q™5 Q¨%°!©)°a©-Ñ%8Ñ9Ó:Ñ:Ø	�‰”c—g‘g˜u q™y¨1™}°¸±¸Q±Ñ?Ó@Ñ@ñAà	
ˆS‰”C—G‘G˜A ¨¡¨Q¡Ñ/°1°q±5Ñ9Ó:Ñ:ñ;ô 	˜aÓ ñ!ô 	˜e a™iÓ(ñ	)ô
 	˜aÓ ñ!ô 	˜e a™iÓ(ñ)ð ð �2‰g€GØ˜˜ 'Ñ)Ñ*€FÜ�J‰J�v˜q %Ó(€EØ�Ñ€HØˆq‰5�%˜ 3Ð&Ð&r.   c                óF   •— | d   | d   }}| j                  «       |‰k  z  S rì  r'  )r!  r   r6  r)  s      €r,   r*  z_btrs.<locals>.cond_fnª
  s,   ø€ Ø˜‘(˜E !™H€x€AØˆI�?‰?Ó  I¡Ñ.Ð.r.   r9  r   F)r•   rT  r3  r   r  r;   Úfullrq   rÏ  rÐ  r   )rK   rè  rê  rI   r;   r)  Ústddevr%  r*  r+  r!  rC  r­  r„  rÊ  rª  r   r@  s    ``` `     @@@@@@@r,   Ú_btrsrù  ƒ
  s  ÿú€ ô �8‰8�E˜D‘L A¨¡HÑ-Ó.€&Ø
ˆT�F‰]Ñ€!Ø�˜‘
Ñ˜T D™[Ñ(€!Øˆd�l�SÑ€!Øˆs�Q‰w‰€#Ø
ˆa�$‰hÑ€!Ø�#˜‘'‰>˜VÑ
#€%Ü	‡i�i�˜‘˜dÑ"Ó#€!÷'õ 'ô4/ô �=‰=˜˜r 4§:¡:¨uÓ5€&Øˆf”c—h‘h˜u e¬TÓ2°CÐ
8€%Ü	×	$Ñ	$ W¨g°uÓ	=¸aÑ	@×	GÑ	GÈÓ	NÐNr.   c                ó  — |€=t        j                  t        j                  |«      t        j                  |«      «      }n4t	        d|t        j                  |«      t        j                  |«      «       t        |«      \  }t        j                  ||j                  «      }t        j                  ||«      }t        j                  ||«      }|dk  }t        j                  ||d|z
  «      }t        |«      |dk  z  }t        j                  |«      }t        |«      }	|dk  }
t        j                  |	|
z  t        j                  |d«      |«      }|||z  dk  z  }t        j                  |«      }t        j                  ||t        j                  |d«      «      }t        j                  |t        j                  |d«      |«      }t        j                  |t        j                  |d«      |«      }|j                  t!        j"                  |«      j$                  «      }t        j                  |t'        | |||||«      t)        | |||||«      «      }|
|	z  |z  }t        j                  |t        j                  |t        j*                  |«      |«      }t        j                  || z  t        j                  |t        j,                  |«      |«      }t        j                  ||z  |	z  |z  ||j/                  |«      |z
  «      }|S )NÚbinomialr†  rÕ   rÔ   rò  g      $@g     ˆÃ@)r•   r·   rH   rI   r¼   r    r   ræ   r;   r—  r
  r-   Úisinfr  r3  rF   r   ré   rñ   rð  rù  Únanrƒ  r   )rK   rè  rê  rI   r;   Ú	p_lt_halfr­  Úcount_nan_or_negÚ	count_infÚq_is_nanÚq_l_0Úuse_inversionÚ	count_invÚ
count_btrsÚq_btrsr)  rá  Úinvalids                     r,   Ú	_binomialr  ³
  sx  € ð €]Ü× Ñ ¤§¡¨%£´"·(±(¸4³.ÓA�Eä�˜U¤B§H¡H¨U£O´R·X±X¸d³^ÔDÜ" 4Ó(�'€4Ü
×
"Ñ
" 5¨$¯*©*Ó
5€%Ü
×
Ñ
˜5 %Ó
(€%Ü	×	Ñ	˜$ Ó	&€$Ø�S‰j€)Ü	‡j�j�˜D #¨¡*Ó-€!Ü˜E“] e¨c¡kÑ2ÐÜ�i‰i˜Ó€)Ü�A‹Y€(Ø
ˆc‰'€%Ü	‡j�j�˜EÑ!¤3§=¡=°°DÓ#9¸1Ó=€!Ø" e¨a¡i°4Ñ&7Ñ8€-ô �)‰)�EÓ
€%ä�j‰j˜¨¬s¯}©}¸UÀCÓ/HÓI€)Ü�z‰z˜-¬¯©°u¸cÓ)BÀEÓJ€*Ü�:‰:�m¤S§]¡]°1°cÓ%:¸AÓ>€&Ø�j‰jœŸ™ eÓ,×0Ñ0Ó1€)Ü�J‰JØÜ˜˜Y¨¨5°%¸ÓCÜ	ˆ#ˆz˜6 5¨%°Ó;ó€'ð �XÑÐ 0Ñ0€'Ü�J‰JØÜ‡M�M�'œ2Ÿ6™6 5Ó)Øó€'ô �J‰JØ�'�ÑÜ‡M�M�'œ2Ÿ6™6 5Ó)Øó€'ô �J‰JØÐ Ñ  8Ñ+¨iÑ7ØØ	‡L�L�Ó˜'Ñ!ó€'ð
 
€.r.   c                ó>  — t        d| «      \  } }t        d||«       t        j                  |«       t        j                  |t
        j                  «      st        d|› �«      ‚t        j                  |«      }|�t        j                  |«      }t        | ||||«      S )a˜  Sample Binomial random values with given shape and float dtype.

  The values are returned according to the probability mass function:

  .. math::
      f(k;n,p) = \binom{n}{k}p^k(1-p)^{n-k}

  on the domain :math:`0 < p < 1`, and where :math:`n` is a nonnegative integer
  representing the number of trials and :math:`p` is a float representing the
  probability of success of an individual trial.

  Args:
    key: a PRNG key used as the random key.
    n: a float or array of floats broadcast-compatible with ``shape``
      representing the number of trials.
    p: a float or array of floats broadcast-compatible with ``shape``
      representing the probability of success of an individual trial.
    shape: optional, a tuple of nonnegative integers specifying the result
      shape. Must be broadcast-compatible with ``n`` and ``p``.
      The default (None) produces a result shape equal to ``np.broadcast(n, p).shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).

  Returns:
    A random array with the specified dtype and with shape given by
    ``np.broadcast(n, p).shape``.
  rû  z8dtype argument to `binomial` must be a float dtype, got )rN   r   r   rÊ   r:   rH   rÙ   rA   rÌ   r
   rÍ   r  )rK   rq  rE  rI   r;   r­   s         r,   rû  rû  î
  s•   € ôD ˜: sÓ+�&€#€qÜ�*˜a Ô#Ü×#Ñ# EÔ*Ü	×	Ñ	˜5¤"§+¡+Ô	.Ü
Ø
BÀ5À'ÐJóð ô ×
#Ñ
# EÓ
*€%Ø
ÐÜ×#Ñ# EÓ*€EÜ	�3˜˜1˜e UÓ	+Ð+r.   Úrandom_clonec                ó   — | S r(   rx   r*   s    r,   r  r     s   € ©1r.   c                ó   — |gS r(   rx   )r­   r:  s     r,   r  r  "  s   € °Q±Cr.   )rI   r;   Úunrollc               ó*  — t        d| «      \  } }t        d||«       t        ||«      \  }}|€|j                  }t	        j
                  ||dd «      }t	        j
                  ||«      }d„ }t	        j                  |dd«      }t        j                  |dd¬«      }|t	        j                  |dk(  d|«      z  }	t        | |	j                  d   «      }
t        j                  |||	|
f|¬	«      \  }}t	        j                  |dd«      j                  |«      S )
a  Sample from a multinomial distribution.

  The probability mass function is

  .. math::
      f(x;n,p) = \frac{n!}{x_1! \ldots x_k!} p_1^{x_1} \ldots p_k^{x_k}

  Args:
    key: PRNG key.
    n: number of trials. Should have shape broadcastable to ``p.shape[:-1]``.
    p: probability of each outcome, with outcomes along the last axis.
    shape: optional, a tuple of nonnegative integers specifying the result batch
      shape, that is, the prefix of the result shape excluding the last axis.
      Must be broadcast-compatible with ``p.shape[:-1]``. The default (None)
      produces a result shape equal to ``p.shape``.
    dtype: optional, a float dtype for the returned values (default float64 if
      jax_enable_x64 is true, otherwise float32).
    unroll: optional, unroll parameter passed to :func:`jax.lax.scan` inside the
      implementation of this function.

  Returns:
    An array of counts for each outcome with the specified dtype and with shape
      ``p.shape`` if ``shape`` is None, otherwise ``shape + (p.shape[-1],)``.
  ÚmultinomialNr9  c                ól   — |\  }}t        || |j                  dd«      | j                  ¬«      }| |z
  |fS )Nr   rü   r“   )rû  r  r;   )Ú	remainderÚ	ratio_keyÚratiorK   rè  s        r,   rÂ   zmultinomial.<locals>.fP  s:   € Ø�J€Eˆ3Ü�S˜) U§Z¡Z°°1Ó%5¸Y¿_¹_ÔM€EØ�uÑ˜eÐ#Ð#r.   r   T)Úreverserü   )r  )rN   r   r    rI   r•   r—  rY  rÏ  r?  rP  r    Úscanr   )rK   rq  rE  rI   r;   r  r­   rÂ   Úremaining_probsÚratiosr�   r  Úcountss                r,   r  r  %  s  € ôD ˜=¨#Ó.�&€#€qÜ�-  AÔ&Ü	  1Ó	%�$€!€Qà
€]Ø�G‰G€EÜ	×Ñ�q˜%  ˜*Ó%€!Ü	×Ñ�q˜%Ó €!ò$ô
 
‡l�l�1�b˜!Ó€!ä$×+Ñ+¨A¨q¸$Ô?€/ØŒs�y‰y˜¨AÑ-¨q°/ÓBÑB€&ä	ˆs�F—L‘L ‘OÓ	$€$Ü&×+Ñ+¨A¨q°6¸4°.ÈÔPÑ€)ˆVô 
�‰�f˜a Ó	$×	+Ñ	+¨EÓ	2Ð2r.   c                ó,   — t         j                  | «      S )a}  Clone a key for reuse

  Outside the context of key reuse checking (see :mod:`jax.experimental.key_reuse`)
  this function operates as an identity.

  Examples:

    >>> import jax
    >>> key = jax.random.key(0)
    >>> data = jax.random.uniform(key)
    >>> cloned_key = jax.random.clone(key)
    >>> same_data = jax.random.uniform(cloned_key)
    >>> assert data == same_data
  )Úrandom_clone_pr  )rK   s    r,   Úcloner  a  s   € ô 
×	Ñ	˜SÓ	!Ð!r.   c           
     ób  ‡— t         j                  j                  s||fS |s||fS t        j                  |«      j
                  }g }|D ]á  }t        t        j                  |«      x}t        j                  «      r|j
                  n	t        «       Š|‰z
  r(t        j                  |t        ˆfd„|D «       «      «      }|t        j                  |«      j
                  k7  r:t        | › dt        j                  |«      › dt        j                  |«      › d�«      ‚|j                  |«       Œã ||fS )Nc              3  ó,   •K  — | ]  }|‰vsŒ|–— Œ y ­wr(   rx   )r|   r:  Úarg_vmas     €r,   r~   z&random_insert_pvary.<locals>.<genexpr>‚  s   øè ø€ ÐE© A°A¸WÒ4Dœa©ùs   ƒ	�z= requires all arguments to have matching type. Got key type: z vs arg type: zt. Use jax.lax.pvary(...) to make them match. If your key is less varying than arg, watch out for key-reuse problems.)r	   Ú
_check_vmar@   r
   rÖ  r×  r9   ÚShapedArrayÚ	frozensetrÕ  r›   rE   Úappend)rJ   rK   rê  Úkey_vmar…  rC  Úavalr  s          @r,   r–  r–  s  s  ø€ Ü	×	Ñ	×	 Ò	 Ø�ˆ9ÐÙ	Ø�ˆ9ÐÜ�K‰K˜Ó× Ñ €'Ø
€#Û€aÜ%¬d¯k©k¸!«nÐ&< d¼d×>NÑ>NÔOˆt�xŠxÜ“Kð ð �ÒÜ
�*‰*�QœÓE©ÓEÓEÓ
F€aØ”$—+‘+˜a“.×$Ñ$Ò$ÜØˆFð Ü�k‰k˜#ÓÐ˜~¬d¯k©k¸!«nÐ-=ð >9ð9ó:ð :ð
 ‡J�Jˆq…Mð ð  
ˆcˆ€/r.   )r+   r$   ro   r#   )rJ   rg   rK   r$   r0   rq   ro   ztuple[Array, bool])rK   r#   rU   rp   rI   ÚShapero   r#   )r‚   úPRNGSpecDesc | Nonero   r^   )r‰   rg   rŠ   úint | ArrayLiker‚   r&  ro   r#   )rŠ   r'  r3   r&  ro   r#   )rK   r$   r—   ÚIntegerArrayro   r#   )rK   r#   r�   úint | tuple[int, ...]ro   r#   )rK   r$   r�   r)  ro   r#   )r�   r#   ro   r^   )r�   r#   ro   ústr | PRNGSpec)r�   r$   ro   r*  )r�   r#   ro   r#   )r�   r$   ro   r#   )r³   r#   r3   r&  )rJ   rg   rI   r%  ro   ÚNone)rx   N)rK   r$   rI   r%  r;   zDTypeLikeUInt | Nonero   r#   )rK   r$   rI   r%  r;   ÚDTypeLikeFloatrÛ   Ú	RealArrayrÜ   r-  ro   r#   )ro   r#   )rK   r$   rI   r%  rÛ   r(  rÜ   r(  r;   ÚDTypeLikeIntro   r#   )r   F)
rK   r$   r+   r'  r  rp   r!  rq   ro   r#   )rx   TNr   N)rK   r$   rC  r'  rI   r%  rD  rq   rE  zRealArray | Noner  rp   r6  ú
str | Nonero   r#   )rK   r$   rI   r%  r;   r,  ro   r#   )NNri  )rK   r$   rk  r-  rl  r-  rI   úShape | Noner;   zDTypeLikeFloat | Nonerm  rg   ro   r#   )rK   r$   r}  r-  r~  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   rE  r-  rI   r0  r6  rg   ro   r#   )
rK   r#   rE  r#   rI   r0  r6  rg   ro   r#   )rK   r$   rC  r-  r„  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   r­  r-  rI   r0  r;   r,  ro   r#   )rK   r#   ro   r#   )
rK   r$   rC  r-  rI   r0  r;   r,  ro   r#   )F)
rK   r$   r$  r-  rI   r0  r;   r.  ro   r#   )
rK   r$   rI   r%  r;   r,  r6  r/  ro   r#   )r9  NTN)rK   r$   rZ  r-  r  rp   rI   r0  rD  rq   r6  r/  ro   r#   )
rK   r$   r„  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   rs  r-  rI   r%  r;   r,  ro   r#   )
rK   r$   rs  r-  rI   r0  r;   r,  ro   r#   )rK   r$   r€  r-  r�  r-  rI   r0  r;   r,  ro   r#   )rK   r$   rI   r%  r;   r.  ro   r#   )rK   r$   r–  r-  r—  r-  rI   r%  r;   r,  ro   r#   )rK   r$   r—  r-  r¡  r-  rI   r%  r;   r,  ro   r#   )rK   r$   rq  rp   rI   r%  r;   r,  rª  z
int | Nonero   r#   )
rK   r$   rE  ÚfloatrI   r%  r;   r,  ro   r#   )
rK   r$   rÂ  rp   rE  r1  rI   r%  r;   r,  )
rK   r$   r—  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   rk  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   rE  r-  rI   r0  r;   r.  ro   r#   )rK   r$   rÌ  r-  r6  r-  rÍ  r-  rI   r0  r;   r,  ro   r#   )
rK   r$   r×  r-  rI   r0  r;   r,  ro   r#   )rK   r#   rq  r-  rE  r-  rI   r0  r;   r,  ro   r#   )rK   r#   rq  r-  rE  r-  rI   r0  r;   r,  r  z
int | bool)¾Ú
__future__r   Úcollections.abcr   r   Ú	functoolsr   r;  Úoperatorr   r£   r   rB   r   rH   Újax._srcr	   r
   r   r   r•   r   r   Újax._src.meshr   Újax._src.sharding_implsr   r   rÒ   Újax._src.apir   r   Újax._src.interpretersr   r   r   Újax._src.laxr   rÏ  r   r   r`  Újax._src.numpyr   ru  r   rs  Újax._src.numpy.lax_numpyr   Újax._src.numpy.utilr   r   r    Újax._src.pjitr!   r"   Újax._src.typingr#   r$   r%   Újax._src.utilr&   r-  r(  r.  ÚDTypeLikeUIntr,  rp   r%  r^   rë   r-   rN   rR   rW   r>   r\   rg   ÚPRNGSpecDescr…   r‹   rK   r�   r‘   rž   r    r§   r©   r«   r¯   r±   rµ   r¼   rÅ   rÇ   rÎ   r1  r×   rÚ   rù   r  r  r#  r  r8  rO  rQ  rV  rf  rj  r{  r|  r   r‹  r�  r“  r”  r¢  r£  r«  r¬  r³  r´  rã  ró  rý  r
  Ú	Primitiver  Údef_implr  Údef_abstract_evalÚdefjvp2Úregister_loweringÚ	lower_funÚprimitive_batchersr  r˜  r  r-  rB  rI  rK  rA  rN  rR  rb  rc  rh  ri  rl  rm  r„   rq  ry  rz  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  Úsimple_implÚdefvectorizedr  r  r–  rx   r.   r,   Ú<module>rM     sl  ðõ #ç .Ý Û Ý Û Ý Û ã å Ý Ý Ý Ý !Ý Ý Ý +ß Eß "Ý $Ý *Ý &Ý 9Ý Ý /Ý /Ý /Ý >ß SÑ SÝ #Ý 9ß 7Ñ 7Ý +ð €	Ø€ð €Ø€Ø€Ø�‰€à�=‰=€à×Ñ€ó
ð
 +0ñ Ø#'ð Ø4Fó òF;óAò÷"Eñ Eð0 �S˜( H¨hÐ6Ñ7€óPð.
+Ø'ð
+Ø,1ó
+ð %)ñ!Ø!ð!Ø-2ó!ð* )-ñ>Ø%ð>Ø16ó>ó:-ô&	-ô<óó
Bóó
"óð /3ñ9Ø+ó9ó*8ò;ð Ø'+ð@ð ñ	@Øð@à$ð@ð  %ó	@òBð Ø$)Ø "Ø "ð	Hð ñHØðHà!ðHð ðHð ð	Hð #(óHñB 	ˆ˜VÔ$ò%?ó %ð%?ðX #&ð	Bð ñBØðBà ðBð !ðBð  ð	Bð #(óBñH 	ˆ˜VÔ$òLIó %ðLIðb Ø$)ðNð
 "ñNØ"ðNàðNð "ðNð
 ',óNò@5ñ 	ˆ˜TÔ"òó #ððB ØØ!%ØØ"ðUOØðUOàðUOð ðUOð ð	UOð
 ðUOð ðUOð (-óUOðr Ø#(ð Oð ñ	 OØð Oà ð Oð "'ó	 OñD 	ˆ˜VÔ$ò
+ó %ð
+ñ 	ˆ˜VÔ$òFó %ðFð /3Ø7;Ø&0ð0DØ'ð0Dà&ð0Dð  ,ð0Dð  5ð	0Dð
 !$ð0Dð
 6;ó0Dñd 	ˆ˜YÔ'òó (ððF ,0Ø-2ð	+Fð
 &*ñ+FØ%ð+Fà%ð+Fð )ð+Fð +ð	+Fð
 /4ó+FñZ 	ˆ˜VÔ$òOó %ðOð0 (˜RŸZ™Z¨›_Ø$(Øð(.Øð(.à!ð(.ð ð(.ð %*ó(.ñV 	ˆ˜w¨Ð/Ô0ò1ó 1ð1ð(  $Ø!&ð	&(Øð&(àð&(ð ð&(ð ð	&(ð ,1ó	&(óR<ð. Ø#(ð$Øð$à ð$à-2ó$ñ> 	ˆ˜VÔ$ò>ó %ð>ð %)Ø&+ð+.Øð+.à!ð+.ð $ð+.ð 16ó+.ñZ 	ˆ˜VÔ$ò(ó %ð(ð(  "Ø(-ð)Øð)à%ð)à27ó)ñ> 	ˆ˜VÔ$ò(ó %ð(óL)ò^$ð* 05ô 'ò";ð  �—‘ Ó/€Ø × Ò ˜Ô $òð ×  Ò  Ð!<Ô =à 
€‡
‚
Ø�DÙNôPð €× Ò �~ ~ t§~¢~ÙˆK $Ô'Øô(ô ð €× Ò �~ ~ t§~¢~ÙˆK $Ô'Øô(à&+õ-ð /C€× Ò ˜NÑ +ð !%Ø"'ð,2Øð,2àð,2ð  ð,2ð -2ó,2ðb $(Ø%*ð'BØð'Bà ð'Bð #ð'Bð 05ó'BñT 	ˆÐ=Ô>ó
:ó ?ð
:ñ 	ˆ˜YÔ'òó (ðñ, 	ˆ˜YÔ'ò'ó (ð'ñT 	ˆ˜VÔ$ò>ó %ð>ð, #'Ø"%ð**Øð**àð**ð  ð**ð +0ó**ð\ Ø#(Ø"ð*)ð
 ñ*)Øð*)à ð*)ð ð*)ð
 "'ó*)ñX 	ˆ˜YÔ'òOó (ðOð& ØØØðMØðMà
ðMð 	ðMð 
ð	Mð
 ðMð 	ðMð óMðb Ø$)ð%Øð%à!ð%à.3ó%ñ: 	ˆ˜VÔ$ò>ó %ð>ð Ø%*ð&Øð&à"ð&à/4ó&ñ: 	ˆ˜VÔ$ñ4ó %ð4ð "&Ø#(ð#'Øð#'àð#'ð !ð#'ð .3ó#'ñJ 	ˆ˜VÔ$òó %ðð Ø#ð"#Ø
ð"#àð"#ð ð"#ð ).ó"#ñH 	ˆ˜VÔ$ò#ó %ð#ð" %)Ø&+ð$+Øð$+à!ð$+ð $ð$+ð 16ó$+ñL 	ˆ˜VÔ$ò
ó %ð
ð  !Ø#ð	*-Øð*-àð*-ð ð*-ð ð	*-ð ).ó	*-ñX 	ˆ˜VÔ$òó %ðð( !Ø%(ð(Øð(à"ð(à-2ó(ñ: 	ˆ˜VÔ$ò3ó %ð3ð Ø$)ð%Øð%à!ð%à.3ó%ñB 	ˆ˜VÔ$ò,ó %ð,ð )+Ø16ð	!>Ø'ð!>à )ð!>ð !&ð!>ð !/ð	!>ð <Aó	!>ñH 	ˆ˜VÔ$ò1ó %ð1ð$  "Ø(-ð	!?Ø ð!?à(ð!?ð ð!?ð &ð	!?ð 38ó	!?ñH 	ˆ˜VÔ$òKó %ðKð ØØð5Øð5àð5ð 
ð5ð 
ð	5ð
 ð5ð ó5ðt Øð	!Øð!à
ð!ð 
ð!ð 
ð	!ð
 ó!ðL ØØðEØðEàðEð ðEð 
ð	Eð
 
óEðF $(Ø%*ð$-Øð$-à ð$-ð #ð$-ð 05ó$-ñL 	ˆ˜VÔ$òó %ðð   $Ø!&ð%(Øð%(àð%(ð ð%(ð ,1ó%(ñN 	ˆ˜VÔ$òó %ðð( %)Ø$'ð#*Øð#*à!ð#*ð "ð#*ð -2ó#*ñJ 	ˆ˜VÔ$òó %ðð& &*Ø',ð,;Øð,;àð,;ð  ð,;ð #ð	,;ð
 %ð,;ð
 27ó,;ñ\ 	ˆ˜V¨DÔ1òó 2ðð$ ", §¡¨A£Ø$(Ø&+ð!.Øð!.à!ð!.ð $ð!.ð 16ó!.ñF 	ˆ˜V¨DÔ1òó 2ðòRñ2 	ˆ˜Y¨tÔ4ñó 5ðñ4 	ˆ˜Y¨tÔ4ñ,Oó 5ð,Oñ^ 	ˆ˜V¨DÔ1ò7ó 2ð7ð| Ø!ð,,Ø	ð,,àð,,ð ð,,ð ð	,,ð
 ð,,ð ó,,ð`  �—‘ Ó/€Ø €× Ò �^Ô $Ø ×  Ò  ¡Ô -Ø €× Ò �~Ô &Ø €× Ò �~Ñ'7Ô 8ð Ø!Øñ93Ø	ð93àð93ð ð93ð
 ð93ð ð93ð ó93òx"ó$r.   