
    &`i^              
           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m	Z	m
Z
mZmZmZmZ d dlZd dlmZmZmZ 	 ej        j        ZdZn# e$ r  G d d	          Zd
ZY nw xY w e j        e          Z e            Zd>dZ G d d          Z ede eej        j!        e"f         Z!e G d d                      Z#e G d d                      Z$e G d de$                      Z%e G d de$                      Z&e G d de$                      Z'e G d de$                      Z(e G d de$                      Z)e G d de#                      Z*e G d d e#                      Z+e G d! d"e#                      Z,e G d# d$e#                      Z-e G d% d&e$                      Z.ed'e	e
gef         fd(            Z/ed)e0d*e0fd+            Z1ed)e0d*e0d,e0fd-            Z2eefd)e0d*e0d.efd/            Z3eefd)e0d*e0d,e0d.efd0            Z4ed1efd2            Z5ed)e"d*e"fd3            Z6eefd)e"d*e"d.efd4            Z7ed?d)e"d*e"d,e"fd6            Z8eefd)e"d*e"d,e"d.efd7            Z9ed@d:e0d;e0fd<            Z:ed:e0d;e0d,e0fd=            Z;dS )A    N)copy)	signature)isclose)AnyCallableDictListOptionalSequenceUnion)DeveloperAPI	PublicAPIRayDeprecationWarningFc                       e Zd ZdS )np_random_generatorN)__name__
__module____qualname__     j/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/tune/search/sample.pyr   r      s        r   r   Treturnc                  >    t          j        dt          d           d S )Nz`The `base` argument is deprecated. Please remove it as it is not actually needed in this method.   )
stacklevel)warningswarnr   r   r   r   _warn_for_baser      s3    ML 	     r   c                       e Zd ZdZdZ	 ddeedej        j	        e
f                  fdZedefd            Zed             Zd	edefd
ZdS )_BackwardsCompatibleNumpyRngzhThin wrapper to ensure backwards compatibility between
    new and old numpy randomness generators.
    Ngenerator_or_seedr   c                 
   |&t          |t          j        j        t          f          r	|| _        d S t          r&t          j                            |          | _        d S t          j                            |          | _        d S N)
isinstancenprandomRandomStater   _rng
LEGACY_RNGdefault_rng)selfr!   s     r   __init__z%_BackwardsCompatibleNumpyRng.__init__0   sw     $
	 57JK)
 )
$ *DIII 	A	--.?@@DIII	--.?@@DIIIr   r   c                 8    t          | j        t                     S r#   )r$   r(   r   r+   s    r   
legacy_rngz'_BackwardsCompatibleNumpyRng.legacy_rng?   s    di)<====r   c                 6    | j         | j         nt          j        S r#   )r(   r%   r&   r.   s    r   rngz _BackwardsCompatibleNumpyRng.rngC   s     !I1tyyry@r   namec                 \    | j         r|dk    rd}n|dk    rd}t          | j        |          S )Nintegersrandintr&   rand)r/   getattrr1   )r+   r2   s     r   __getattr__z(_BackwardsCompatibleNumpyRng.__getattr__H   s@    ? 	z!! !!tx&&&r   r#   )r   r   r   __doc__r(   r
   r   r%   r&   r'   intr,   propertyboolr/   r1   strr   r8   r   r   r   r    r    )   s          D 	A A#')>CD
A A A A >D > > > X> A A XA' ' ' ' ' ' ' 'r   r    c                       e Zd ZdZdZdZd ZddZd Z	 	 	 dde	e
ee         ef                  d	ed
dfdZd Zd ZdefdZed             ZdS )Domaina  Base class to specify a type and valid range to sample parameters from.

    This base class is implemented by parameter spaces, like float ranges
    (``Float``), integer ranges (``Integer``), or categorical variables
    (``Categorical``). The ``Domain`` object contains information about
    valid values (e.g. minimum and maximum values), and exposes methods that
    allow specification of specific samplers (e.g. ``uniform()`` or
    ``loguniform()``).

    Nc                     |S )zCast value to domain typer   r+   values     r   castzDomain.castg   s    r   Fc                     | j         r5|s3t          d                    | j        j        | j         |                    || _         d S )NzmYou can only choose one sampler for parameter domains. Existing sampler for parameter {}: {}. Tried to add {})sampler
