
    ёiw                      S SK Jr  S SKJr  S SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJrJrJr  S S	KJrJrJr  S
SKJrJrJrJr  S
SKJrJrJrJrJr  \(       a  S SKJ r   S SK!J"r"J#r#J$r$  / r% S:       S;S jjr&\ S<       S=S jj5       r'S>S?S jjr(S>S@S jjr)S>S@S jjr*    SA         SBS jjr+\ SC         SDS jj5       r,\" SS/5         SESS.           SFS jjj5       r-      SG                 SHS jjr.     SISSSS .                   SJS! jjjr/\    SK           SLS" jj5       r0  S:SSSS .             SMS# jjjr1\  S:SSSSS$.               SNS% jjj5       r2\" SS/5        S:SSS&.           SOS' jjj5       r3 S>SSSS(.       SPS) jjjr4\" SS*/5          SQSS.           SRS+ jjj5       r5\ SS         STS, jj5       r6     SUSSSS .                   SVS- jjjr7\" SS./SS//5      \    SW           SXS0 jj5       5       r8S SS/SS4           SYS1 jjr9  SZSS2.         S[S3 jjjr:    S\           S]S4 jjr;  S^SSSSS$.               S_S5 jjjr<\  S:SSSSS$.               SNS6 jjj5       r=\" S7S8/5       S`       SaS9 jj5       r>g)b    )annotations)TYPE_CHECKINGN)_C_ops)_current_expected_place)DataType)Variable)in_dynamic_modein_dynamic_or_pir_modein_pir_modeuse_pir_api)param_one_aliasparam_two_aliassize_args_decorator   )check_dtypecheck_shape
check_typecheck_variable_and_dtype)LayerHelper_get_paddle_placeconvert_np_dtype_to_dtype_coredygraph_only)Tensor)	DTypeLike	PlaceLike	ShapeLikexc                4   Ub  [         R                  " X5      n [        5       (       a  [        R                  " U 5      $ [        U S/ SQS5        [        S	0 [        5       D6nUR                  U R                  S9nUR                  SSU 0SU00 S9  SUl        U$ )
a)  

For each element :math:`x_i` in input ``x``, take a sample from the Bernoulli distribution, also called two-point distribution,
with success probability :math:`x_i`. The Bernoulli distribution with success probability :math:`x_i` is a discrete probability
distribution with probability mass function

.. math::
    p(y)=\begin{cases}
        x_i,&y=1\\
        1-x_i,&y=0
    \end{cases}.

Args:
    x (Tensor): The input Tensor, it's data type should be float32, float64.
    p (float|None, optional): If ``p`` is given, the success probability will always be ``p``. Default is None, which means
        to use the success probability specified by input ``x``.
    name (str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor, A Tensor filled samples from Bernoulli distribution, whose shape and dtype are same as ``x``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> paddle.set_device('cpu')  # on CPU device
        >>> paddle.seed(100)

        >>> x = paddle.rand([2,3])
        >>> print(x)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.55355281, 0.20714243, 0.01162981],
         [0.51577556, 0.36369765, 0.26091650]])
        >>> # doctest: -SKIP

        >>> out = paddle.bernoulli(x)
        >>> print(out)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[1., 0., 1.],
         [0., 1., 0.]])
        >>> # doctest: -SKIP

        >>> out = paddle.bernoulli(x, p=0)
        >>> print(out)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0., 0., 0.],
         [0., 0., 0.]])
r   )float32float64float16uint16	bernoullidtypeXOuttypeinputsoutputsattrsTrandint)paddle	full_liker
   r   r$   r   r   locals"create_variable_for_type_inferencer&   	append_opstop_gradient)r   pnamehelperouts        T/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/tensor/random.pyr$   r$   ;   s    n 	}Q""" s?	
 3&(377'' 8 
 	c1Xs|2 	 	
 !
    c                    U R                  SS5        X:  nX:  nU R                  US5        U R                  US5        U $ )at  
This is the inplace version of api ``bernoulli``, which returns a Tensor filled
with random values sampled from a bernoulli distribution. The output Tensor will
be inplaced with input ``x``. Please refer to :ref:`api_paddle_bernoulli`.

Args:
    x(Tensor): The input tensor to be filled with random values.
    p (float|Tensor, optional): The success probability parameter of the output Tensor's bernoulli distribution.
        If ``p`` is float, all elements of the output Tensor shared the same success probability.
        If ``p`` is a Tensor, it has per-element success probabilities, and the shape should be broadcastable to ``x``.
        Default is 0.5
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random values sampled from the bernoulli distribution with success probability ``p`` .

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.set_device('cpu')
        >>> paddle.seed(200)
        >>> x = paddle.randn([3, 4])
        >>> x.bernoulli_()
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0., 1., 0., 1.],
         [1., 1., 0., 1.],
         [0., 1., 0., 0.]])

        >>> x = paddle.randn([3, 4])
        >>> p = paddle.randn([3, 1])
        >>> x.bernoulli_(p)
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[1., 1., 1., 1.],
         [0., 0., 0., 0.],
         [0., 0., 0., 0.]])
              ?)uniform_masked_fill_)r   r6   r7   	ones_mask
zeros_masks        r:   
bernoulli_rC      sB    Z JJsCIJNN9c"NN:s#Hr;   c                   [        5       (       aL  [        R                  " [        R                  " XR                  S9U/5      u  p[
        R                  " X5      $ [        U SSS/S5        [        US/ SQS5        [        R                  " [        R                  " XR                  S9U/5      u  p[        S0 [        5       D6nUR                  [        S5      S9nUR                  SXS.S	U00 S
9  SUl        U$ )aZ  
Returns a tensor filled with random number from the Binomial Distribution, which supports Tensor shape
broadcasting. The returned Tensor's data type is int64.

.. math::

    out_i \sim Binomial (n = count_i, p = prob_i)

Args:
    count(Tensor): A tensor with each element specifying the size of a binomial distribution. The input
        data type should be int32 or int64.
    prob(Tensor): A tensor with each element specifying the probability of success in the binomial experiment.
        The input data type should be bfloat16, float16, float32, float64.
    name(str|None, optional): The default value is None. Normally there is no need for user to set this
        property. For more information, please refer to :ref:`api_guide_Name`.
Returns:
    Tensor, A Tensor filled with binomial random values with the same shape as the broadcasted Tensors of
    ``count`` and ``prob``. The data type is int64.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.set_device('cpu')
        >>> paddle.seed(100)

        >>> n = paddle.to_tensor([10.0, 50.0])
        >>> p = paddle.to_tensor([0.2, 0.6])
        >>> out = paddle.binomial(n, p)
        >>> print(out)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [1 , 31])
        >>> # doctest: -SKIP