ValueErrorformat	__class__r   )r+   rE   allow_overrides      r   set_samplerzDomain.set_samplerk   sT    < 	 	&&,fN+T\7' '   r   c                 @    | j         }|s|                                 }|S r#   )rE   default_sampler_cls)r+   rE   s     r   get_samplerzDomain.get_samplerv   s'    , 	1..00Gr      configsizerandom_stater'   c                     t          |t                    st          |          }|                                 }|                    | |||          S )N)rO   rP   rQ   )r$   r    rM   sample)r+   rO   rP   rQ   rE   s        r   rS   zDomain.sample|   sP     ,(DEE 	F7EEL""$$~~d6<~XXXr   c                 6    t          | j        t                    S r#   )r$   rE   Gridr.   s    r   is_gridzDomain.is_grid   s    $,---r   c                     dS )NFr   r.   s    r   is_functionzDomain.is_function   s    ur   rB   c                     t           )z8Returns True if `value` is a valid value in this domain.NotImplementedErrorrA   s     r   is_validzDomain.is_valid   s    !!r   c                     dS )Nz	(unknown)r   r.   s    r   
domain_strzDomain.domain_str   s    {r   )FNrN   N)r   r   r   r9   rE   rL   rC   rJ   rM   r
   r   r	   r   r:   rS   rV   rX   r   r\   r;   r^   r   r   r   r?   r?   W   s       	 	 G  	 	 	 	   59&*		Y 	YtDz4/01	Y 	Y $		Y 	Y 	Y 	Y. . .  "c " " " "   X  r   r?   c            	       V    e Zd Z	 	 	 d	dedeeee         ef                  deddfdZ	dS )
SamplerNrN   domainrO   rP   rQ   r'   c                     t           r#   rZ   r+   rb   rO   rP   rQ   s        r   rS   zSampler.sample   s
     "!r   r_   )
r   r   r   r?   r
   r   r	   r   r:   rS   r   r   r   ra   ra      sq        
 59&*" "" tDz4/01" 	"
 $" " " " " "r   ra   c                       e Zd Zd ZdS )BaseSamplerc                     dS )NBaser   r.   s    r   __str__zBaseSampler.__str__   s    vr   Nr   r   r   ri   r   r   r   rf   rf      s#            r   rf   c                       e Zd Zd ZdS )Uniformc                     dS )Nrl   r   r.   s    r   ri   zUniform.__str__   s    yr   Nrj   r   r   r   rl   rl      s#            r   rl   c                   $    e Zd ZefdefdZd ZdS )
LogUniformbasec                 8    |t           urt                       d S d S r#   )_MISSINGr   )r+   rp   s     r   r,   zLogUniform.__init__   s'    x  r   c                     dS )Nro   r   r.   s    r   ri   zLogUniform.__str__   s    |r   N)r   r   r   rr   objectr,   ri   r   r   r   ro   ro      sF        &.  V        r   ro   c                   &    e Zd ZddedefdZd ZdS )Normal        meansdc                 L    || _         || _        | j        dk    s
J d            d S )Nr   z$SD has to be strictly greater than 0rx   ry   )r+   rx   ry   s      r   r,   zNormal.__init__   s*    	w{{{B{{{{{r   c                     dS )Nrv   r   r.   s    r   ri   zNormal.__str__   s    xr   N)rw   rw   )r   r   r   floatr,   ri   r   r   r   rv   rv      sQ        C CU Ce C C C C    r   rv   c            	       Z    e Zd ZdZ	 	 	 d
dedeeee         ef                  de	ddfd	Z
dS )rU   z"Dummy sampler used for grid searchNrN   rb   rO   rP   rQ   r'   c                      t          d          S )NzDo not call `sample()` on grid.)RuntimeErrorrd   s        r   rS   zGrid.sample   s     =>>>r   r_   )r   r   r   r9   r?   r
   r   r	   r   r:   rS   r   r   r   rU   rU      sw        ,,
 59&*? ?? tDz4/01? 	?
 $? ? ? ? ? ?r   rU   c                       e Zd Z G d de          Z G d de          Z G d de          ZeZ	de
e         de
e         fd	Zd
 Zd ZefdefdZddZdefdZdefdZed             ZdS )Floatc            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Float._UniformNrN   rb   r   rO   rP   rQ   r'   c                 v   t          |t                    st          |          }|j        t          d          k    s
J d            |j        t          d          k     s
J d            |                    |j        |j        |          }t          |          dk    r|n|                    |d                   S )N-infzUniform needs a lower boundinfzUniform needs a upper boundrP   rN   r   )r$   r    lowerr}   upperuniformlenrC   r+   rb   rO   rP   rQ   itemss         r   rS   zFloat._Uniform.sample   s     l,HII J;LII<%--///1N///<%,,...0M... ((v|$(OOEJJNN55E!H0E0EEr   r_   	r   r   r   r
   r   r	   r   r:   rS   r   r   r   _Uniformr      s|         9=*.	F 	F	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r   c            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Float._LogUniformNrN   rb   r   rO   rP   rQ   r'   c                    t          |t                    st          |          }|j        dk    s
J d            d|j        cxk     rt	          d          k     sn J d            t          j        |j                  }t          j        |j                  }t          j        |                    |||                    }t          |          dk    r|n|
                    |d                   S Nr   z-LogUniform needs a lower bound greater than 0r   z-LogUniform needs a upper bound greater than 0r   rN   )r$   r    r   r   r}   r%   logexpr   r   rC   r+   rb   rO   rP   rQ   logminlogmaxr   s           r   rS   zFloat._LogUniform.sample   s     l,HII J;LII<!###%T###FL////5<</////> 0//VFL))FVFL))FF<//T/JJKKEJJNN55E!H0E0EEr   r_   r   r   r   r   _LogUniformr      s|         9=*.	F 	F	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r   c            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Float._NormalNrN   rb   r   rO   rP   rQ   r'   c                    t          |t                    st          |          }|j        r"|j        t          d          k    s
J d            |j        r"|j        t          d          k    s
J d            |                    | j        | j        |          }t          |          dk    r|n|	                    |d                   S )Nr   z3Normal sampling does not allow a lower value bound.r   z3Normal sampling does not allow a upper value bound.r   rN   r   )
r$   r    r   r}   r   normalrx   ry   r   rC   r   s         r   rS   zFloat._Normal.sample   s     l,HII J;LII| Ev|u8 8 ( ( (D( (  | Ev|u8 8 ( ( (D( (  !''	47'FFEJJNN55E!H0E0EEr   r_   r   r   r   r   _Normalr      s|         9=*.	F 	F	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r   r   r   c                 f    ||nt          d          | _        ||nt          d          | _        d S )Nr   r   )r}   r   r   r+   r   r   s      r   r,   zFloat.__init__  s2    #/UUU6]]
#/UUU5\\


r   c                      t          |          S r#   )r}   rA   s     r   rC   z
Float.cast  s    U||r   c                    | j         t          d          k    st          d          | j        t          d          k     st          d          t	          |           }|                    |                                            |S )Nr   zTUniform requires a lower bound. Make sure to set the `lower` parameter of `Float()`.r   zTUniform requires a upper bound. Make sure to set the `upper` parameter of `Float()`.)r   r}   rF   r   r   rJ   r   r+   news     r   r   zFloat.uniform  s    zE&MM))2   zE%LL((2   4jj(((
r   rp   c                 X   |t           urt                       | j        dk    st          d| j         d          d| j        cxk     rt          d          k     sn t          d| j         d          t          |           }|                    |                                            |S Nr   z6LogUniform requires a lower bound greater than 0.Got: zg. Did you pass a variable that has been log-transformed? If so, pass the non-transformed value instead.r   z7LogUniform requires a upper bound greater than 0. Got: 	rr   r   r   rF   r   r}   r   rJ   r   r+   rp   r   s      r   
loguniformzFloat.loguniform#      xzA~~
     4:,,,,e,,,,
     4jj((**+++
r   rw         ?c                 v    t          |           }|                    |                     ||                     |S r#   )r   rJ   r   )r+   rx   ry   r   s       r   r   zFloat.normal8  s2    4jjT2..///
r   qc                    | j         t          d          k    rHt          | j         |z  t          | j         |z                      st	          d| j          d| d          | j        t          d          k     rHt          | j        |z  t          | j        |z                      st	          d| j         d| d          t          |           }|                    t          |	                                |          d           |S )	Nr   zYour lower variable bound z) is not divisible by quantization factor .r   zYour upper variable bound TrI   )
r   r}   r   roundrF   r   r   rJ   	QuantizedrM   r+   r   r   s      r   	quantizedzFloat.quantized=  s(   :f%%gJNE$*q.11/
 /
% ,TZ , ,'(, , ,   :e$$WJNE$*q.11.
 .
$ ,TZ , ,'(, , ,  
 4jj	#//"3"3Q77MMM
r   rB   c                 6    | j         |cxk    o
| j        k    nc S r#   r   r   rA   s     r   r\   zFloat.is_validQ  (    zU0000dj00000r   c                 (    d| j          d| j         dS N(z, )r   r.   s    r   r^   zFloat.domain_strT      .4:......r   Nrw   r   )r   r   r   rl   r   ro   r   rv   r   rL   r
   r}   r,   rC   r   rr   rt   r   r   r   r\   r;   r^   r   r   r   r   r      s       F F F F F7 F F FF F F F Fj F F F(F F F F F& F F F& #Bhuo Bhuo B B B B
     )1  v    *   
5    (1e 1 1 1 1 / / X/ / /r   r   c                       e Zd Z G d de          Z G d de          ZeZd Zd Z	de
fdZd	 Zefd
efdZde
fdZed             ZdS )Integerc            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Integer._UniformNrN   rb   r   rO   rP   rQ   r'   c                     t          |t                    st          |          }|                    |j        |j        |          }t          |          dk    r|n|                    |d                   S )Nr   rN   r   )r$   r    r4   r   r   r   rC   r   s         r   rS   zInteger._Uniform.sample\  sk     l,HII J;LII ))&,4)PPEJJNN55E!H0E0EEr   r_   r   r   r   r   r   r   [  s|         9=*.
	F 
	F
	F U4:t#345
	F 	
	F
 (
	F 
	F 
	F 
	F 
	F 
	Fr   r   c            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Integer._LogUniformNrN   rb   r   rO   rP   rQ   r'   c                 :   t          |t                    st          |          }|j        dk    s
J d            d|j        cxk     rt	          d          k     sn J d            t          j        |j                  }t          j        |j                  }t          j        |                    |||                    }t          j	        |          
                    t                    }t          |          dk    r|n|                    |d                   S r   )r$   r    r   r   r}   r%   r   r   r   floorastyper:   r   rC   r   s           r   rS   zInteger._LogUniform.samplei  s    l,HII J;LII<!###%T###FL////5<</////> 0//VFL))FVFL))FF<//T/JJKKEHUOO**3//EJJNN55E!H0E0EEr   r_   r   r   r   r   r   r   h  s|         9=*.	F 	F	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r   c                 "    || _         || _        d S r#   r   r   s      r   r,   zInteger.__init__  s    