r%   countint32int64binomialprob)bfloat16r"   r    r!   )rE   rI   r9   r)   T)rH   )r
   r0   broadcast_tensorscastr&   r   rH   r   r   r2   r3   r   r4   r5   )rE   rI   r7   r8   r9   s        r:   rH   rH      s    H ..[[jj148
 u++ '71CZP 9		
 ..[[jj148
 468477,W5 8 
 	"1CL	 	 	
 !
r;   c                    [        5       (       a  [        R                  " U 5      $ [        U SSS/S5        [	        S	0 [        5       D6nUR                  U R                  S9nUR                  SSU 0SU00 S9  U$ )
a  
Returns a tensor filled with random number from a Poisson Distribution.

.. math::

    out_i \sim Poisson (lambda = x_i)

Args:
    x(Tensor):  A tensor with rate parameter of poisson Distribution. The data type
        should be bfloat16, float16, float32, float64.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
Returns:
    Tensor, A Tensor filled with random number with the same shape and dtype as ``x``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.set_device('cpu')
        >>> paddle.seed(100)

        >>> x = paddle.uniform([2,3], min=1.0, max=5.0)
        >>> out = paddle.poisson(x)
        >>> print(out)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[2., 5., 0.],
         [5., 1., 3.]])
        >>> # doctest: -SKIP
r   r    r!   poissonr%   r'   r(   r)   )rN   )	r
   r   rN   r   r   r2   r3   r&   r4   r   r7   r8   r9   s       r:   rN   rN      s    B ~~a   C)Y)?K3&(377agg7FC8eS\ 	 	
 
r;   c                    [        5       (       a  [        R                  " U 5      $ [        U SSS/S5        [	        S0 [        5       D6nUR                  U R                  S9nUR                  SSU 0SU00 S9  U$ )	a=  
Returns a tensor filled with random number from a Standard Gamma Distribution.

.. math::

    out_i \sim Gamma (alpha = x_i, beta = 1.0)

Args:
    x(Tensor):  A tensor with rate parameter of standard gamma Distribution. The data type
        should be bfloat16, float16, float32, float64.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
Returns:
    Tensor, A Tensor filled with random number with the same shape and dtype as ``x``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.set_device('cpu')
        >>> paddle.seed(100)

        >>> x = paddle.uniform([2,3], min=1.0, max=5.0)
        >>> out = paddle.standard_gamma(x)
        >>> print(out)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[3.35393834, 0.80538225, 0.36511323],
         [6.10344696, 4.28612375, 6.37196636]])
        >>> # doctest: -SKIP
r   r    r!   standard_gammar%   r9   r)   )rQ   )	r
   r   rQ   r   r   r2   r3   r&   r4   rO   s       r:   rQ   rQ   -  s    B $$Q'' sY	*,<	
 ::77agg7F!8CL	 	 	
 
r;   shapec                X    [         R                  " XX#S9n[         R                  " U5      $ )a
  
Returns a Tensor filled with random values sampled from a Log Normal
Distribution, with ``mean``, ``std``.
The Log Normal Distribution is defined as follows

.. math::

    f(x) = \frac{1}{x\sigma\sqrt{2\pi}}e^{-\frac{(\ln{x}-\mu)^2}{2\sigma^2}}

Args:
    mean (float|Tensor, optional): The mean of the output Tensor's underlying normal distribution.
        If ``mean`` is float, all elements of the output Tensor share the same mean.
        If ``mean`` is a Tensor(data type supports float32, float64), it has per-element means.
        Default is 1.0
    std (float|Tensor, optional): The standard deviation of the output Tensor's underlying normal distribution.
        If ``std`` is float, all elements of the output Tensor share the same standard deviation.
        If ``std`` is a Tensor(data type supports float32, float64), it has per-element standard deviations.
        Default is 2.0
    shape (tuple|list|Tensor|None, optional): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. If ``mean`` or ``std``
        is a Tensor, the shape of the output Tensor is the same as ``mean`` or ``std`` , attr ``shape`` is ignored.
        Default is None
    name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random values sampled from a log normal distribution with the underlying normal distribution's ``mean`` and ``std`` .

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(200)

        >>> out1 = paddle.log_normal(shape=[2, 3])
        >>> print(out1)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[4.01107359 , 3.53824377 , 25.79078865],
         [0.83332109 , 0.40513405 , 2.09763741 ]])

        >>> mean_tensor = paddle.to_tensor([1.0, 2.0, 3.0])
        >>> out2 = paddle.log_normal(mean=mean_tensor)
        >>> print(out2)
        Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [4.45330524 , 0.57903880 , 31.82369995])

        >>> std_tensor = paddle.to_tensor([1.0, 2.0, 3.0])
        >>> out3 = paddle.log_normal(mean=mean_tensor, std=std_tensor)
        >>> print(out3)
        Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [10.31321430, 8.97369766 , 35.76752090])
)meanstdrR   r7   )r0   normalexp)rT   rU   rR   r7   normal_samples        r:   
log_normalrY   `  s$    t MMtEMM::m$$r;   c                2    [        XUS9R                  5       $ )a  
This inplace version of api ``log_normal``, which returns a Tensor filled
with random values sampled from a log normal distribution. The output Tensor will
be inplaced with input ``x``. Please refer to :ref:`api_paddle_log_normal`.

Args:
    x (Tensor): The input tensor to be filled with random values.
    mean (float|int, optional): Mean of the output tensor, default is 1.0.
    std (float|int, optional): Standard deviation of the output tensor, default
        is 2.0.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random values sampled from a log normal distribution with the underlying normal distribution's ``mean`` and ``std`` .

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(200)
        >>> x = paddle.randn([3, 4])
        >>> x.log_normal_()
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[3.99360156 , 0.11746082 , 12.14813519, 4.74383831 ],
         [0.36592522 , 0.09426476 , 31.81549835, 0.61839998 ],
         [1.33314908 , 12.31954002, 36.44527435, 1.69572163 ]])
rT   rU   )normal_exp_r   rT   rU   r7   s       r:   log_normal_r_     s    D 1S)..00r;   input   Fr9   c                  [        5       (       a  [        R                  " XX$S9$ [        U S/ SQS5        [	        S0 [        5       D6nUR                  [        S5      S9nUR                  SSU 0SU0XS	.S
9  SUl	        U$ )a,
  
Returns a Tensor filled with random values sampled from a Multinomial
distribution. The input ``x`` is a tensor with probabilities for generating the
random number. Each element in ``x`` should be larger or equal to 0, but not all
0. ``replacement`` indicates whether it is a replaceable sample. If ``replacement``
is True, a category can be sampled more than once.

.. note::
    Alias Support: The parameter name ``input`` can be used as an alias for ``x``.
    For example, ``multinomial(input=tensor_x, ...)`` is equivalent to ``multinomial(x=tensor_x, ...)``.

Args:
    x(Tensor):  A tensor with probabilities for generating the random number. The data type
        should be float32, float64.
        alias: ``input``.
    num_samples(int, optional): Number of samples, default is 1.
    replacement(bool, optional): Whether it is a replaceable sample, default is False.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
    out (Tensor|None, optional): The output Tensor. If set, the result will be stored in this Tensor. Default is None.
Returns:
    Tensor, A Tensor filled with sampled category index after ``num_samples`` times samples.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.seed(100) # on CPU device

        >>> x = paddle.rand([2,4])
        >>> print(x)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.55355281, 0.20714243, 0.01162981, 0.51577556],
         [0.36369765, 0.26091650, 0.18905126, 0.56219709]])
        >>> # doctest: -SKIP

        >>> paddle.seed(200) # on CPU device
        >>> out1 = paddle.multinomial(x, num_samples=5, replacement=True)
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 5], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[3, 3, 0, 0, 0],
         [3, 3, 3, 1, 0]])
        >>> # doctest: -SKIP

        >>> # out2 = paddle.multinomial(x, num_samples=5)
        >>> # InvalidArgumentError: When replacement is False, number of samples
        >>> #  should be less than non-zero categories

        >>> paddle.seed(300) # on CPU device
        >>> out3 = paddle.multinomial(x, num_samples=3)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[3, 0, 1],
         [3, 1, 0]])
        >>> # doctest: -SKIP

rb   r   )r#   r"   r    r!   multinomialrG   r%   r'   r(   )num_samplesreplacementr)   T)rd   )
r
   r   rd   r   r   r2   r3   r   r4   r5   )r   re   rf   r7   r9   r8   s         r:   rd   rd     s    N !!!+GG s?	
 7fh777,W5 8 
 	8CL"-J	 	 	
 !
r;   minmaxc                |   [        5       (       a+  [        U5      n[        R                  " U UUUUUUSSSU5      $ [	        U SSS5        [        US[        [        4S5        [        USSS5        [        S0 [        5       D6nUR                  U5      n	[        U5      n
UR                  SSU 0SU	0UUUUUUU
S	.S
9  U	$ )a  
This OP initializes a variable with random values sampled from a
uniform distribution in the range [min, max). The input_dim_idx used to get the input dimension value which will be used to resize the output dimension.
.. code-block:: text
    *Case 1:
        Given:
            input =[[0.946741  , 0.1357001 , 0.38086128]]    # input.shape=[1,3]
            shape=[2,4]
        result.shape[output_dim_idx] = input.shape[input_dim_idx],
        output_dim_idx = 0,
        input_dim_idx = 0,
        result.shape[0] = input.shape[0],
        then:
            result=[[ 0.3443427 , -0.23056602,  0.3477049 ,  0.06139076]]    # result.shape=[1,4]
   *Case 2:
       Given:
           input =[[0.946741  , 0.1357001 , 0.38086128]]     # input.shape=[1,3]
           shape=[2,4]
           input_dim_idx=1
           output_dim_idx=1
       result.shape[output_dim_idx] = input.shape[input_dim_idx],
       output_dim_idx = 1,
       input_dim_idx = 1,
       result.shape[1] = input.shape[1],
       then:
           result=[[-0.23133647, -0.84195036,  0.21441269],
                   [-0.08774924,  0.25605237, -0.09403259]]    # result.shape=[2,3]
Args:
    input (Tensor): A Tensor. Supported data types: float32, float64.
    shape (tuple|list): A python list or python tuple. The shape of the output Tensor, the data type is int.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of output Tensor. Supported data types: float32, float64. Default float32.
    input_dim_idx (int, optional): An index used to get the input dimension value which will be used to resize the output dimension. Default  0.
    output_dim_idx (int, optional): An index used to indicate the specific dimension that will be replaced by corresponding input dimension value. Default 0.
    min (float, optional): The lower bound on the range of random values to generate, the min is included in the range. Default -1.0.
    max (float, optional): The upper bound on the range of random values to generate, the max is excluded in the range. Default 1.0.
    seed (int, optional):  Random seed used for generating samples. 0 means use a seed generated by the system.Note that if seed is not 0, this operator will always generate the same random numbers every time.
Returns:
    Tensor, A Tensor of the specified shape filled with uniform_random values. The shape of the Tensor is determined by the shape parameter and the specified dimension of the input Tensor.
Examples:
    .. code-block:: pycon

        >>> import paddle
        >>> import paddle.base as base
        >>> from paddle.tensor import random
        >>> paddle.enable_static()
        >>> # example 1:
        >>> input = paddle.static.data(name="input", shape=[1, 3], dtype='float32')
        >>> out_1 = random.uniform_random_batch_size_like(input, [2, 4])
        >>> print(out_1.shape)
        paddle.Size([1, 4])

        >>> # example 2:
        >>> out_2 = random.uniform_random_batch_size_like(input, [2, 4], input_dim_idx=1, output_dim_idx=1)
        >>> print(out_2.shape)
        paddle.Size([2, 3])
r   r>   Input)r    r!   r#   uniform_random_batch_size_likerR   r&   r(   )rR   input_dim_idxoutput_dim_idxrg   rh   seedr&   r)   )rk   )r
   r   r   rk   r   r   listtupler   r   r2   r3   r4   )r`   rR   r&   rl   rm   rg   rh   rn   r8   r9   c_dtypes              r:   rk   rk     s    D *5144
 	
 ((	 uge}.NO((	 FVXFF

3
3E
:C(/G
-*,
	   Jr;   r9   devicerequires_gradc          
        Sn	/ SQn
Uc6  [         R                  R                  5       nXJ;  a  [        U	 SU
 SU 35      e[	        U[
        R                  R                  [
        R                  45      (       d  [        U5      n[	        U[        5      (       a  U[
        R                  R                  R                  [
        R                  R                  R                  [
        R                  R                  [
        R                  R                  4;  a  [        SU 35      eUR                  UR                  :w  a%  [        SUR                   SUR                   35      eUR                  n[!        5       (       a  [#        5       (       a   [         R$                  R'                  U 5      n OR[)        5       (       aC  [         R$                  R+                  U 5      (       a  [         R$                  R-                  U 5      n Uc
  [/        5       O
[1        U5      n[2        R4                  " U [7        U5      [7        U5      X4XS9nUS	L a  S
Ul        U$ [;        X	5        [=        USX5        0 nUUUUS.n[         R$                  R?                  XX	S9  [A        S0 [C        5       D6nURE                  U5      nURG                  SUSU0US9  S	Ul        U$ )a  
Returns a Tensor filled with random values sampled from a Gaussian
distribution, with ``shape`` and ``dtype``.

Args:
    shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
    mean (float|int|complex, optional): Mean of the output tensor, default is 0.0.
    std (float|int, optional): Standard deviation of the output tensor, default
        is 1.0.
    seed (int, optional): Random seed of generator.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the output Tensor.
        Supported data types: bfloat16, float16, float32, float64, complex64, complex128.
        Default is None, use global default dtype (see ``get_default_dtype``
        for details).
    name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
    out(Tensor, optional): The output tensor.
    device(PlaceLike|None, optional): The desired device of returned tensor.
        if None, uses the current device for the default tensor type (see paddle.device.set_device()).
        device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
    requires_grad(bool, optional):  If autograd should record operations on the returned tensor. Default: False.

Returns:
    Tensor, A Tensor filled with random values sampled from a Gaussian
        distribution, with ``shape`` and ``dtype``.
z%gaussian/standard_normal/randn/normal)r    r!   r"   r#   rJ   	complex64
complex128z only supports , but the default dtype is zVif mean is a complex number, dtype should be complex64 or complex128, but got dtype = rThe mean of complex gaussian distribution should be a complex number with real part equal imaginary part, but got  != rb   TFr&   )rT   rU   rn   r&   r+   r-   rR   op_typegaussian_randomr(   r)   )gaussian)$r0   	frameworkget_default_dtype	TypeError
isinstancer   VarDescVarTyper   r   complex	COMPLEX64
COMPLEX128realimag
ValueErrorr
   r	   utilsconvert_shape_to_listr   _contain_varget_int_tensor_listr   r   r   r~   floatr5   r   r   get_shape_tensor_inputsr   r2   r3   r4   )rR   rT   rU   rn   r&   r7   r9   rs   rt   op_type_for_checksupported_dtypesplacetensorr+   r-   r8   s                   r:   r~   r~     s   N @ }  224($%_5E4FFabgahi  edll22DMMBCC*51$  LL  **LL  ++MM##MM$$	
 
 ##('+  99		!;;?99+T$))V  yyLL66u=E]]v||88??LL44U;E ~ $%"6* 	
 5;c
D
 D #(F E-E7$4H	
 	,,e 	- 	
 468477>"CL	 	 	
 !
r;   c                j   [        U[        5      (       a  U R                  [        R                  R
                  R                  [        R                  R
                  R                  [        R                  R                  [        R                  R                  4;  a  [        SU R                   35      eUR                  UR                  :w  a%  [        SUR                   SUR                   35      eUR                  n[        R                  " U [        U5      [        U5      [!        U5      5      $ )a  
This is the inplace version of OP ``gaussian``, which returns a Tensor filled
with random values sampled from a gaussian distribution. The output Tensor will
be inplaced with input ``x``. Please refer to :ref:`api_tensor_gaussian`.

Args:
    x(Tensor): The input tensor to be filled with random values.
    mean (float|int|complex, optional): Mean of the output tensor, default is 0.0.
    std (float|int, optional): Standard deviation of the output tensor, default
        is 1.0.
    seed (int, optional): Random seed of generator.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
Returns:
    Tensor, The input tensor x filled with random values sampled from a gaussian
    distribution.
Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.randn([3, 4])
        >>> paddle.tensor.random.gaussian_(x)
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
            [[ 0.86384124,  0.67328387,  0.21874231, -0.12615913],
            [ 0.69844258,  0.42084831, -0.42476156, -0.00072985],
            [ 1.72819555,  1.87785017,  0.48915744,  0.09235018]])
zVif mean is a complex number, x's dtype should be complex64 or complex128, but dtype = ry   rz   )r   r   r&   r   r   r   r   r   r   r   r   r   r   r   gaussian_inplace_r   int)r   rT   rU   rn   r7   s        r:   	gaussian_r     s    J $  77LL  **LL  ++MM##MM$$	
 
  wwi)  99		!;;?99+T$))V  yy##AuT{E#JD	JJr;   c                  Ub  [        U[        R                  R                  [        R                  45      (       dw  [        U5      nU[        R                  R                  R                  [        R                  R                  R                  4;   a  [        U SSUUUUUS9$ [        U SSUUUUUS9$ [        U SSUUUUUS9$ )a  
Returns a Tensor filled with random values sampled from a standard
normal distribution with mean 0 and standard deviation 1, with ``shape``
and ``dtype``.

Args:
    shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the output Tensor.
        Supported data types: float16, bfloat16, float32, float64, complex64, complex128.
        Default is None, use global default dtype (see ``get_default_dtype``
        for details).
    name (str|None, optional): Name for the operation (optional, default is None).
        For more information, please refer to :ref:`api_guide_Name`.
    out(Tensor, optional): The output tensor.
    device(PlaceLike|None, optional): The desired device of returned tensor.
        if None, uses the current device for the default tensor type (see paddle.device.set_device()).
        device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types. Default: None.
    requires_grad(bool, optional):  If autograd should record operations on the returned tensor. Default: False.

Returns:
    Tensor, A Tensor filled with random values sampled from a standard
        normal distribution with mean 0 and standard deviation 1, with
        ``shape`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # doctest: +SKIP("Random output")
        >>> # example 1: attr shape is a list which doesn't contain Tensor.
        >>> out1 = paddle.standard_normal(shape=[2, 3])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.33719197, -0.25688133, -0.42868865],
         [-0.27804616, -0.25058213, -0.28209466]])
        >>> # doctest: -SKIP

        >>> # example 2: attr shape is a list which contains Tensor.
        >>> dim1 = paddle.to_tensor(2, 'int64')
        >>> dim2 = paddle.to_tensor(3, 'int32')
        >>> out2 = paddle.standard_normal(shape=[dim1, dim2, 2])
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[ 0.81888396, -0.64831746],
          [ 1.28911388, -1.88154876],
          [-0.03271919, -0.32410008]],
         [[-0.20224631,  0.46683890],
          [ 1.91947734,  0.71657443],
          [ 0.33410960, -0.64256823]]])
        >>> # doctest: -SKIP

        >>> # example 3: attr shape is a Tensor, the data type must be int64 or int32.
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out3 = paddle.standard_normal(shape_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 0.01182475, -0.44895259, -1.79227340],
         [ 1.52022707, -0.83830303,  0.05261501]])
        >>> # doctest: -SKIP

        >>> # example 4: attr dtype is complex64.
        >>> paddle.seed(200)
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out4 = paddle.standard_normal(shape_tensor, dtype='complex64')
        >>> print(out4)
        Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[ (0.1375531256198883+0.0932074561715126j) ,
           (0.7955012917518616-0.41801896691322327j),
          (-0.6730020642280579-0.09163688868284225j)],
         [ (0.17453041672706604-0.9002832770347595j),
           (0.16270922124385834-1.3086302280426025j),
           (0.9428746104240417+0.06869460642337799j)]])
                r>   )rR   rT   rU   r&   r7   r9   rs   rt   r=   )r   r   r   r   r   r   r   r~   )rR   r&   r7   r9   rs   rt   s         r:   standard_normalr   F  s    r $$dmm4" " +51LL  **LL  **
 
  +	 	 +	 	 '	
 		
r;   )r9   rs   rt   
pin_memoryc          	        Ub  [        U5      O	[        5       nU(       Ga#  [        5       (       Ga  UGb  [        U[        R
                  [        R                  45      (       d  [        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R
                  " 5       nOw[        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R                  " 5       nO[        SU 35      e[        U UUUUUS9nU(       a  [        5       (       a  UR                  5       nU$ )a  
Returns a Tensor filled with random values sampled from a standard
normal distribution with mean 0 and standard deviation 1, with ``shape``
and ``dtype``.

Args:
    shape (tuple|list|Tensor|*shape): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
        If ``shape`` is *shape, directly pass integers as variable-length arguments (e.g., `randn(2, 3)`).
        alias: ``size``.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the output Tensor.
        Supported data types: float16, bfloat16, float32, float64, complex64, complex128.
        Default is None, use global default dtype (see ``get_default_dtype``
        for details).
    name (str|None, optional): Name for the operation (optional, default is None).
        For more information, please refer to :ref:`api_guide_Name`.
    out(Tensor, optional): The output tensor.
    device(PlaceLike|None, optional): The desired device of returned tensor.
    requires_grad(bool, optional):  If autograd should record operations on the returned tensor. Default: False.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor, A Tensor filled with random values sampled from a standard
    normal distribution with mean 0 and standard deviation 1, with
    ``shape`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1: attr shape is a list which doesn't contain Tensor.
        >>> out1 = paddle.randn(shape=[2, 3])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.29270014, -0.02925120, -1.07807338],
         [ 1.19966674, -0.46673676, -0.18050613]])
        >>> # doctest: -SKIP

        >>> # example 2: attr shape is a list which contains Tensor.
        >>> dim1 = paddle.to_tensor(2, 'int64')
        >>> dim2 = paddle.to_tensor(3, 'int32')
        >>> out2 = paddle.randn(shape=[dim1, dim2, 2])
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[-0.26019713,  0.54994684],
          [ 0.46403214, -1.41178775],
          [-0.15682915, -0.26639181]],
         [[ 0.01364388, -2.81676364],
          [ 0.86996621,  0.07524570],
          [ 0.21443737,  0.90938759]]])
        >>> # doctest: -SKIP

        >>> # example 3: attr shape is a Tensor, the data type must be int64 or int32.
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out3 = paddle.randn(shape_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 0.57575506, -1.60349274, -0.27124876],
         [ 1.08381045,  0.81270242, -0.26763600]])
        >>> # doctest: -SKIP

        >>> # example 4: attr dtype is complex64.
        >>> paddle.seed(200)
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out4 = paddle.randn(shape_tensor, dtype='complex64')
        >>> print(out4)
        Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[ (0.1375531256198883+0.0932074561715126j) ,
           (0.7955012917518616-0.41801896691322327j),
          (-0.6730020642280579-0.09163688868284225j)],
         [ (0.17453041672706604-0.9002832770347595j),
           (0.16270922124385834-1.3086302280426025j),
           (0.9428746104240417+0.06869460642337799j)]])
$Pinning memory is not supported for rr   )r   r   r	   r   r   CUDAPinnedPlaceXPUPinnedPlace	CUDAPlacePlaceis_gpu_placeXPUPlaceis_xpu_placeRuntimeErrorr   r   rR   r&   r7   r9   rs   rt   r   r   s           r:   randnr     s   x  	&!$&  	6D$8$8$:M:M#NOOfdnn--vtzz**v/B/B/D/D))+F..vtzz**v/B/B/D/D((*F!EfXNOO#F o''""$Mr;   )rs   rt   c                   Uc  U R                   nUc  U R                  n[        R                  " U 5      n[	        UUUUUS9$ )a  
Returns a tensor with the same size as input that is filled with random numbers from a normal distribution with mean 0 and variance 1.

Args:
    x (Tensor): The input multi-dimensional tensor which specifies shape. The dtype of ``x``
        can be float16, bfloat16, float32, float64, complex64, complex128.
        alias: ``input``.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the
        output tensor. Supported data types: float16, bfloat16, float32, float64, complex64, complex128. If ``dtype`` is None, the data type is the
        same as x's data type. Default is None.
    name (str|None, optional): The default value is None.  Normally there is no
        need for user to set this property.  For more information, please
        refer to :ref:`api_guide_Name`.
    device (str|paddle.Place|None, optional): The device on which to place the created tensor.
        If None, the device is the same as input's device. Default is None.
    requires_grad (bool, optional): Whether to compute gradients for the created tensor.
        Default is False.

Returns:
    Tensor, A Tensor with the same size as input that is filled with random numbers from a normal distribution with mean 0 and variance 1.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1:
        >>> # dtype is None and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out1 = paddle.randn_like(x)
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 0.51785558, -0.10632933]])
        >>> # doctest: -SKIP
        >>> print(out1.dtype)
        paddle.float32

        >>> # example 2:
        >>> # dtype is None and the dtype of x is float64
        >>> x = paddle.zeros((1,2)).astype("float64")
        >>> out2 = paddle.randn_like(x)
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[ 0.64437317, -1.26898670]])
        >>> # doctest: -SKIP
        >>> print(out2.dtype)
        paddle.float64

        >>> # example 3:
        >>> # dtype is float64 and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out3 = paddle.randn_like(x, dtype="float64")
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[ 1.45264642, -1.33133914]])
        >>> # doctest: -SKIP
        >>> print(out3.dtype)
        paddle.float64

        >>> # example 4:
        >>> # device and requires_grad are provided
        >>> x = paddle.zeros((1, 2)).astype("float32")
        >>> out4 = paddle.randn_like(x, device=paddle.CPUPlace(), requires_grad=True)
        >>> print(out4)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float32, place=Place(cpu), stop_gradient=False,
            [[0.78040242, 0.29628819]])
rR   r&   r7   rs   rt   )r&   r   r0   rR   r   )r   r&   r7   rs   rt   rR   s         r:   
randn_liker   E  sJ    ` }~LLOE# r;   )r&   rs   rt   c                   Uc  U R                   nUc  U R                  n[        R                  " U 5      n[	        UUUUUS9$ )a  
Returns a tensor with the same size as input that is filled with random numbers from a uniform distribution on the interval [0, 1).

Args:
    input (Tensor): The input multi-dimensional tensor which specifies shape. The dtype of ``input``
        can be float16, float64, float8_e4m3fn, float32, bfloat16.
    name (str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the
        output tensor. Supported data types: float16, float64, float8_e4m3fn, float32, bfloat16.
        If ``dtype`` is None, the data type is the same as input's data type. Default is None.
    device (str|paddle.Place|None, optional): The device on which to place the created tensor.
        If None, the device is the same as input's device. Default is None.
    requires_grad (bool, optional): Whether to compute gradients for the created tensor.
        Default is False.

Returns:
    Tensor: A Tensor with the same size as input that is filled with random numbers from a uniform distribution on the interval [0, 1).

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1:
        >>> # dtype is None and the dtype of input is float32
        >>> x = paddle.zeros((2, 3)).astype("float32")
        >>> out1 = paddle.rand_like(x)
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.34962332, 0.82356787, 0.91275704],
         [0.12328923, 0.58439839, 0.32735515]])
        >>> # doctest: -SKIP
        >>> print(out1.dtype)
        paddle.float32

        >>> # example 2:
        >>> # dtype is None and the dtype of input is float64
        >>> x = paddle.zeros((2, 3)).astype("float64")
        >>> out2 = paddle.rand_like(x)
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[0.73964721, 0.28413662, 0.91918457],
         [0.62838351, 0.39185921, 0.51561823]])
        >>> # doctest: -SKIP
        >>> print(out2.dtype)
        paddle.float64

        >>> # example 3:
        >>> # dtype is float64 and the dtype of input is float32
        >>> x = paddle.zeros((2, 3)).astype("float32")
        >>> out3 = paddle.rand_like(x, dtype="float64")
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[0.84492219, 0.11572551, 0.73868765],
         [0.90269387, 0.45644298, 0.28739912]])
        >>> # doctest: -SKIP
        >>> print(out3.dtype)
        paddle.float64

        >>> # example 4:
        >>> # with requires_grad=True
        >>> x = paddle.zeros((2, 2)).astype("float32")
        >>> out4 = paddle.rand_like(x, requires_grad=True)
        >>> print(out4.stop_gradient)
        False
r   )r&   r   r0   rR   rand)r`   r7   r&   rs   rt   rR   s         r:   	rand_liker     sK    ^ }~LLE# r;   sizec          	        [        5       (       Gd  [        U S[        [        [        [
        [        R                  R                  4S5        [        US[        [        [
        [        R                  R                  4S5        [        U [
        [        R                  R                  45      (       a  [        U R                  S/ SQSS5        [        U[
        [        R                  R                  45      (       a  [        UR                  SSS/SS5        Ub  [        US5        [        U [        5      (       aF  [        U[        5      (       a  [        UU US	UUS
9$ [        [        R                  " U5      SSS	US9nGO[        U [
        [        R                  R                  45      (       Ga  U R                  [        R                   R"                  R$                  [        R                   R"                  R&                  [        R(                  R$                  [        R(                  R&                  4;   a  [        U[
        [        R                  R                  45      (       a-  [        R                  " U 5      n[        R*                  " X5      nO[        U5      n[        [        R                  " U 5      SSU R                  US9nGO>[        U[
        [        R                  R                  45      (       ag  UR                  U R                  :w  a   [        R,                  " XR                  5      n[        R                  " U 5      n[        R*                  " X5      nO[        U5      n[/        [        R                  " U 5      U R                  U5      nOq[        U[
        [        R                  R                  45      (       a7  [        U 5      n [/        [        R                  " U5      UR                  U5      nO[        X XUS9$ XQ-  U -   n[1        5       (       d  SUl        Ub  [        R4                  " XT5        UnU$ )a  
Returns a Tensor filled with random values sampled from a normal
distribution with ``mean`` and ``std`` (standard deviation).

If ``mean`` is a Tensor, the output Tensor has the same shape and data type as ``mean``.
If ``mean`` is not a Tensor and ``std`` is a Tensor, the output Tensor has the same shape and data type as ``std``.
If ``mean`` and ``std`` are not a Tensor, the output Tensor has the same shape as ``shape``, with data type float32.

If ``mean`` and ``std`` are Tensor, the num of elements of ``mean`` and ``std`` should be the same.

If ``mean`` is a complex number, the output Tensor follows complex normal distribution, with data type complex64.
If ``mean`` is a Tensor with complex data type, the output Tensor has same data type with ``mean``.

.. note::
    Alias Support: The parameter name ``size`` can be used as an alias for ``shape``.
    For example, ``normal(size=[2, 3], ...)`` is equivalent to ``normal(shape=[2, 3], ...)``.

Args:
    mean (float|complex|Tensor, optional): The mean of the output Tensor's normal distribution.
        If ``mean`` is float, all elements of the output Tensor shared the same mean.
        If ``mean`` is a Tensor(data type supports float32, float64, complex64, complex128), it has per-element means.
        Default is 0.0
    std (float|Tensor, optional): The standard deviation of the output Tensor's normal distribution.
        If ``std`` is float, all elements of the output Tensor shared the same standard deviation.
        If ``std`` is a Tensor(data type supports float32, float64), it has per-element standard deviations.
        Default is 1.0
    shape (tuple|list|Tensor|None, optional): Shape of the Tensor to be created. The data type is ``int32`` or ``int64``.
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. If ``mean`` or ``std``
        is a Tensor, the shape of the output Tensor is the same as ``mean`` or ``std``, attr ``shape`` is ignored.
        Default is None
    name (str|None, optional): Name for the operation (optional, default is None).
        For more information, please refer to :ref:`api_guide_Name`.
    out (Tensor|None, optional): Optional output tensor. If provided, the result will be stored in this tensor.
        The ``out`` tensor must have the same shape and dtype as the expected output. Default is None.

Returns:
    Tensor: A Tensor filled with random values sampled from a normal distribution with ``mean`` and ``std``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> out1 = paddle.normal(shape=[2, 3])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.85107994, -0.85490644, -1.35941815],
         [-0.55500370,  0.20964541,  2.24193954]])
        >>> # doctest: -SKIP

        >>> mean_tensor = paddle.to_tensor([1.0, 2.0, 3.0])
        >>> out2 = paddle.normal(mean=mean_tensor)
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [1.05411839, 3.71514320, 3.42665267])
        >>> # doctest: -SKIP

        >>> std_tensor = paddle.to_tensor([1.0, 2.0, 3.0])
        >>> out3 = paddle.normal(mean=mean_tensor, std=std_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [0.48646951, 0.00815189, 3.74022293])
        >>> # doctest: -SKIP

        >>> paddle.seed(200)
        >>> out4 = paddle.normal(mean=1+1j, shape=[2, 3])
        >>> print(out4)
        Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[(1.137553095817566+1.0932074785232544j)  ,
          (1.7955012321472168+0.5819810628890991j) ,
          (0.32699793577194214+0.9083631038665771j)],
         [(1.1745303869247437+0.09971672296524048j),
          (1.1627092361450195-0.30863022804260254j),
          (1.9428746700286865+1.0686945915222168j) ]])

        >>> mean_tensor = paddle.to_tensor([1+1j, 2+2j, 3+3j])
        >>> out5 = paddle.normal(mean=mean_tensor)
        >>> print(out5)
        Tensor(shape=[3], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [(1.136009693145752-0.11074113845825195j),
         (2.529331684112549+2.1968750953674316j) ,
         (2.2910101413726807+1.8114780187606812j)])
rT   rV   rU   )r    r!   rv   rw   zWIf mean is Tensor, it's data type only support float32, float64, complex64, complex128.r    r!   z?If std is Tensor, it's data type only support float32, float64.rv   )rR   rT   rU   r&   r7   r9   r   r>   )rR   rT   rU   r&   r7   )rR   rT   rU   r7   r9   T)r	   r   r   r   r   r   r0   pirValuer   r   r&   r   r~   rR   r   r   r   r   r   r   reshaperL   r   r
   r5   assign)rT   rU   rR   r7   r9   
out_tensor
mean_shapes          r:   rV   rV     s$   @ %(FJJ,<,<=		
 	eXvzz/?/?@(	
 dXvzz'7'7899

Ai cHfjj&6&6788		I&Q x($  c5!!!  "ll3' !J 
D8VZZ%5%56	7	7::LL  **LL  ++MM##MM$$	
 
 #&***:*:;<<#\\$/
nnS5Cj!ll4( jjJ #&***:*:;<<99

* ++c::6C#\\$/
nnS5Cj(d);TZZNJ	C(FJJ$4$45	6	6T{$V\\#%6		4H
eCLL!D(J!###'
 
j&
r;   c                    [        XUS9$ )a  
This is the inplace version of api ``normal``, which returns a Tensor filled
with random values sampled from a normal distribution. The output Tensor will
be inplaced with input ``x``. Please refer to :ref:`api_paddle_normal`.

Args:
    x(Tensor): The input tensor to be filled with random values.
    mean (float|int|complex, optional): Mean of the output tensor, default is 0.0.
    std (float|int, optional): Standard deviation of the output tensor, default
        is 1.0.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
Returns:
    Tensor, A Tensor filled with random values sampled from a normal distribution with ``mean`` and ``std`` .
Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.randn([3, 4])
        >>> x.normal_()
        >>> # doctest: +SKIP('random check')
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 0.06132207,  1.11349595,  0.41906244, -0.24858207],
         [-1.85169315, -1.50370061,  1.73954511,  0.13331604],
         [ 1.66359663, -0.55764782, -0.59911072, -0.57773495]])

r[   )r   r^   s       r:   r\   r\     s    B Qs++r;   c          
        / SQn	Uc4  [         R                  R                  5       nX;  a  [        SU	 SU 35      e[	        U[
        R                  R                  [
        R                  45      (       d  [        U5      n[        5       (       aq  [         R                  R                  U 5      n Uc
  [        5       O
[        U5      n
[        R                   " U U[#        U5      [#        U5      UU
US9nUSL a  SUl        U$ ['        5       (       Gad  [)        U S[*        [,        [         R.                  R0                  4S5        [3        US	U	S5        [)        US
["        [4        [         R.                  R0                  4S5        [)        US["        [4        [         R.                  R0                  4S5        [         R                  R7                  U 5      (       a  [         R                  R9                  U 5      n [	        U[4        5      (       a  [#        U5      n[	        U[4        5      (       a  [#        U5      nUc
  [        5       O
[        U5      n
[        R                   " U UUUUU
US9nUSL a  SUl        U$ [)        U S[*        [,        [:        4S5        [3        US	U	S5        [)        US
["        [4        [:        4S5        [)        US["        [4        [:        4S5        0 nXBX1S.n[         R                  R=                  XU SS9  [?        S0 [A        5       D6nURC                  U5      nURE                  SUUSU0S9  SUl        U$ )a  
Returns a Tensor filled with random values sampled from a uniform
distribution in the range [``min``, ``max``), with ``shape`` and ``dtype``.

Examples:

.. code-block:: text

    Input:
      shape = [1, 2]
    Output:
      result=[[0.8505902, 0.8397286]]

Args:
    shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of the output Tensor.
        Supported data types: float32, float64, complex64, complex128.
        Default is None, use global default dtype (see ``get_default_dtype``
        for details).
    min(float|int, optional): The lower bound on the range of random values
        to generate, ``min`` is included in the range. Default is 0.
    max(float|int, optional): The upper bound on the range of random values
        to generate, ``max`` is excluded in the range. Default is 1.0.
    seed(int, optional): Random seed used for generating samples. If seed is 0,
        it will use the seed of the global default generator (which can be set by paddle.seed).
        Note that if seed is not 0, this operator will always generate the same random numbers every
        time. Default is 0.
    name(str|None, optional): Name for the operation (optional, default is None).
        For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random values sampled from a uniform
    distribution in the range [``min``, ``max``), with ``shape`` and ``dtype``.

Examples:
    .. code-block:: python
        :name: code-example1

        >>> import paddle

        >>> # example 1:
        >>> # attr shape is a list which doesn't contain Tensor.
        >>> out1 = paddle.uniform(shape=[3, 4])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 0.38170254, -0.47945309,  0.39794648, -0.94233936],
         [-0.85296679, -0.76094693,  0.10565400,  0.59155810],
         [ 0.11681318, -0.42144555, -0.81596589,  0.62113667]])
        >>> # doctest: -SKIP

        >>> # example 2:
        >>> # attr shape is a list which contains Tensor.
        >>> dim1 = paddle.to_tensor(2, 'int64')
        >>> dim2 = paddle.to_tensor(3, 'int32')
        >>> out2 = paddle.uniform(shape=[dim1, dim2])
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.00294012, -0.07210171, -0.44236207],
         [ 0.70089281,  0.21500075, -0.22084606]])
        >>> # doctest: -SKIP

        >>> # example 3:
        >>> # attr shape is a Tensor, the data type must be int64 or int32.
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out3 = paddle.uniform(shape_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.60801756,  0.32448411,  0.90269291],
         [-0.66421294, -0.95218551, -0.51022208]])
        >>> # doctest: -SKIP
)r    r!   r"   r#   rv   rw   zuniform/rand only supports rx   rb   TFrR   zuniform/randr&   rg   rh   )rn   rg   rh   r&   r{   uniform_randomr(   )r*   r+   r-   r,   )uniform)#r0   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r5   r   r   ro   rp   r   r   r   r   r   r   r   r   r   r2   r3   r4   )rR   r&   rg   rh   rn   r7   r9   rs   rt   r   r   r   r+   r-   r8   s                  r:   r   r     s   p }  224(-.>-??Z[`Zab  edll22DMMBCC*512259 ~ $%"6* 	
 #J#J
 D #(F 	7T5&***:*:;^	
 	E7$4nE3sFJJ,<,<=~N3sFJJ,<,<=~N<<$$U++LL44U;Ec3*Cc3*C ~ $%"6* 	
 
 D #(F 5'D%#:NKE7$4nE3sH5~F3sH5~F#F,,e^ 	- 	
 3&(377>!CL	 	 	
 !
r;   fromtoc           	     6    [         R                  " XX#SSS5      $ )a  
This is the inplace version of OP ``uniform``, which returns a Tensor filled
with random values sampled from a uniform distribution. The output Tensor will
be inplaced with input ``x``. Please refer to :ref:`api_paddle_uniform`.

Args:
    x(Tensor): The input tensor to be filled with random values.
    min(float|int, optional): The lower bound on the range of random values
        to generate, ``min`` is included in the range. Default is 0.
        Alias: ``from``.
    max(float|int, optional): The upper bound on the range of random values
        to generate, ``max`` is excluded in the range. Default is 1.0.
        Alias: ``to``.
    seed(int, optional): Random seed used for generating samples. If seed is 0,
        it will use the seed of the global default generator (which can be set by paddle.seed).
        Note that if seed is not 0, this operator will always generate the same random numbers every
        time. Default is 0.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.

Returns:
    Tensor, The input tensor x filled with random values sampled from a uniform
    distribution in the range [``min``, ``max``).

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example:
        >>> x = paddle.ones(shape=[3, 4])
        >>> x.uniform_()
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[-0.50484276,  0.49580324,  0.33357990, -0.93924278],
         [ 0.39779735,  0.87677515, -0.24377221,  0.06212139],
         [-0.92499518, -0.96244860,  0.79210341, -0.78228098]])
        >>> # doctest: -SKIP
r   r>   )r   uniform_inplace_)r   rg   rh   rn   r7   s        r:   r?   r?     s    b ""13aC@@r;   c                8   Uc  U S::  a  [        SU  S35      eU nSn UcD  [        R                  R                  R                  n[        5       (       a  [        R                  nOD[        U[        R                  R                  [        R                  45      (       d  [        U5      n[        5       (       a?  [        R                  R                  U5      n[        R                  " XX#[        5       5      $ [!        5       (       a  [#        US5        [%        USSS/S5        [        R                  R'                  U5      (       a  [        R                  R)                  U5      n[        R                  " XX#[        5       5      $ [#        US5        [%        USSS/S5        X:  a  [        SU  S	U 35      e0 nXSUS
.n[        R                  R+                  XVUSS9  [-        S0 [/        5       D6nUR1                  US9nUR3                  SUSU0US9  SUl        U$ )a  
Returns a Tensor filled with random integers from a discrete uniform
distribution in the range [``low``, ``high``), with ``shape`` and ``dtype``.
If ``high`` is None (the default), the range is [0, ``low``).

Args:
    low (int, optional): The lower bound on the range of random values to generate.
        The ``low`` is included in the range. If ``high`` is None, the
        range is [0, ``low``). Default is 0.
    high (int, optional): The upper bound on the range of random values to
        generate, the ``high`` is excluded in the range. Default is None
        (see above for behavior if high = None). Default is None.
    shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list. Default is [1].
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the
        output tensor. Supported data types: int32, int64. If ``dtype``
        is None, the data type is int64. Default is None.
    name (str|None, optional): The default value is None.  Normally there is no
        need for user to set this property.  For more information, please
        refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random integers from a discrete uniform
    distribution in the range [``low``, ``high``), with ``shape`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1:
        >>> # attr shape is a list which doesn't contain Tensor.
        >>> out1 = paddle.randint(low=-5, high=5, shape=[2, 3])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[-1,  4,  4],
         [-2, -5, -2]])
        >>> # doctest: -SKIP

        >>> # example 2:
        >>> # attr shape is a list which contains Tensor.
        >>> dim1 = paddle.to_tensor(2, 'int64')
        >>> dim2 = paddle.to_tensor(3, 'int32')
        >>> out2 = paddle.randint(low=-5, high=5, shape=[dim1, dim2])
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[-4, -4,  2],
         [-3, -1, -5]])
        >>> # doctest: -SKIP

        >>> # example 3:
        >>> # attr shape is a Tensor
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out3 = paddle.randint(low=-5, high=5, shape=shape_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[-1,  4, -3],
         [ 1,  2, -1]])
        >>> # doctest: -SKIP

        >>> # example 4:
        >>> # data type is int32
        >>> out4 = paddle.randint(low=-5, high=5, shape=[3], dtype='int32')
        >>> print(out4)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[3], dtype=int32, place=Place(cpu), stop_gradient=True,
        [4, 4, 0])
        >>> # doctest: -SKIP

        >>> # example 5:
        >>> # Input only one parameter
        >>> # low=0, high=10, shape=[1], dtype='int64'
        >>> out5 = paddle.randint(10)
        >>> print(out5)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,
        [7])
        >>> # doctest: -SKIP

r   @If high is None, low must be greater than 0, but received low = .r/   r&   rF   rG   z6randint's low must less then high, but received low = 	, high = lowhighrn   r&   r{   r%   r(   r)   Tr.   )r   r   r   r   INT64r   r   r   r   r	   r0   r   r   r   r/   r   r   r   r   r   r   r   r   r2   r3   r4   r5   )	r   r   rR   r&   r7   r+   r-   r8   r9   s	            r:   r/   r/     s   v |!8RSVRWWXY  }$$**==NNE 4 4dmmDEE*512259~~u%<%>
 	
 
E9%E7Wg$6	B<<$$U++LL44U;E~~u%<%>
 	
 	E9%E7Wg$6	B;H N! 
 1uE,,eY 	- 	
 3&(377e7D6E3<u 	 	
 !
r;   )	generatorc                  U R                   nUc  US:X  a  [        R                  " U 5      (       aM  U[        R                  :X  a  SnO0U[        R                  :X  a  SnOU[        R
                  :X  a  SnOSnSU-  nO%[        R                  " U5      R                  nOUnSnX:  a  [        SU SU 35      e[        R                  " XU5      $ )	u  
Fills self tensor with numbers sampled from the discrete uniform distribution over [from, to - 1].
If not specified, the values are usually only bounded by self tensor’s data type. However,
for floating point types, if unspecified, range will be [0, 2^mantissa] to ensure that every value is representable.

Args:
    from (int, optional): The lower bound on the range of random values to generate. Default is 0.
    to (int|None, optional): The upper bound on the range of random values to generate. Default is None.
    generator (None): Placeholder for random number generator (currently not implemented, reserved for future use).

Returns:
    Tensor, A Tensor filled with random integers from a discrete uniform
    distribution in the range [``from``, ``to``).


Examples:
    .. code-block:: python

        >>> import paddle

        >>> x = paddle.zeros([3], dtype=paddle.int32)
        >>> x.random_(0, 10)
r      5         r   z:random_ expects 'from' to be less than 'to', but got from=z >= to=)r&   r0   is_floating_pointr    r!   r"   iinforh   r   r   random_)r   from_r   r   r&   mantissas         r:   r   r   W  s    < GGE	zA:''**FNN*!Hfnn,!Hfnn,!H H[\\%(,,BE{HwWYVZ[
 	
 >>!B''r;   c                ,   Uc  US::  a  [        SU S35      eUnSnUc  U R                  nOD[        U[        R                  R
                  [        R                  45      (       d  [        U5      n[        R                  " U 5      nX:  a  [        SU SU 35      e[        5       (       Ga)  [        5       (       aO  [        R                  R                  U5      n[        R                  " XU[        R                   [#        5       5      nO[%        US[&        [(        [        R*                  R,                  4S5        [/        US/ S	QS5        [        R                  R1                  U5      (       a  [        R                  R3                  U5      n[        R                  " XU[        R                   [#        5       5      n[        R4                  " Xc5      nU$ [7        US5        [/        US/ S	QS5        S
U0nUUS[        R                  R
                  R                   S.n[9        S0 [;        5       D6n	U	R=                  [        R                  R
                  R                   S9nU	R?                  SUSU0US9  SUl         [        R4                  " Xc5      nU$ )a  
Returns a Tensor filled with random integers from a discrete uniform
distribution in the range [``low``, ``high``), with the same shape as ``x``.
(use ``dtype`` if ``dtype`` is not None)
If ``high`` is None (the default), the range is [0, ``low``).

Args:
    x (Tensor): The input multi-dimensional tensor which specifies shape. The dtype of ``x``
        can be bool, int32, int64, float16, float32, float64.
    low (int, optional): The lower bound on the range of random values to generate.
        The ``low`` is included in the range. If ``high`` is None, the
        range is [0, ``low``). Default is 0.
    high (int|None, optional): The upper bound on the range of random values to
        generate, the ``high`` is excluded in the range. Default is None.
        If ``high`` is None, the range is [0, ``low``).
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the
        output tensor. Supported data types: bool, int32, int64, float16,
        float32, float64. If ``dtype`` is None, the data type is the
        same as x's data type. Default is None.
    name (str|None, optional): The default value is None.  Normally there is no
        need for user to set this property.  For more information, please
        refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor filled with random integers from a discrete uniform
    distribution in the range [``low``, ``high``), with ``shape`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1:
        >>> # dtype is None and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out1 = paddle.randint_like(x, low=-5, high=5)
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0., 0.]])
        >>> # doctest: -SKIP
        >>> print(out1.dtype)
        paddle.float32

        >>> # example 2:
        >>> # dtype is None and the dtype of x is float64
        >>> x = paddle.zeros((1,2)).astype("float64")
        >>> out2 = paddle.randint_like(x, low=-5, high=5)
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[ 4., -5.]])
        >>> # doctest: -SKIP
        >>> print(out2.dtype)
        paddle.float64

        >>> # example 3:
        >>> # dtype is None and the dtype of x is int32
        >>> x = paddle.zeros((1,2)).astype("int32")
        >>> out3 = paddle.randint_like(x, low=-5, high=5)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=int32, place=Place(cpu), stop_gradient=True,
        [[ 0, -4]])
        >>> # doctest: -SKIP
        >>> print(out3.dtype)
        paddle.int32

        >>> # example 4:
        >>> # dtype is None and the dtype of x is int64
        >>> x = paddle.zeros((1,2)).astype("int64")
        >>> out4 = paddle.randint_like(x, low=-5, high=5)
        >>> print(out4)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[ 4, -3]])
        >>> # doctest: -SKIP
        >>> print(out4.dtype)
        paddle.int64

        >>> # example 5:
        >>> # dtype is float64 and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out5 = paddle.randint_like(x, low=-5, high=5, dtype="float64")
        >>> print(out5)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=float64, place=Place(cpu), stop_gradient=True,
        [[3., 1.]])
        >>> # doctest: -SKIP
        >>> print(out5.dtype)
        paddle.float64

        >>> # example 6:
        >>> # dtype is bool and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out6 = paddle.randint_like(x, low=-5, high=5, dtype="bool")
        >>> print(out6)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=bool, place=Place(cpu), stop_gradient=True,
        [[False, True ]])
        >>> # doctest: -SKIP
        >>> print(out6.dtype)
        paddle.bool

        >>> # example 7:
        >>> # dtype is int32 and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out7 = paddle.randint_like(x, low=-5, high=5, dtype="int32")
        >>> print(out7)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=int32, place=Place(cpu), stop_gradient=True,
        [[-2, -2]])
        >>> # doctest: -SKIP
        >>> print(out7.dtype)
        paddle.int32

        >>> # example 8:
        >>> # dtype is int64 and the dtype of x is float32
        >>> x = paddle.zeros((1,2)).astype("float32")
        >>> out8 = paddle.randint_like(x, low=-5, high=5, dtype="int64")
        >>> print(out8)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[-5,  4]])
        >>> # doctest: -SKIP
        >>> print(out8.dtype)
        paddle.int64

        >>> # example 9:
        >>> # dtype is int64 and the dtype of x is bool
        >>> x = paddle.zeros((1,2)).astype("bool")
        >>> out9 = paddle.randint_like(x, low=-5, high=5, dtype="int64")
        >>> print(out9)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[1, 2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[ 1, -2]])
        >>> # doctest: -SKIP
        >>> print(out9.dtype)
        paddle.int64

r   r   r   z;randint_like's low must less then high, but received low = r   rR   randint_liker&   )boolr"   r    r!   rF   rG   ShapeTensorr   r/   r%   r(   r)   Tr.   )!r   r&   r   r   r   r   r   r   r0   rR   r
   r	   r   r   r   r/   r   r   r   ro   rp   r   r   r   r   r   rL   r   r   r2   r3   r4   r5   )
r   r   r   r&   r7   rR   r9   r+   r-   r8   s
             r:   r   r     sO   h |!8RSVRWWXY  }%$,,"6"6!FGG.u5ELLOE
{I# OV
 	

 LL66u=E..5(..2I2KC ufjj../	 K	 ||((//88?..5(..2I2KC kk#%
E>*G		
  '\\))//	
 3&(377,,&&,, 8 
 	6E3<u 	 	
 !kk#%
r;   c                  Ub  [        U5      O	[        5       nU(       Ga#  [        5       (       Ga  UGb  [        U[        R
                  [        R                  45      (       d  [        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R
                  " 5       nOw[        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R                  " 5       nO[        SU 35      e[        U[        R                  R                  [        R                   R                  R"                  45      (       d  [%        U5      n['        5       (       aI  [(        R*                  " XXCS9nUSL a  SUl        U(       a  [        5       (       a  UR/                  5       nU$ U S:  a  [1        S5      e[3        US/ SQS	5        [5        S0 [7        5       D6nUR9                  U5      nXS
S.n	UR;                  S	0 SU0U	S9  SUl        U$ )a0  
Returns a 1-D Tensor filled with random permutation values from 0
to n-1, with ``dtype``.

Args:
    n (int): The upper bound (exclusive), and it should be greater than 0.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of
        the output Tensor. Supported data types: int32, int64, float32,
        float64. Default is int64.
    name (str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
    out(Tensor, optional): The output tensor.
    device(PlaceLike|None, optional): The desired device of returned tensor.
    requires_grad(bool, optional):  If autograd should record operations on the returned tensor. Default: False.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor, A 1-D Tensor filled with random permutation values from 0
    to n-1, with ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> out1 = paddle.randperm(5)
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[5], dtype=int64, place=Place(cpu), stop_gradient=True,
        [3, 0, 1, 4, 2])
        >>> #doctest: -SKIP

        >>> out2 = paddle.randperm(7, 'int32')
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[7], dtype=int32, place=Place(cpu), stop_gradient=True,
        [3, 2, 0, 6, 5, 4, 1])
        >>> #doctest: -SKIP

r   rb   TFra   z4The input n should be greater than 0 in randperm op.r&   )rG   rF   r    r!   randpermr   )nr&   rn   r(   r)   )r   )r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r0   r   r   r   r
   r   r   r5   r   r   r   r   r2   r3   r4   )
r   r&   r7   r9   rs   rt   r   r   r8   r-   s
             r:   r   r   n  s   j  	&!$&  	6D$8$8$:M:M#NOOfdnn--vtzz**v/B/B/D/D))+F..vtzz**v/B/B/D/D((*F!EfXNOOedll22FJJOO4L4LMNN*516;D #(F /++&&(Fq5F  	7Dj	
 468477>3BE 	 	
 !
r;   c                  Ub  [        U5      O	[        5       nU(       Ga#  [        5       (       Ga  UGb  [        U[        R
                  [        R                  45      (       d  [        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R
                  " 5       nOw[        U[        R                  5      (       d4  [        U[        R                  5      (       a+  UR                  5       (       a  [        R                  " 5       nO[        SU 35      e[        U USSUUUUS9nU(       a  [        5       (       a  UR                  5       nU$ )a   
Returns a Tensor filled with random values sampled from a uniform
distribution in the range [0, 1), with ``shape`` and ``dtype``.

Args:
    shape (tuple|list|Tensor): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        If ``shape`` is a list or tuple, each element of it should be integer or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
        If ``shape`` is *shape, directly pass integers as variable-length arguments (e.g., `rand(2, 3)`).
        alias: ``size``.
    dtype (str|np.dtype|paddle.dtype|None, optional): The data type of the output Tensor.
        Supported data types: float32, float64.
        Default is None, use global default dtype (see :ref:`get_default_dtype`
        for details).
    name (str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
    out(Tensor, optional): The output tensor.
    device(PlaceLike|None, optional): The desired device of returned tensor.
    requires_grad(bool, optional):  If autograd should record operations on the returned tensor. Default: False.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor, A Tensor filled with random values sampled from a uniform
    distribution in the range [0, 1), with ``shape`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1: attr shape is a list which doesn't contain Tensor.
        >>> out1 = paddle.rand(shape=[2, 3])
        >>> print(out1)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.68532258, 0.69431782, 0.44835982],
         [0.13204314, 0.48128194, 0.36574543]])
        >>> # doctest: -SKIP

        >>> # example 2: attr shape is a list which contains Tensor.
        >>> dim1 = paddle.to_tensor(2, 'int64')
        >>> dim2 = paddle.to_tensor(3, 'int32')
        >>> out2 = paddle.rand(shape=[dim1, dim2, 2])
        >>> print(out2)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[0.62102991, 0.45255184],
          [0.81386960, 0.22463219],
          [0.87946558, 0.28097662]],
         [[0.36565998, 0.63203937],
          [0.58640617, 0.92696166],
          [0.85060406, 0.38138932]]])
        >>> # doctest: -SKIP

        >>> # example 3: attr shape is a Tensor, the data type must be int64 or int32.
        >>> shape_tensor = paddle.to_tensor([2, 3])
        >>> out3 = paddle.rand(shape_tensor)
        >>> print(out3)
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.77650446, 0.12870903, 0.05153799],
         [0.27029657, 0.03963696, 0.42487794]])
        >>> # doctest: -SKIP
r   r=   r>   )rR   r&   rg   rh   r7   r9   rs   rt   )r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   s           r:   r   r     s#   \  	&!$&  	6D$8$8$:M:M#NOOfdnn--vtzz**v/B/B/D/D))+F..vtzz**v/B/B/D/D((*F!EfXNOO#	F o''""$Mr;   lamlambdc                    [        5       (       a  [        R                  " X5      $ [        U S/ SQS5        [	        S0 [        5       D6nUR                  SSU 0SU 0SU0S9  U $ )	a  
This inplace OP fill input Tensor ``x`` with random number from a Exponential Distribution.

``lam`` is :math:`\lambda` parameter of Exponential Distribution.

.. math::

    f(x) = \lambda e^{-\lambda x}

.. note::
    Alias Support: The parameter name ``lambd`` can be used as an alias for ``lam``.
    For example, ``exponential_(tensor_x, lambd=1.0, ...)`` is equivalent to ``exponential_(tensor_x, lam=1.0, ...)``.

Args:
    x(Tensor):  Input tensor. The data type should be float32, float64.
    lam(float, optional): :math:`\lambda` parameter of Exponential Distribution. Default, 1.0.
        alias: ``lambd``.
    name(str|None, optional): The default value is None. Normally there is no
        need for user to set this property. For more information, please
        refer to :ref:`api_guide_Name`.
Returns:
    Tensor, Input Tensor ``x``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.set_device('cpu')
        >>> paddle.seed(100)

        >>> x = paddle.empty([2,3])
        >>> x.exponential_()
        >>> # doctest: +SKIP("Random output")
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[0.80643415, 0.23211166, 0.01169797],
         [0.72520679, 0.45208144, 0.30234432]])
        >>> # doctest: -SKIP

r   )r"   r    r!   r#   exponentialr'   r(   lambdar)   )r   )r
   r   exponential_r   r   r2   r4   )r   r   r7   r8   s       r:   r   r   D	  st    V ""1** s?	
 7fh78AJS/	 	 	
 r;   )NN)r   r   r6   zfloat | Noner7   
str | Nonereturnr   )g      ?N)r   r   r6   float | Tensorr7   r   r   r   )N)rE   r   rI   r   r7   r   r   r   )r   r   r7   r   r   r   )r>          @NN)
rT   r   rU   r   rR   ShapeLike | Noner7   r   r   r   )r>   r   N)
r   r   rT   r   rU   r   r7   r   r   r   )ra   FN)r   r   re   r   rf   r   r7   r   r9   Tensor | Noner   r   )r    r   r   g      r>   r   )r`   r   rR   r   r&   r   rl   r   rm   r   rg   r   rh   r   rn   r   r   r   )r=   r>   r   NN)rR   r   rT   r   rU   r   rn   r   r&   DTypeLike | Noner7   r   r9   paddle.Tensor | Noners   PlaceLike | Nonert   r   r   r   )r=   r>   r   N)r   r   rT   r   rU   r   rn   r   r7   r   r   r   )rR   r   r&   r   r7   r   r9   r   rs   r   rt   r   r   r   )rR   r   r&   r   r7   r   r9   r   rs   r   rt   r   r   r   r   r   )r   r   r&   r   r7   r   rs   r   rt   r   r   r   )r7   r   r&   r   rs   r   rt   r   )r=   r>   NN)rT   zcomplex | TensorrU   r   rR   r   r7   r   r9   r   r   r   )r=   r>   N)
r   r   rT   r   rU   r   r7   r   r   r   )Nr   r>   r   N)rR   r   r&   r   rg   r   rh   r   rn   r   r7   r   r9   r   rs   r   rt   r   r   r   )r   r>   r   N)r   r   rg   r   rh   r   rn   r   r7   r   r   r   )r   r   r   
int | NonerR   r   r&   r   r7   r   r   r   )r   N)
r   r   r   r   r   r   r   Noner   r   )r   NNN)r   r   r   r   r   r   r&   r   r7   r   r   r   )rG   N)r   r   r&   r   r7   r   r9   r   rs   r   rt   r   r   r   r   r   )r>   N)r   r   r   r   r7   r   r   r   )?
__future__r   typingr   r0   r   paddle.base.frameworkr   paddle.base.libpaddler   paddle.common_ops_importr   paddle.frameworkr	   r
   r   r   paddle.utils.decorator_utilsr   r   r   base.data_feederr   r   r   r   r   r   r   r   r   r   r   paddle._typingr   r   r   __all__r$   rC   rH   rN   rQ   rY   r_   rd   rk   r~   r   r   r   r   r   rV   r\   r   r?   r/   r   r   r   r   r    r;   r:   <module>r      s  " #     9 * -     >>
 ;?III-7IIX ;?11 1.811 1h@F+\0h "	;%
;%	;% ;% 	;%
 ;%| GK!1!1!1',!1:D!1!1 !1H #w  	X XXX X 	X 
X X !X| !rrr r 	r
 r 
r 
r r rn "v !%#vv
v 
v 	v
 v v 
v v v vr  5K5K
5K 
5K 	5K
 5K 5K 5Kt #@

 !%#@
@
@
 @

 
@
 @
 @
 @
F  #x
 !%#xxx x
 
x x x x x xv #w  #[
  $[[[ [
 [ [ [ ![@ [ ##[
[ 	[
 [ [| '6"# "	w w
w	w w 	w 
w w $wt IM , , ,). ,<F , ,  ,J #q #qqq 
q 
	q
 q q 
q q q qh %5$-0 /A/A	/A 
/A 	/A
 /A /A  1/Af s"K	K
K K 	K
 K K` 5(
 5(5(5( 	5(
 5( 5(t "\\	\ \ 	\
 \ \B c
 !%#c
cc c
 
c c c c cL  #l
 !%#lll l
 
l l l l l l^ %!"48888'188 #8r;   