r   c                      t          |          S r#   )r:   rA   s     r   rC   zInteger.cast  s    5zzr   r   c                     t          |           }|                    t          |                                |          d           |S )NTr   )r   rJ   r   rM   r   s      r   r   zInteger.quantized  s<    4jj	#//"3"3Q77MMM
r   c                 r    t          |           }|                    |                                            |S r#   r   rJ   r   r   s     r   r   zInteger.uniform  ,    4jj(((
r   rp   c                 X   |t           urt                       | j        dk    st          d| j         d          d| j        cxk     rt          d          k     sn t          d| j         d          t          |           }|                    |                                            |S r   r   r   s      r   r   zInteger.loguniform  r   r   rB   c                 6    | j         |cxk    o
| j        k    nc S r#   r   rA   s     r   r\   zInteger.is_valid  r   r   c                 (    d| j          d| j         dS r   r   r.   s    r   r^   zInteger.domain_str  r   r   N)r   r   r   rl   r   ro   r   rL   r,   rC   r:   r   r   rr   rt   r   r\   r;   r^   r   r   r   r   r   Y  s#       F F F F F7 F F FF F F F Fj F F F* #    3    
  
 )1  v    *1c 1 1 1 1 / / X/ / /r   r   c                   t    e Zd Z G d de          ZeZdefdZd Zd Z	d Z
d Zd	efd
Zed             ZdS )Categoricalc            	       V    e Zd Z	 	 	 d
dddeeee         ef                  deddfd	ZdS )Categorical._UniformNrN   rb   r   rO   rP   rQ   r'   c                 @   t          |t                    st          |          }|                    t          j        dt          j                            |          }fd|D             }t          |          dk    r|n                    |d                   S )Nr   r   c                 *    g | ]}j         |         S r   
categories).0indexrb   s     r   
<listcomp>z/Categorical._Uniform.sample.<locals>.<listcomp>  s!    CCC%V&u-CCCr   rN   )r$   r    choicer%   aranger   r   rC   )r+   rb   rO   rP   rQ   indicesr   s    `     r   rS   zCategorical._Uniform.sample  s     l,HII J;LII #))	!S!233444 *  G DCCC7CCCEJJNN55E!H0E0EEr   r_   r   r   r   r   r   r     s|         9=*.	F 	F!	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r   r   c                 .    t          |          | _        d S r#   )listr   )r+   r   s     r   r,   zCategorical.__init__  s    z**r   c                 r    t          |           }|                    |                                            |S r#   r   r   s     r   r   zCategorical.uniform  r   r   c                 f    t          |           }|                    t                                 |S r#   )r   rJ   rU   r   s     r   gridzCategorical.grid  s(    4jj
r   c                 *    t          | j                  S r#   )r   r   r.   s    r   __len__zCategorical.__len__  s    4?###r   c                     | j         |         S r#   r   )r+   items     r   __getitem__zCategorical.__getitem__  s    t$$r   rB   c                     || j         v S r#   r   rA   s     r   r\   zCategorical.is_valid  s    ''r   c                     | j          S r#   r   r.   s    r   r^   zCategorical.domain_str  s    /##r   N)r   r   r   rl   r   rL   r   r,   r   r   r   r   r   r\   r;   r^   r   r   r   r   r     s        F F F F F7 F F F$ #+8 + + + +  
  
$ $ $% % %(c ( ( ( ( $ $ X$ $ $r   r   c                   b    e Zd Z G d de          ZeZdefdZd Zde	fdZ
ed             Zd	S )
Functionc            	       v    e Zd Zdddeeef         fdZ	 	 	 ddddeee	e         ef                  de
dd	fd
ZdS )Function._CallSamplerrb   r   rO   c                     	 |                     |          S # t          t          f$ rE ddlm} |                      |d|i                    }t
                              d           |cY S w xY w)Nr   )_UnresolvedAccessGuardrO   z~sample_from functions that take a spec dict are deprecated. Please update your function to work with the config dict directly.)funcAttributeErrorKeyError!ray.tune.search.variant_generatorr   loggerwarning)r+   rb   rO   r   rs        r   __try_fnzFunction._CallSampler.__try_fn  s    {{6***"H- 	 	 	TTTTTTKK 6 6&7I J JKK0  
 	s    AA-,A-NrN   rP   rQ   r'   c                 0    t          |t                    st          |          }j        r fdt          |          D             }nfdt          |          D             }t	          |          dk    r|n                    |d                   S )Nc                     g | ]I}t          t                    r                    |                   n                              JS r   )r$   r   _CallSampler__try_fn)r   irO   rb   r+   s     r   r   z0Function._CallSampler.sample.<locals>.<listcomp>  sb         &fd33;ffQi888!]]66::	  r   c                 8    g | ]}                                 S r   r   )r   r   rb   s     r   r   z0Function._CallSampler.sample.<locals>.<listcomp>  s!    <<<1<<<r   rN   r   )r$   r    pass_configranger   rC   r   s   ```   r   rS   zFunction._CallSampler.sample  s     l,HII J;LII! 
=      #4[[   =<<<d<<<JJNN55E!H0E0EEr   r_   )r   r   r   r   r=   r   r   r
   r   r	   r:   rS   r   r   r   _CallSamplerr     s        	: 	tCH~ 	 	 	 	" 9=*.	F 	F	F U4:t#345	F 		F
 (	F 	F 	F 	F 	F 	Fr   r  r   c                 
   t          |          }d}	 |                    i            n# t          $ r d}Y nw xY w|s8	 |                                 n"# t          $ r}t          d          |d }~ww xY w|| _        || _        d S )NTFz]The function passed to a `Function` parameter must be callable with either 0 or 1 parameters.)r   bind	TypeErrorrF   r   r   )r+   r   sigr   excs        r   r,   zFunction.__init__  s    oo	 HHRLLLL 	  	  	 KKK	   	



    >   '			s#   ) 88A 
A2A--A2c                     dS NTr   r.   s    r   rX   zFunction.is_function      tr   rB   c                     dS r	  r   rA   s     r   r\   zFunction.is_valid   r
  r   c                     | j          dS )Nz()r   r.   s    r   r^   zFunction.domain_str#  s    )r   N)r   r   r   rf   r  rL   r   r,   rX   r   r\   r;   r^   r   r   r   r   r     s        $F $F $F $F $F{ $F $F $FL 'X    *  c         X     r   r   c            	       |    e Zd Zdedeeef         fdZd Z	 	 	 dde	de
eee         ef                  d	ed
dfdZdS )r   rE   r   c                 D    || _         || _        | j         s
J d            d S )Nz&Quantized() expects a sampler instance)rE   r   )r+   rE   r   s      r   r,   zQuantized.__init__*  s,    |EEEEE|EEr   c                     | j         S r#   )rE   r.   s    r   rM   zQuantized.get_sampler0  s
    |r   NrN   rb   rO   rP   rQ   r'   c                    t          |t                    st          |          }| j        dk    r| j                            ||||          S t          |          }t          j        |j        | j        z            | j        z  |_        t          j	        |j
        | j        z            | j        z  |_
        | j                            ||||          }t          j        t          j        || j                            | j        z  }t          |t          j                  s|                    |          S t          |          S )NrN   )rQ   )r$   r    r   rE   rS   r   r%   ceilr   r   r   r   dividendarrayrC   r   )r+   rb   rO   rP   rQ   quantized_domainvaluesr   s           r   rS   zQuantized.sample3  s    ,(DEE 	F7EEL6Q;;<&&vvt,&WWW<<!#)>!?!?$&!H!#&,*?!@!@46!I$$fd % 
 
 HRYvtv6677$&@	)RZ00 	*;;y)))Ir   r_   )r   r   r   ra   r   r}   r:   r,   rM   r?   r
   r	   r   rS   r   r   r   r   r   (  s        F FE%*,= F F F F   59&*  tDz4/01 	
 $     r   r   r   c                      t          |           S )zSpecify that tune should sample configuration values from this function.

    Arguments:
        func: An callable function to draw a sample from.
    )r   r   s    r   sample_fromr  M  s     D>>r   r   r   c                 F    t          | |                                          S )zSample a float value uniformly between ``lower`` and ``upper``.

    Sampling from ``tune.uniform(1, 10)`` is equivalent to sampling from
    ``np.random.uniform(1, 10))``

    )r   r   r   s     r   r   r   W  s      &&(((r   r   c                 l    t          | |                                                              |          S )a>  Sample a quantized float value uniformly between ``lower`` and ``upper``.

    Sampling from ``tune.uniform(1, 10)`` is equivalent to sampling from
    ``np.random.uniform(1, 10))``

    The value will be quantized, i.e. rounded to an integer increment of ``q``.
    Quantization makes the upper bound inclusive.

    )r   r   r   r   r   r   s      r   quniformr  b  s.     &&((221555r   rp   c                 t    |t           urt                       t          | |                                          S )zSugar for sampling in different orders of magnitude.

    Args:
        lower: Lower boundary of the output interval (e.g. 1e-4)
        upper: Upper boundary of the output interval (e.g. 1e-2)

    )rr   r   r   r   r   r   rp   s      r   r   r   p  s7     8))+++r   c                     |t           urt                       t          | |                                                              |          S )a  Sugar for sampling in different orders of magnitude.

    The value will be quantized, i.e. rounded to an integer increment of ``q``.

    Quantization makes the upper bound inclusive.

    Args:
        lower: Lower boundary of the output interval (e.g. 1e-4)
        upper: Upper boundary of the output interval (e.g. 1e-2)
        q: Quantization number. The result will be rounded to an
            integer increment of this value.

    )rr   r   r   r   r   r   r   r   rp   s       r   qloguniformr   ~  sE     8))++55a888r   r   c                 D    t          |                                           S )zSample a categorical value.

    Sampling from ``tune.choice([1, 2])`` is equivalent to sampling from
    ``np.random.choice([1, 2])``

    )r   r   r   s    r   r   r     s     z""**,,,r   c                 F    t          | |                                          S )a  Sample an integer value uniformly between ``lower`` and ``upper``.

    ``lower`` is inclusive, ``upper`` is exclusive.

    Sampling from ``tune.randint(10)`` is equivalent to sampling from
    ``np.random.randint(10)``

    .. versionchanged:: 1.5.0
        When converting Ray Tune configs to searcher-specific search spaces,
        the lower and upper limits are adjusted to keep compatibility with
        the bounds stated in the docstring above.

    )r   r   r   s     r   r5   r5     s      5%  ((***r   c                 t    |t           urt                       t          | |                                          S )aj  Sample an integer value log-uniformly between ``lower`` and ``upper``.

    ``lower`` is inclusive, ``upper`` is exclusive.

    .. versionchanged:: 1.5.0
        When converting Ray Tune configs to searcher-specific search spaces,
        the lower and upper limits are adjusted to keep compatibility with
        the bounds stated in the docstring above.

    )rr   r   r   r   r  s      r   
lograndintr$    s7     85%  ++---r   rN   c                 l    t          | |                                                              |          S )a  Sample an integer value uniformly between ``lower`` and ``upper``.

    ``lower`` is inclusive, ``upper`` is also inclusive (!).

    The value will be quantized, i.e. rounded to an integer increment of ``q``.
    Quantization makes the upper bound inclusive.

    .. versionchanged:: 1.5.0
        When converting Ray Tune configs to searcher-specific search spaces,
        the lower and upper limits are adjusted to keep compatibility with
        the bounds stated in the docstring above.

    )r   r   r   r  s      r   qrandintr&    s.     5%  ((**44Q777r   c                     |t           urt                       t          | |                                                              |          S )a  Sample an integer value log-uniformly between ``lower`` and ``upper``.

    ``lower`` is inclusive, ``upper`` is also inclusive (!).

    The value will be quantized, i.e. rounded to an integer increment of ``q``.
    Quantization makes the upper bound inclusive.

    .. versionchanged:: 1.5.0
        When converting Ray Tune configs to searcher-specific search spaces,
        the lower and upper limits are adjusted to keep compatibility with
        the bounds stated in the docstring above.

    )rr   r   r   r   r   r  s       r   qlograndintr(    sE     85%  ++--77:::r   rw   r   rx   ry   c                 J    t          dd                              | |          S )zSample a float value normally with ``mean`` and ``sd``.

    Args:
        mean: Mean of the normal distribution. Defaults to 0.
        sd: SD of the normal distribution. Defaults to 1.

    N)r   r   r{   s     r   randnr*    s$     t##D"---r   c                 p    t          dd                              | |                              |          S )aa  Sample a float value normally with ``mean`` and ``sd``.

    The value will be quantized, i.e. rounded to an integer increment of ``q``.

    Args:
        mean: Mean of the normal distribution.
        sd: SD of the normal distribution.
        q: Quantization number. The result will be rounded to an
            integer increment of this value.

    N)r   r   r   )rx   ry   r   s      r   qrandnr,    s2     t##D"--77:::r   )r   N)rN   r   )<loggingr   r   inspectr   mathr   typingr   r   r   r	   r
   r   r   numpyr%   ray.util.annotationsr   r   r   r&   	Generatorr   r)   r   	getLoggerr   r   rt   rr   r   r    r'   r:   r?   ra   rf   rl   ro   rv   rU   r   r   r   r   r   r  r}   r   r  r   r   r   r5   r$  r&  r(  r*  r,  r   r   r   <module>r5     s                       G G G G G G G G G G G G G G G G G G     P O O O O O O O O O	)-JJ           JJJ 
	8	$	$ 688   &' &' &' &' &' &' &' &'R 
&(;RY=RTWW
 ; ; ; ; ; ; ; ;| " " " " " " " "     '   
     g   
             W    
? 
? 
? 
? 
?7 
? 
? 
? C/ C/ C/ C/ C/F C/ C/ C/L P/ P/ P/ P/ P/f P/ P/ P/f -$ -$ -$ -$ -$& -$ -$ -$` F  F  F  F  F v F  F  F R ! ! ! ! ! ! ! !H hvs{+     )5 ) ) ) ) ) 
6E 
6% 
6E 
6 
6 
6 
6 :B 
, 
,e 
,E 
, 
, 
, 
, 
, EM 9 9u 9U 9u 9F 9 9 9 9& -x - - - - +3 +s + + + +" 6> . .c .# .V . . . .  8 8C 8 8 8 8 8 8" ?G ; ;s ;3 ;3 ;f ; ; ; ;& . . . . . . . ; ;E ;e ; ; ; ; ; ;s   A A"!A"