
    ёio                   
   S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJrJ	r	  S SK
rS SKrS SKJr  S SKJrJr  S SKJr  S SKJrJrJr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!  S	SK"J#r#  S	SK$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  \(       a$  S SK/J0r0  S SKJ1r1  S SK2J3r3  S SK4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  / r<Sq=SeS jr>SeS jr?   Sf             SgS jjr@    Sh             SiS jjrA Sj       SkS jjrB\" SS/SS/5        SlSSSS.                 SmS jjj5       rC   Sn             SoS  jjrD   Sp         SqS! jjrE  Sr       SsS" jjrF    St           SuS# jjrG   Sp         SvS$ jjrHSwS% jrISSSSS&.         SxS' jjrJ " S( S)\R                  RT                  R                  5      rL\" S*S+/5        SlSSSS,.               SyS- jjj5       rM    Sz               S{S. jjrN\  SlSSSSS/.               S|S0 jjj5       rO\" S*S+/05        SlSSSS,.             S}S1 jjj5       rP\  SlSSSSS/.               S|S2 jjj5       rQ\" S*S+/05        SlSSSS,.             S}S3 jjj5       rR\" S4S5/S6S7/5         S~SSSSS/.                 SS8 jjj5       rS\" SS9/05        SlSSSSS/.                 SS: jjj5       rT    SSSSSSS<.                   SS= jjjrU\" S>S;S?9    SSSSSS@.               SSA jjj5       rVSSB jrW\ S       SSC jj5       rX\ S       SSD jj5       rY\	  Sl       SSE jj5       rZ\	SSSF.       SSG jj5       rZSH rZ S       SSI jjr[ S         SSJ jjr\ S       SSK jjr]   S         SSL jjr^\  SlSSSSS/.               S|SM jjj5       r_\" S*S+/05        SlSSSS,.             S}SN jjj5       r`SSSO jjraSSSP jjrbSlSSQ jjrc SSSR.         SSS jjjrd S       SSU jjre S       SSV jjrf SSSR.         SSW jjjrg\+   S         SSX jj5       rh\+ S       SSY jj5       ri\     S             SSZ jj5       rj\  S         SS[ jj5       rkS\ rl\l" S]5      rm\l" S^5      rn\l" S_5      ro\l" S`5      rp\l" Sa5      rq\l" Sb5      rr\l" Sc5      rs\l" Sd5      rt\l" ST5      ru\l" S5      rvg)    )annotationsN)TYPE_CHECKINGoverload)_C_ops)triltriu)
deprecated)ParamAliasDecoratorparam_one_aliasparam_two_aliassize_args_decorator)inplace_apis_in_dygraph_only   )check_dtype
check_typecheck_variable_and_dtypeconvert_dtype)Variabledevice_guard)	ParamAttr)
LayerHelper_current_expected_place_current_expected_place__get_paddle_placeconvert_np_dtype_to_dtype_coredygraph_onlyin_dynamic_modein_dynamic_or_pir_modein_pir_mode)Sequence)Any)NDArray)	DTypeLikeNestedNumericSequenceNumericParamAttrLike	PlaceLike	ShapeLike
TensorLikeFc                   U [         R                  R                  R                  :X  a$  [         R                  R                  R                  $ U [         R                  R                  R
                  :X  a$  [         R                  R                  R                  $ U [        R                  R                   R                  R                  :X  a.  [        R                  R                   R                  R                  $ U [        R                  R                   R                  R
                  :X  a.  [        R                  R                   R                  R                  $ U $ N)r   VarDescVarType	COMPLEX64FP32
COMPLEX128FP64paddlepirDataTypeFLOAT32FLOAT64dtypes    V/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/tensor/creation.py_complex_to_real_dtyper;   P   s    $$...||##(((	$,,&&11	1||##(((	&**//**44	4zz''///	&**//**55	5zz''///    c                   U [         R                  R                  R                  :X  a$  [         R                  R                  R                  $ U [         R                  R                  R
                  :X  a$  [         R                  R                  R                  $ U [        R                  R                   R                  R                  :X  a.  [        R                  R                   R                  R                  $ U [        R                  R                   R                  R                  :X  a.  [        R                  R                   R                  R                  $ U $ r,   )r   r-   r.   r0   r/   r2   r1   r3   r4   r5   r6   r7   r8   s    r:   _real_to_complex_dtyper>   ]   s    $$)))||##---	$,,&&++	+||##...	&**//**22	2zz''111	&**//**22	2zz''222r<   shapeboolc                   [        U S[        [        [        R                  4S5        U  Ha  n[        US[
        [        R                  [        R                  [        R                  [        R                  [        R                  4S5        Mc     [        US/ SQS5        [        S
0 [        5       D6nUR                  UU UUSS9nUR                  U[         R"                  R$                  R'                  [)        U5      US9S	9  U$ )a  
This function creates a new tensor variable with value in the global block(block 0).

Args:
    shape (list[int]|tuple[int]): Shape of the variable
    value (float): The value of the variable. The new created
                  variable will be filled with it.
    dtype (str): Data type of the variable
    persistable (bool, optional): If this variable is persistable.
                       Default: False
    force_cpu (bool, optional): Force this variable to be on CPU.
                     Default: False
    name (str|None, optional): For detailed information, please refer to
       :ref:`api_guide_Name` . Usually name is no need to set and None by default.

Returns:
    Variable: The created Variable

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.enable_static()
        >>> var = paddle.static.create_global_var(shape=[2,3], value=1.0, dtype='float32',
        ...                                persistable=True, force_cpu=True, name='new_var')
r?   create_global_varitem of shaper9   )
r@   float16float32float64int8int16int32int64uint8uint16T)r9   r?   persistablenamestop_gradient)value	force_cpu)initializer)
global_var)r   listtuplenpndarrayintrK   rG   rH   rI   rJ   r   r   localscreate_global_variableset_variable_initializerr3   nnrR   ConstantInitializerfloat)	r?   rP   r9   rM   rQ   rN   itemhelpervars	            r:   rB   rB   j   s    D ugeRZZ8:MN  	
  	
 	$ 22F

'
' ( C ##II))==,) > 
 $  Jr<   c                d   [        U S[        [        [        R                  4S5        U  Ha  n[        US[
        [        R                  [        R                  [        R                  [        R                  [        R                  4S5        Mc     [        US/ SQS5        [        US[        S5      [        4S5        [        US[        S5      [        R                  R                   R"                  4S5        [%        S
0 ['        5       D6nUc	  [        US	9nUR)                  X0[+        U5      XE5      $ )a:  
This function creates a parameter. The parameter is a learnable variable, which can have
gradient, and can be optimized.

Note:
    This is a very low-level API. This API is useful when you create operator by your self, instead of using layers.

Args:
    shape (list of int): Shape of the parameter
    dtype (str): Data type of the parameter. It can be set as 'float16', 'float32', 'float64'.
    name(str|None, optional): For detailed information, please refer to
       :ref:`api_guide_Name` . Usually name is no need to set and None by default.
    attr (ParamAttr|None, optional): Attribute object of the specified argument. For detailed information, please refer to
       :ref:`api_paddle_ParamAttr` None by default, which means that ParamAttr will be initialized as it is.
    is_bias (bool, optional): This can affect which default initializer is chosen
                   when default_initializer is None. If is_bias,
                   initializer.Constant(0.0) will be used. Otherwise,
                   Xavier() will be used.
    default_initializer (Initializer|None, optional): Initializer for the parameter

Returns:
    The created parameter.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> paddle.enable_static()
        >>> W = paddle.create_parameter(shape=[784, 200], dtype='float32')
r?   create_parameterrC   r9   )
r@   rD   rL   rE   rF   rG   rH   rI   rJ   rK   attrNdefault_initializer)rN   )rc   )r   rT   rU   rV   rW   rX   rK   rG   rH   rI   rJ   r   typer   r3   r\   rR   Initializerr   rY   rc   r   )r?   r9   rN   rd   is_biasre   r_   r`   s           r:   rc   rc      s   L ugeRZZ8:LM 	
  	
 	" tVd4j)46HI	dVYY**667	 8vx8F|d#""]5)7 r<   c                |    [        U S/ SQS5        [        S0 [        5       D6nUR                  UR                  XS9$ )a  
Create a variable, which will hold a Tensor with data type dtype.

Args:
    dtype(str|paddle.dtype|np.dtype, optional): the data type of Tensor to be created, the
        data type is bool, float16, float32, float64, int8, int16, int32 and int64.
    name(string, 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`
    persistable(bool): Set the persistable flag of the create tensor.
        default value is False.

Returns:
    Variable: The tensor to be created according to dtype.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> tensor = paddle.tensor.create_tensor(dtype='float32')
r9   )r@   rD   rE   rF   rG   rI   rI   rJ   create_tensorrN   r9   rM   )rj   )r   r   rY   create_variablerN   )r9   rN   rM   r`   s       r:   rj   rj     sN    . 		
 	 5FH5F!![[ "  r<   stopendnumsteps)outdevicerequires_gradc          	        Uc  [         R                  " 5       nUb  [        U5      O	[        5       nUnU n	Un
[	        U[
        [         R                  R                  45      (       d  [        US[        S5        [	        U[        R                  R                  [         R                  R                  R                  45      (       d  [        U5      n[	        U [
        [         R                  R                  45      (       d   [        S5         [!        S/X0SS9n	SSS5        [	        U[
        [         R                  R                  45      (       d   [        S5         [!        S/X1SS9n
SSS5        [	        U[
        [         R                  R                  45      (       d!  [        S5         [!        S/SUSS9nSSS5        [#        5       (       a)  [$        R&                  " U	U
UUUUS	9nU(       a  S
Ul        U$ [+        5       (       Ga  [-        S0 [/        5       D6n[1        U	R2                  5      n[1        U
R2                  5      n[1        U5      n[	        U [         R                  R                  5      (       a  [5        U R2                  S/ SQS5        O[        U S[        [6        4S5        [	        U[         R                  R                  5      (       a  [5        UR2                  S/ SQS5        O[        US[        [6        4S5        [	        U[         R                  R                  5      (       a  [5        UR2                  SSS/S5        [5        US/ SQS5        US:X  d  US:X  a  US;   d  US:X  d  US:X  a  US:X  a  [9        SU SU SU S35      e[	        U[         R:                  R                  R                  R                  5      (       a'  [         R                  R                  R<                  U   n[$        R&                  " U	U
UUUUS	9nU(       a  S
Ul        U$ [-        S0 [/        5       D6n[1        U	R2                  5      n[1        U
R2                  5      n[1        U5      n[	        U [
        5      (       a  [5        U R2                  S/ SQS5        O[        U S[        [6        4S5        [	        U[
        5      (       a  [5        UR2                  S/ SQS5        O[        US[        [6        4S5        [	        U[
        5      (       a  [5        UR2                  SS/S5        [5        US/ SQS5        US:X  d  US:X  a  US;   d  US:X  d  US:X  a  US:X  a  [9        SU SU SU S35      eUR?                  US9nURA                  SU	U
US.SU0SU/0S9  [	        U[        5      (       a  URB                  RE                  U45        U$ ! , (       d  f       GN= f! , (       d  f       GN~= f! , (       d  f       GN@= f)a<  
Return fixed number of evenly spaced values within a given interval. Note: no gradient calculation is performed.

Args:
    start(int|float|Tensor): The input :attr:`start` is start of range. It is a int, float, \
        or a 0-D Tensor with data type int32, int64, float32 or float64.
    stop(int|float|Tensor): The input :attr:`stop` is end of range. It is a int, float, \
        or a 0-D Tensor with data type int32, int64, float32 or float64.
    num(int|Tensor): The input :attr:`num` is given num of the sequence. It is an int, \
        or a 0-D Tensor with data type int32.
    dtype(str|paddle.dtype|np.dtype|None, optional): The data type of output tensor, it could be
        int32, int64, float32 and float64. Default: if None, the data type is float32.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    out(Tensor|None, optional): Optional output tensor. If provided, the result will be stored in this tensor. \
        The tensor must have the correct shape and dtype. Default: None.
    device(str|paddle.CUDAPlace|paddle.CPUPlace|None, optional): The device where the output tensor will be placed. \
        It can be a string (e.g., 'cpu', 'gpu:0'), a paddle.CUDAPlace, or a paddle.CPUPlace object. \
        If None, the current device context will be used. Default: None.
    requires_grad(bool, optional): Whether the output tensor should have gradient computation enabled. \
        If True, the output tensor's ``stop_gradient`` attribute will be set to False. Default: False.

Returns:
    Tensor: the output data type will be float32, float64. The 1-D tensor with fixed number of evenly spaced values, \
    the data shape of this tensor is :math:`[num]` . If the :attr:`num` is set 1, the output tensor just has \
    the value with input :attr:`start`.

.. note::
    **Alias Support:**

    - The parameter name ``end`` can be used as an alias for ``stop``. \
      For example, ``linspace(start=0, end=10, ...)`` is equivalent to ``linspace(start=0, stop=10, ...)``.
    - The parameter name ``steps`` can be used as an alias for ``num``. \
      For example, ``linspace(start=0, stop=10, steps=5)`` is equivalent to ``linspace(start=0, stop=10, num=5)``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.linspace(0, 10, 5, 'float32')
        >>> print(data.numpy())
        [0. 2.5 5. 7.5 10.]
        >>> data = paddle.linspace(0, 10, 1, 'float32')
        >>> print(data.numpy())
        [0.]

        >>> # Using device parameter
        >>> data = paddle.linspace(0, 10, 5, device='cpu')
        >>> print(data.numpy())
        [0. 2.5 5. 7.5 10.]

        >>> # Using requires_grad parameter
        >>> data = paddle.linspace(0, 10, 5, requires_grad=True)
        >>> print(data.stop_gradient)
        False

Nro   linspacecpu   TrQ   rI   rq   Fstart)rD   rL   rE   rF   rI   rJ   rm   rJ   r9   rF   rE   rI   zThe dtype of start/stop is /z$ but the attr(dtype) of linspace is zL, which may cause data type overflows. Please reset attr(dtype) of linspace.r8   )StartStopNumOutrf   inputsattrsoutputs)ru   )#r3   get_default_dtyper   r   
isinstancer   r4   Valuer   rX   r   r-   r.   r5   r   r   fill_constantr   r   ru   rO   r    r   rY   r   r9   r   r^   
ValueErrorbasevartype_to_datatype"create_variable_for_type_inference	append_opdesc	set_shape)rz   rm   ro   r9   rN   rq   rr   rs   
tensor_numtensor_starttensor_stop
out_tensorr`   start_dtype
stop_dtype	out_dtypes                   r:   ru   ru   C  s7   H }((*  	&!$& 
 JLKcHfjj&6&67883j1edll22FJJOO4L4LMNN*51eh

(8(89::% (!edKL !dXvzz'7'7899% 'UDIK !cHfjj&6&6788% &sGSDIJ !__

 ',J$	4684#L$6$67";#4#45
!%(	eVZZ--..M	 ugU|Z@dFJJ,,--

M	 tVc5\:>c6::++,,		57G*<jII		
 9$y(@117"kW&<W$-k]!J<Gklqkr s] ]  eV[[--55==>>JJOO77>E__

 ',J$4684#L$6$67";#4#45
!%(	eX&&M	 ugU|Z@dH%%

M	 tVc5\:>c8$$		57)Z@I		
 9$y(@117"kW&<W$-k]!J<Gklqkr s] ] 
 77e7D%#!
 E"SEN 	 		
 c3HHv&
S !  !  ! s$   
WW(W/
W
W,/
W>c                    Uc  [         R                  " 5       nUnU nUnUn	[        U[        [         R                  R
                  45      (       d  [        US[        S5        [        U[        R                  R                  [        R                  45      (       d  [        U5      n[        U [        [         R                  R
                  45      (       d!  [        S5         [        S/X@5      nSSS5        [        U[        [         R                  R
                  45      (       d!  [        S5         [        S/XA5      nSSS5        [        U[        [         R                  R
                  45      (       d"  [        S5         [        S/SU5      nSSS5        [        U[        [         R                  R
                  45      (       d!  [        S5         [        S/XC5      n	SSS5        [        5       (       a#  [         R"                  " UUUU	U[%        5       5      $ ['        5       (       a  [)        UR*                  5      n
[)        UR*                  5      n[)        U	R*                  5      n[)        U5      nUS:X  d  U
S:X  d  US:X  a  US;   d  US	:X  d  U
S	:X  d  US	:X  a  US:X  a  [-        S
U
 SU SU SU S3	5      e[        U[         R                  R
                  5      (       a  [/        UR*                  SS/S5        [         R"                  " UUUU	U[%        5       5      $ [1        S0 [3        5       D6n[)        UR*                  5      n
[)        UR*                  5      n[)        U	R*                  5      n[)        U5      n[        U [        5      (       a  [/        U R*                  S/ SQS5        O[        U S[        [4        4S5        [        U[        5      (       a  [/        UR*                  S/ SQS5        O[        US[        [4        4S5        [        U[        5      (       a  [/        UR*                  SS/S5        [        U[        5      (       a  [/        UR*                  S/ SQS5        O[        US[        [4        4S5        [/        US/ SQS5        US:X  d  U
S:X  d  US:X  a  US;   d  US	:X  d  U
S	:X  d  US	:X  a  US:X  a  [-        S
U
 SU SU SU S3	5      eUR7                  US9nUR9                  SUUUU	S.SU0SU/0S9  [        U[        5      (       a  UR:                  R=                  U45        U$ ! , (       d  f       GNQ= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f)a  
Return fixed number of logarithmically-evenly spaced values within the interval \
:math:`[base^{start}, base^{stop}]`.

Notes:
    This API does not compute the gradient.

Args:
    start(int|float|Tensor): The input :attr:`start` is exponent of first entry in \
        the sequence. It is a scalar, or a 0-D Tensor of shape [] with input data \
        type int32, int64, float32 or float64.
    stop(int|float|Tensor): The input :attr:`stop` is exponent of last entry in the \
        sequence. It is a scalar, or a 0-D Tensor of shape [] with input data \
        type int32, int64, float32 or float64.
    num(int|Tensor): The input :attr:`num` is given number of items in the sequence. \
        It is an int scalar, or a 0-D Tensor of shape [] with data type int32.
    base(int|float|Tensor): The input :attr:`base` is base of the logarithm function. \
        It is a scalar, or a 0-D Tensor of shape [] with input data type int32, int64, \
        float32 or float64.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of output tensor, it could be \
        int32, int64, float32 or float64. Default: if None, the data type is float32. \
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor: The output data type will be float32, float64. The 1-D tensor with \
    fixed number of logarithmically-evenly spaced values, the data shape of this \
    tensor is :math:`[num]`. If the :attr:`num` is set 1, the output tensor \
    just has the value with exponential of :attr:`start` with base :attr:`base`.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.logspace(0, 10, 5, 2, 'float32')
        >>> print(data.numpy())
        [1.0000000e+00 5.6568542e+00 3.2000000e+01 1.8101933e+02 1.0240000e+03]
        >>> data = paddle.logspace(0, 10, 1, 2, 'float32')
        >>> print(data.numpy())
        [1.]
Nro   logspacerv   rw   rI   rF   r{   rJ   z The dtype of start/stop/base is r|   z$ but the attr(dtype) of logspace is zL, which may cause data type overflows. Please reset attr(dtype) of logspace.rz   )rE   rF   rI   rJ   rm   r   r9   )rI   rJ   rE   rF   r8   )r}   r~   r   Baser   r   )r   )r3   r   r   r   r4   r   r   rX   r   r-   r.   r5   r   r   r   r   r   r   r   r    r   r9   r   r   r   rY   r^   r   r   r   r   )rz   rm   ro   r   r9   rN   r   r   r   tensor_baser   r   
base_dtyper   r`   rq   s                   r:   r   r   "  s   ` }((*JLKKcHfjj&6&67883j1edll22DMMBCC*51eh

(8(89::% (!e;L !dXvzz'7'7899% 'U9K !cHfjj&6&6788% &sGS9J !dXvzz'7'7899% 'U9K !#%
 	
 
#L$6$67";#4#45
";#4#45
!%(	 i')+*11 g%')(W$2;-qAj\Y}  D  ~E E] ]  c6::++,,		57)Z@#%
 	
 4684#L$6$67";#4#45
";#4#45
!%(	eX&&8	 ugU|Z@dH%%

8	 tVc5\:>c8$$		57)Z@dH%%

8	 tVc5\:>7Dj	

 i')+*11 g%')(W$2;-qAj\Y}  D  ~E E] ] 
 77e7D%#!#	 E"SEN 	 
	
 c3HHv&
K !  !  !  ! s0    T80U
 UU.8
U

U
U+.
U=c           	     
         SS jn[        U [        R                  5      (       a  [        R                  " U 5      n [        U [        R                  5      (       Gd  [        R
                  " U 5      (       a-  [        U [        5      (       d  [        R                  " U 5      n GO[        U [        [        45      (       Ga  SnU  H&  n[        U[        R                  5      (       d  M$  Sn  O   U(       a  [        U 5      S:X  al  [        U S   [        R                  5      (       aJ  U S   R                  [        R                  :X  a)  [        R                  " U S   R                  5       /5      n O[        R                  " U 5      n U(       d  U R                  nO[        R                  " U 5      n U R                  [        R                  :X  a  [!        S5      eO[        U [        R                  5      (       a"  U R#                  US5      n U" X5      n X0l        U $ [        U [&        R(                  5      (       a$  [        R                  " XS9n U" X5      n X0l        U $ [+        S[-        U 5       S	35      eU(       d  U R                  S
;   a^  [        R.                  " 5       n[        R0                  " U 5      (       a
  US;   a  SOSn[3        U5      [3        U R                  5      :w  a  UnU R                  S;   a  U R5                  S5      n U(       a  [3        U5      [3        U R                  5      :w  ad  [3        U5      S:X  a;  [&        R6                  R                  U USSS SS9nUR5                  U5      nX8l        U$ U R5                  [3        U5      5      n [        U [        R                  5      (       Ga6  U R                  [        R8                  [        R:                  [        R<                  [        R>                  [        R@                  [        RB                  4;   a  U RD                  S:X  a  [        U[&        RF                  5      (       d4  [        U[&        RH                  5      (       a\  URK                  5       (       aG  [        RL                  " U RN                  U RQ                  S/5      S   U R                  5      n	X9l        U	$ [&        R6                  R                  U USSS US9$ [        R                  " U USSUS9$ )Nc                    U(       a<  [        U5      [        U R                  5      :w  a  U R                  [        U5      5      $ U $ r,   )r   r9   astype)tensorr9   s     r:   _handle_tensor_dtype3_to_tensor_non_static.<locals>._handle_tensor_dtype  s6     U#}V\\'BB}}]5%9::r<   FTrw   r   z
	Failed to convert input data to a regular ndarray :
	 - Usually this means the input data contains nested lists with different lengths. )placez2Can't constructs a 'paddle.Tensor' with data type z>, data type must be scalar|list|tuple|np.ndarray|paddle.Tensor)rD   rE   rF   	complex64
complex128)rD   rE   r   r   rI   rJ   rL   )rP   r   rM   	zero_copyrN   rO   )rP   r   rM   r   rO   )r   paddle.Tensorr9   r$   returnr   ))r   rV   numberarrayrW   isscalarstrrT   rU   r3   Tensorlenr9   bfloat16numpyobject_r   _copy_torO   r   DenseTensor	TypeErrorrf   r   iscomplexobjr   r   eagerrE   rF   rI   rJ   r   r   size	CUDAPlacePlaceis_gpu_placefullr?   reshape)
datar9   r   rO   r   
has_tensorddefault_typer   rets
             r:   _to_tensor_non_staticr     s   &/	 $		""xx~dBJJ'';;tZc%:%:88D>DtUm,,Ja//!%J  IN"47FMM::Q888T!W]]_$56D88D>D JJExx~zzRZZ' _  (
 fmm,,==.D'4D!.Kd..// ==3D'4D!.KDT$ZL  QO  P  zz    &779??4(( (+AA $) !
 !.-

2KK(EzzY&{{7+u%tzz)BB8+ZZ&&!" ' F ]]5)F#0 M;;}U34D$

##JJ



 		Q5$..11udjj11e6H6H6J6J ++djj$,,s*;A*>

KC -J::$$!+ %   }}'
 	
r<   c                   [        U [        [        R                  R                  45      (       a,  U nUb%  XR
                  :w  a  [        R                  " X15      nGO[        U [        R                  5      (       a  [        R                  " U 5      n [        U [        R                  5      (       Gd  [        R                  " U 5      (       a,  [        U [        5      (       d  [        R                  " U 5      n Oi[        U [        [        45      (       a6    [        R                  " U 5      nUR
                  S:X  a  [        S5      eUn O[        S[)        U 5       S35      eU R
                  S;   a%  U R+                  [        R,                  " 5       5      n O!U R
                  S;   a  U R+                  S5      n U(       a  UnOC[/        U S5      (       a  U R
                  S:w  a  U R
                  nO[        R,                  " 5       n[1        U5      nU R
                  S	:X  a  U R+                  S
5      n [3        U 5      n[1        UR
                  5      U:w  a  [        R                  " X85      nX#l        U$ !   S /[!        U 5      -  n[#        U 5       H  u  pg[%        XqU5      XV'   M     [        R&                  " U5      n  GN]= f)NobjectzNumpy get dtype `object`.zDo not support transform type `z` to tensor)rD   rE   rF   r   rJ   r9   rH   rI   )r   r   r3   r4   r   r9   castrV   r   r   rW   r   r   rT   rU   RuntimeErrorr   	enumerate_to_tensor_staticstackrf   r   r   hasattrr   assignrO   )	r   r9   rO   output
array_datato_stack_listidxr   target_dtypes	            r:   r   r   n  s   
 $6::#3#3455**!4[[/F dBII&&88D>D$

++{{4  D#)>)>xx~D4-007 "$$J "''83*+FGG%D #5d4j\M 
 zz>>{{6#;#;#=>y({{7+ LT7##

h(>::L!335L$\2:: ;;w'D&,6[[6F(MI7%)FSY$6M"+D/->m.* #2 "<<6Ds   4I2 2A	J>c                N   U(       + n[        U5      nUc
  [        5       nU(       a  [        U[        R                  [        R
                  45      (       dy  [        U[        R                  5      (       a  [        R                  " 5       nOD[        U[        R                  5      (       a  [        R
                  " 5       nO[        SU S35      e[        5       (       a  [        R                  " U 5      nU(       de  [        U S5      (       aT  [        R                  " 5       (       d  [        S5      e[        R                  " U 5      nU(       a  UR                  5       nU$ U(       a"  [         (       d  ["        R$                  " SSS9  S	q['        XXe5      nU$ [(        R*                  " S
[(        R,                  5      n	[(        R.                  " U	[1        U5      5      S   n
[        R2                  R5                  U
5         [7        XU5      nUsSSS5        $ ! , (       d  f       g= f)u  
Constructs a ``paddle.Tensor`` from ``data`` ,
which can be scalar, tuple, list, numpy\.ndarray, paddle\.Tensor.

If the ``data`` is already a Tensor, copy will be performed and return a new tensor.
If you only want to change stop_gradient property, please call ``Tensor.stop_gradient = stop_gradient`` directly.

.. code-block:: text

    We use the dtype conversion rules following this:
            Keep dtype
    np.number ───────────► paddle.Tensor
                            (0-D Tensor)
                default_dtype
    Python Number ───────────────► paddle.Tensor
                                    (0-D Tensor)
                Keep dtype
    np.ndarray ───────────► paddle.Tensor

Args:
    data(scalar|tuple|list|ndarray|Tensor): Initial data for the tensor.
        Can be a scalar, list, tuple, numpy\.ndarray, paddle\.Tensor.
    dtype(str|np.dtype, optional): The desired data type of returned tensor. Can be 'bool' , 'float16' ,
        'float32' , 'float64' , 'int8' , 'int16' , 'int32' , 'int64' , 'uint8',
        'complex64' , 'complex128'. Default: None, infers dtype from ``data``
        except for python float number which gets dtype from ``get_default_type`` .
    device(CPUPlace|CUDAPinnedPlace|CUDAPlace|str, optional): The place to allocate Tensor. Can be
        CPUPlace, CUDAPinnedPlace, CUDAPlace. Default: None, means global place. If ``device`` is
        string, It can be ``cpu``, ``gpu:x`` and ``gpu_pinned``, where ``x`` is the index of the GPUs.
    requires_grad(bool, optional): Whether to block the gradient propagation of Autograd. 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 constructed from ``data`` .

Examples:
    .. code-block:: python

        >>> # type: ignore
        >>> import paddle

        >>> type(paddle.tensor(1))
        <class 'paddle.Tensor'>

        >>> paddle.tensor(1)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> x = paddle.tensor(1, requires_grad=True)
        >>> print(x)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=False,
        1)

        >>> paddle.tensor(x)  # A new tensor will be created with default stop_gradient=True
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> paddle.tensor([[0.1, 0.2], [0.3, 0.4]], device=paddle.CPUPlace(), requires_grad=True)
        Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=False,
        [[0.10000000, 0.20000000],
         [0.30000001, 0.40000001]])

        >>> type(paddle.tensor([[1+1j, 2], [3+2j, 4]], dtype='complex64'))
        <class 'paddle.Tensor'>

        >>> paddle.tensor([[1+1j, 2], [3+2j, 4]], dtype='complex64')
        Tensor(shape=[2, 2], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[(1+1j), (2+0j)],
         [(3+2j), (4+0j)]])
N$Pinning memory is not supported for .__cuda_array_interface__zXPaddlePaddle is not compiled with CUDA, but trying to create a Tensor from a CUDA array.zTo copy construct from a tensor, it is recommended to use sourceTensor.clone().detach(), rather than paddle.to_tensor(sourceTensor).r   )
stacklevelTz[(](.+?)[)]r   )r   r   r   r   CUDAPinnedPlaceXPUPinnedPlacer   XPUPlacer   r   r3   	is_tensorr   is_compiled_with_cuda tensor_from_cuda_array_interface
pin_memory_warned_in_tensorwarningswarnr   recompileDOTALLfindallr   staticr   r   )r   r9   rr   rs   r   rO   r   r   r   re_exp	place_strs              r:   r   r     s   Z &%Mf%E}(**$$d&9&9:  eT^^,,((*Et}}--'')E!EeWANOO$$T*	WT+EFF--//"n  ::4@F**,  ((MMF#$
 )-%*4MF NBII6JJvs5z215	]]''	2&tMBF 322s   >H
H$c                     [        XX#(       + S9$ )ul  
Constructs a ``paddle.Tensor`` from ``data`` ,
which can be scalar, tuple, list, numpy\.ndarray, paddle\.Tensor.

If the ``data`` is already a Tensor, copy will be performed and return a new tensor.
If you only want to change stop_gradient property, please call ``Tensor.stop_gradient = stop_gradient`` directly.

.. note::
Alias Support: The parameter name ``device`` can be used as an alias for ``place``.
For example, ``device=paddle.CUDAPlace(0)`` is equivalent to ``place=paddle.CUDAPlace(0)``.

.. code-block:: text

    We use the dtype conversion rules following this:
            Keep dtype
    np.number ───────────► paddle.Tensor
                            (0-D Tensor)
                default_dtype
    Python Number ───────────────► paddle.Tensor
                                    (0-D Tensor)
                Keep dtype
    np.ndarray ───────────► paddle.Tensor

Args:
    data(scalar|tuple|list|ndarray|Tensor): Initial data for the tensor.
        Can be a scalar, list, tuple, numpy\.ndarray, paddle\.Tensor.
    dtype(str|paddle.dtype|np.dtype, optional): The desired data type of returned tensor. Can be 'bool' , 'float16' ,
        'float32' , 'float64' , 'int8' , 'int16' , 'int32' , 'int64' , 'uint8',
        'complex64' , 'complex128'. Default: None, infers dtype from ``data``
        except for python float number which gets dtype from ``get_default_type`` .
    place(CPUPlace|CUDAPinnedPlace|CUDAPlace|str, optional): The place to allocate Tensor. Can be
        CPUPlace, CUDAPinnedPlace, CUDAPlace. Default: None, means global place. If ``place`` is
        string, It can be ``cpu``, ``gpu:x`` and ``gpu_pinned``, where ``x`` is the index of the GPUs.
    device: An alias for ``place`` , with identical behavior.
    stop_gradient(bool, optional): Whether to block the gradient propagation of Autograd. Default: True.

Returns:
    Tensor: A Tensor constructed from ``data`` .

Examples:
    .. code-block:: python

        >>> import paddle

        >>> type(paddle.to_tensor(1))
        <class 'paddle.Tensor'>

        >>> paddle.to_tensor(1)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> x = paddle.to_tensor(1, stop_gradient=False)
        >>> print(x)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=False,
        1)

        >>> paddle.to_tensor(x)  # A new tensor will be created with default stop_gradient=True
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> paddle.to_tensor([[0.1, 0.2], [0.3, 0.4]], place=paddle.CPUPlace(), stop_gradient=False)
        Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=False,
        [[0.10000000, 0.20000000],
         [0.30000001, 0.40000001]])

        >>> type(paddle.to_tensor([[1+1j, 2], [3+2j, 4]], dtype='complex64'))
        <class 'paddle.Tensor'>

        >>> paddle.to_tensor([[1+1j, 2], [3+2j, 4]], dtype='complex64')
        Tensor(shape=[2, 2], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[(1+1j), (2+0j)],
         [(3+2j), (4+0j)]])
)r9   rr   rs   r   )r   r9   r   rO   s       r:   	to_tensorr   1  s    ^ %7H r<   c                    [        U [        R                  5      (       d  [        S[	        U 5       S35      e[        U 5      $ )a  
Creates a ``paddle.Tensor`` from a ``numpy.ndarray``.

The returned Tensor and the input ``ndarray`` share the same underlying memory.
Changes to the Tensor will be reflected in the ``ndarray`` and vice versa.

Args:
    ndarray(numpy.ndarray): The numpy ndarray to be converted to a Tensor.

Returns:
    Tensor: A Tensor that shares the same memory with the input ``ndarray``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import numpy as np

        >>> np_data = np.array([1, 2, 3]).astype('int64')
        >>> tensor = paddle.from_numpy(np_data)
        >>> print(tensor)
        Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
               [1, 2, 3])
zCThe input type of from_numpy() must be numpy.ndarray, but received zG. To convert other types to tensor, please use paddle.tensor() instead.)r   rV   rW   r   rf   r   )rW   s    r:   
from_numpyr     sJ    2 grzz**QRVW^R_Q` aT T
 	
 '?r<   )r9   rr   copyrs   c                   [        XX$S9$ )u  
Constructs a ``paddle.Tensor`` from ``obj`` ,
which can be scalar, tuple, list, numpy\.ndarray, paddle\.Tensor.

If the ``obj`` is already a tensor, copy will be performed and return a new tensor.

.. note::
The parameter ``copy`` will not affect this api's behavior. Copy will always be performed if ``obj`` is a tensor.

.. code-block:: text

    We use the dtype conversion rules following this:
            Keep dtype
    np.number ───────────► paddle.Tensor
                            (0-D Tensor)
                default_dtype
    Python Number ───────────────► paddle.Tensor
                                    (0-D Tensor)
                Keep dtype
    np.ndarray ───────────► paddle.Tensor

Args:
    obj(scalar|tuple|list|ndarray|Tensor): Initial data for the tensor.
        Can be a scalar, list, tuple, numpy\.ndarray, paddle\.Tensor.
    dtype(str|np.dtype, optional): The desired data type of returned tensor. Can be 'bool' , 'float16' ,
        'float32' , 'float64' , 'int8' , 'int16' , 'int32' , 'int64' , 'uint8',
        'complex64' , 'complex128'. Default: None, infers dtype from ``data``
        except for python float number which gets dtype from ``get_default_type`` .
    device(CPUPlace|CUDAPinnedPlace|CUDAPlace|str, optional): The place to allocate Tensor. Can be
        CPUPlace, CUDAPinnedPlace, CUDAPlace. Default: None, means global place. If ``place`` is
        string, It can be ``cpu``, ``gpu:x`` and ``gpu_pinned``, where ``x`` is the index of the GPUs.
    copy(bool, optional): This param is ignored and has no effect.
    requires_grad(bool, optional): Whether to block the gradient propagation of autograd. Default: False.

Returns:
    Tensor: A Tensor constructed from ``data`` .

Examples:
    .. code-block:: python

        >>> import paddle

        >>> type(paddle.asarray(1))
        <class 'paddle.Tensor'>

        >>> paddle.asarray(1)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> x = paddle.asarray(1, requires_grad=True)
        >>> print(x)
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=False,
        1)

        >>> paddle.asarray(x)  # A new tensor will be created with default stop_gradient=True
        Tensor(shape=[], dtype=int64, place=Place(cpu), stop_gradient=True,
        1)

        >>> paddle.asarray([[0.1, 0.2], [0.3, 0.4]], device=paddle.CPUPlace(), requires_grad=True)
        Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=False,
        [[0.10000000, 0.20000000],
         [0.30000001, 0.40000001]])

        >>> type(paddle.asarray([[1+1j, 2], [3+2j, 4]], dtype='complex64'))
        <class 'paddle.Tensor'>

        >>> paddle.asarray([[1+1j, 2], [3+2j, 4]], dtype='complex64')
        Tensor(shape=[2, 2], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[(1+1j), (2+0j)],
         [(3+2j), (4+0j)]])
)r   r9   rr   rs   r   )objr9   rr   r   rs   s        r:   asarrayr     s    ^ f r<   c                  ^   ^  \ rS rSrSrSU 4S jjr    S         SU 4S jjjrSrU =r$ )	MmapStoragei  a/  
This class will use mmap to load a file.

Args:
    filename(str): the name of .safetensors file.
    nbytes(int): number of bytes to map into memory.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> shape = [4,5]
        >>> dtype = paddle.float32
        >>> a = paddle.arange(4*5).reshape(shape).astype(dtype)
        >>> a.numpy().tofile("test.pp")
        >>> size = a.size * a.element_size()
        >>> t = paddle.MmapStorage("test.pp", size)
        >>> t.get_slice(dtype = dtype, start = 0, stop = a.size).reshape(shape)
        Tensor(shape=[4, 5], dtype=float32, place=Place(cpu), stop_gradient=True,
               [[0. , 1. , 2. , 3. , 4. ],
                [5. , 6. , 7. , 8. , 9. ],
                [10., 11., 12., 13., 14.],
                [15., 16., 17., 18., 19.]])

c                $   > [         TU ]  X5        g r,   )super__init__)selffilenamenbytes	__class__s      r:   r   MmapStorage.__init__  s    *r<   c                z   > [         R                  R                  R                  U5      n[        TU ]  XRX45      nU$ )aW  
Slice the tensor from the mmapped file.
Args:
    dtype (DTypeLike | None): The data type of the output tensor. Default: "uint8".
    start (int): The start index of the slice. Default: 0.
    stop (int): The end index of the slice. Default: -1.
    step (int): The step size of the slice. Default: 1.
Returns:
    Tensor: The sliced tensor.
)r3   r   	frameworkconvert_to_proto_typer   	get_slice)r   r9   rz   rm   stepproto_dtyperq   r   s          r:   r   MmapStorage.get_slice  s:    " kk++AA%H161B2
 
r<    )r   r   r   rX   )rK   r   rw   )
r9   DTypeLike | Nonerz   rX   rm   rX   r   rX   r   r   )	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__)r   s   @r:   r   r     sU    4+
 #*  	
  
 r<   r   xinput)rr   rs   r   c                  [        U[        R                  [        [        R
                  R                  [        [        R                  R                  45      (       d  [        S[        U5       S35      eUc  U R                  nOD[        U[        R                  R                  [        R                   45      (       d  [#        U5      nUc  U R$                  n['        5       (       Ga  Ub  [)        U5      O	[+        5       nU(       Ga#  [-        5       (       Ga  UGb  [        U[        R.                  [        R0                  45      (       d  [        U[        R2                  5      (       d4  [        U[        R4                  5      (       a+  UR7                  5       (       a  [        R.                  " 5       nOw[        U[        R8                  5      (       d4  [        U[        R4                  5      (       a+  UR;                  5       (       a  [        R0                  " 5       nO[=        SU 35      e[>        R@                  " XX$5      nUSL a  SUl!        U(       a  [-        5       (       a  URE                  5       nU$ [G        S0 [I        5       D6n[K        U S/ SQS5        [M        US	/ SQS
5        URO                  US9n	URQ                  SSU /0XS.SU	/0S9  SU	l!        U	$ )a  

This function creates a tensor filled with ``fill_value`` which has identical shape of ``x`` and ``dtype``.
If the ``dtype`` is None, the data type of Tensor is same with ``x``.

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

Args:
    x(Tensor): The input tensor which specifies shape and data type. The data type can be bool, float16, float32, float64, int32, int64.
    fill_value(bool|float|int): The value to fill the tensor with. Note: this value shouldn't exceed the range of the output data type.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of output. The data type can be one
        of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
        data type is the same as input.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor: Tensor which is created according to ``x``, ``fill_value`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> input = paddle.full(shape=[2, 3], fill_value=0.0, dtype='float32', name='input')
        >>> output = paddle.full_like(input, 2.0)
        >>> print(output.numpy())
        [[2. 2. 2.]
         [2. 2. 2.]]
zlThe fill_value should be int, float, bool, complex, np.number, string numeric value or Tensor, but received r   r   TF	full_liker  )r@   rD   rE   rF   rH   rI   rJ   rL   r9   zfull_like/zeros_like/ones_liker8   fill_any_likeX)rP   r9   r   r   r  ))r   numbersNumberr   r   r   r   r   r3   r4   r   r   rf   r9   r-   r.   r5   r   r   r   r   r   r   r   r   r   r   r   r   is_xpu_placer   r   r  rO   r   r   rY   r   r   r   r   )
r  
fill_valuer9   rN   rr   rs   r   r   r`   rq   s
             r:   r  r  0  s   b 	djj//6::;K;KL  z{  AK  |L  {M  MN  O
 	
 }%$,,"6"6!FGG.u5E~ ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  !!!?D #(F /++&&(F5FH5 	 	
 		 -	
 77e7D !:&7SEN	 	 	
 !
r<   c                   [        U [        5      (       a  U /OU n [        5       (       Ga4  Uc  [        5       nO[	        U5      nU(       a  [
        R                  " 5       n[        U[
        R                  R                  [
        R                  45      (       d  [        U5      n[        5       (       aP  [        U[
        R                  R                  5      (       a'  [        R                  R
                  R                  U   n[        5       (       a;  [        U [         ["        45      (       a  [        R$                  R'                  U 5      n O[        R$                  R)                  U 5        [        U [         ["        45      (       aD  [        R$                  R+                  U 5      (       a  [        R$                  R-                  U 5      n O5[        U [        R                  R.                  5      (       a  O[1        S5      eUc   [2        R4                  " XX5      nSUl        U$ UR8                  U:w  a  [1        S5      e[2        R:                  " X@X!U5      nSUl        U$ SU0n[=        U5      n[        U[>        5      (       dQ  US;   a&  [A        [        U5      5      US'   [        U5      US'   O%[A        [C        U5      5      US'   [C        U5      US'   [E        S0 [G        5       D6n0 n	[        U[>        5      (       a3  [=        UR8                  5      U:w  a  [        RH                  " X!5      nX)S	'   [        R$                  R)                  U 5        [K        US
/ SQS5        [M        U S[>        [         ["        4S5        Ub  [O        US[=        U5      /S5        [E        S0 [G        5       D6n[        R$                  RQ                  XU SS9  Uc  URS                  US9nUR8                  US
'   URU                  SU	SU/0USS9  SUl        U$ )N-Shape only supports Value, or list, or tuple.TzTRequired out.dtype == dtype if specifying out, but received f{out.dtype} != f{dtype}rQ   )rG   rK   rH   rI   rJ   	str_valuerP   r   ValueTensorr9   )r@   rD   rE   rF   rG   rK   rH   rI   rJ   r   r   rL   float8_e4m3fnfloat8_e5m2r?   rq   r   r   r?   op_typer8   r   rf   r   r   r   rO   )r   )+r   rX   r   r   r   r   CPUPlacer-   r.   r5   r   r    r3   r4   r   r   rT   rU   utilsconvert_shape_to_listcheck_shape_contain_varget_int_tensor_listr   r   r   r   rO   r9   full_r   r   r   r^   r   rY   r   r   r   r   get_shape_tensor_inputsr   r   )
r?   r9   rP   rQ   rq   r   rN   r   r`   r   s
             r:   r   r     sF    "%--UG5E=+-E%e,EMMOE%$,,"6"6!FGG.u5E==Zt||/C/CDDJJOO77>E%$//::5ALL$$U+%$//<<,,U33"LL<<UCEE6::#3#344 OPP;++eE9C $CJ99f  ll3uU; 
 i(e$%**DD%(U_k"!$Ug%(u%6k"!&ug99eX&&U[[)U2E1$)=!  '  '	
* 	5'HdE#:OL?$U]512O 99,,e_ 	- 	
 ;;;%;HCg SEN 	 	
 !
r<   )rq   rr   rs   r   c               "    [        U SUUUUUUS9$ )a-  
Create a Tensor of specified :attr:`shape` and :attr:`dtype` and fill it with 1.

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, the elements of it should be integers or 0-D Tensor with shape [].
        If ``shape`` is an Tensor, it should be an 1-D Tensor which represents a list.
    dtype (np.dtype|str, optional): Data type of output Tensor, it should be one of
        bool, float16, float32, float64, int32 and int64. If it is set to None, the data type will be float32.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    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 of data type :attr:`dtype` with shape :attr:`shape` and all elements are 1.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # shape is a list/tuple
        >>> data1 = paddle.ones(shape=[3, 2])
        >>> print(data1.numpy())
        [[1. 1.]
         [1. 1.]
         [1. 1.]]

        >>> # shape is a Tensor
        >>> shape = paddle.to_tensor([3, 2])
        >>> data2 = paddle.ones(shape=shape)
        >>> print(data2.numpy())
        [[1. 1.]
         [1. 1.]
         [1. 1.]]

        >>> # shape is a Tensor List
        >>> shape = [paddle.to_tensor(3), paddle.to_tensor(2)]
        >>> data3 = paddle.ones(shape=shape)
        >>> print(data3.numpy())
        [[1. 1.]
         [1. 1.]
         [1. 1.]]
rw   rq   rr   rs   r   rN   r   r?   r9   rN   rq   rr   rs   r   s          r:   onesr+  3  s*    v 	#	 	r<   c          
          [        U SUUUUUS9$ )a<  
Returns a Tensor filled with the value 1, with the same shape and
data type (use ``dtype`` if ``dtype`` is not None) as ``x``.

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

Args:
    x(Tensor): The input tensor which specifies shape and dtype. The
        dtype of ``x`` can be bool, float16, float32, float64, int32, int64.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of the
        output tensor. Supported data types: bool, float16, float32, float64,
        int32, int64. If ``dtype`` is None, the data type is the same as ``x``.
        Default is None.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    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 the value 1, with the same shape and
    data type (use ``dtype`` if ``dtype`` is not None) as ``x``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> x = paddle.to_tensor([1,2,3])
        >>> out1 = paddle.ones_like(x)
        >>> print(out1.numpy())
        [1 1 1]
        >>> out2 = paddle.ones_like(x, dtype='int32')
        >>> print(out2.numpy())
        [1 1 1]

rw   )r  r  r9   rN   rr   r   rs   r  r  r9   rN   rr   rs   r   s         r:   	ones_liker.  z  s'    d 
# r<   c               "    [        U SUUUUUUS9$ )a	  
Creates a tensor of specified :attr:`shape` and :attr:`dtype`, and fills it with 0.

.. note::
    Alias Support: The parameter name ``size`` can be used as an alias for ``shape``.
    ``shape`` can be a variable number of arguments.
    For example:
        ``paddle.ones(1, 2, 3, dtype=paddle.float32)``
        ``paddle.ones(size=[1, 2, 3], dtype=paddle.float32)``

Args:
    shape (tuple|list|Tensor|variable number of arguments): Shape of the Tensor to be created. The data type is ``int32`` or ``int64`` .
        alias: ``size``.
        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): Data type of output Tensor, it supports
        bool, float16, float32, float64, int32 and int64. Default: if None, the data type is float32.
        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.
        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.
    name(str|None, optional): The default value is None.  Normally there is no need for user to set this
    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 of data type :attr:`dtype` with shape :attr:`shape` and all elements set to 0.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # shape is a list/tuple
        >>> data1 = paddle.zeros(shape=[3, 2])
        >>> print(data1.numpy())
        [[0. 0.]
         [0. 0.]
         [0. 0.]]

        >>> # shape is a Tensor
        >>> shape = paddle.to_tensor([3, 2])
        >>> data2 = paddle.zeros(shape=shape)
        >>> print(data2.numpy())
        [[0. 0.]
         [0. 0.]
         [0. 0.]]

        >>> # shape is a Tensor List
        >>> shape = [paddle.to_tensor(3), paddle.to_tensor(2)]
        >>> data3 = paddle.zeros(shape=shape)
        >>> print(data3.numpy())
        [[0. 0.]
         [0. 0.]
         [0. 0.]]
r   r(  r)  r*  s          r:   zerosr0    s*    H 	#	 	r<   c          
          [        U SUUUUUS9$ )a5  
Returns a Tensor filled with the value 0, with the same shape and
data type (use ``dtype`` if ``dtype`` is not None) as ``x``.

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

Args:
    x(Tensor): The input tensor which specifies shape and dtype. The
        dtype of ``x`` can be bool, float16, float32, float64, int32, int64.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of the
        output tensor. Supported data types: bool, float16, float32, float64,
        int32, int64. If ``dtype`` is None, the data type is the same as ``x``.
        Default is None.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    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 the value 0, with the same shape and
    data type (use ``dtype`` if ``dtype`` is not None) as ``x``.


Examples:
    .. code-block:: python

        >>> import paddle

        >>> x = paddle.to_tensor([1, 2, 3])
        >>> out1 = paddle.zeros_like(x)
        >>> print(out1.numpy())
        [0 0 0]
        >>> out2 = paddle.zeros_like(x, dtype='int32')
        >>> print(out2.numpy())
        [0 0 0]

r   )r  r  r9   rN   rr   rs   r   r  r-  s         r:   
zeros_liker2    s'    f 
# r<   num_rowsnnum_columnsmc          	        S nU" U S5        Uc  [         R                  " 5       n[        U[        R                  R
                  [         R                  R                  R                  45      (       d  [        U5      nUb
  U" US5        OU n[        5       (       Ga  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[*        R,                  " U UUUUS9n	USL a  SU	l        Ub  SUl        U(       a  [        5       (       a  U	R1                  5       n	U	$ [3        S0 [5        5       D6n
[7        US	/ S
QS5        U
R9                  US9nU
R;                  S0 SU/0U UUS.SS9  SUl        U$ )a  

This function constructs 2-D Tensor with ones on the diagonal and zeros elsewhere.

.. note::
    Alias Support: The parameter name ``n`` can be used as an alias for ``num_rows``, and ``m`` can be used as an alias for ``num_columns``.
    For example, ``eye(n=tensor_x, m=tensor_y, ...)`` is equivalent to ``eye(num_rows=tensor_x, num_columns=tensor_y, ...)``.

Args:
    num_rows(int | paddle.Tensor): the number of rows in each batch Tensor.
        Alias: ``n``.
    num_columns(int | paddle.Tensor | None, optional): the number of columns in each batch Tensor.
        If None, default: num_rows.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of the returned Tensor.
        It should be int32, int64, float16, float32, float64, complex64, complex128. Default: if None, the data type
        is float32.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor: An identity Tensor or DenseTensor of shape [num_rows, num_columns].

Examples:
    .. code-block:: python

        >>> import paddle

        >>> data = paddle.eye(3, dtype='int32')
        >>> print(data.numpy())
        [[1 0 0]
         [0 1 0]
         [0 0 1]]
        >>> data = paddle.eye(2, 3, dtype='int32')
        >>> print(data.numpy())
        [[1 0 0]
         [0 1 0]]
c                   [        U [        [        R                  R                  [
        R                  R                  45      (       aI  [        U R                  5      S:X  d/  [        U R                  5      S:X  a  U R                  S   S;   d   eg g [        U [        [        R                  45      (       a  U S:  a  [        U S35      eg )Nr   rw   )rw   r  z should be a non-negative int.)r   r   r   r   r   r3   r4   r   r   r?   rX   rV   integerr   )rd   messages     r:   _check_attreye.<locals>._check_attr|  s    dh

(9(96::;K;KLNNtzz?a'DJJ1$A')A )A ( D3

"344qwi'EFGG 9Ar<   r3  r5  r   ry   TFeyer9   )rD   rE   rF   rL   rI   rJ   r   r   r8   r   )r3  r5  r9   r  )r=  )r3   r   r   r   r-   r.   r4   r5   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r=  rO   r   r   rY   r   r   r   )r3  r5  r9   rN   rq   rr   rs   r   r;  r   r`   s              r:   r=  r=  E  s?   nH *%}((*edll22FJJOO4L4LMNN*51K/ ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  
 D #(F $)!/++&&(F/fh/	 	
 77e7DSEN$*
  	 
	
 CJr<   r   c          	        [        U[        R                  [        [        R
                  R                  [        [        R                  R                  45      (       d  [        S[        U5       S35      eUcO  [        U[        5      (       a  SnO7[        U[        R                  5      (       a  SnO[        R                   " 5       n[#        5       (       GaC  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[        R0                  5      (       a+  UR3                  5       (       a  [        R*                  " 5       nOw[        U[        R4                  5      (       d4  [        U[        R0                  5      (       a+  UR7                  5       (       a  [        R,                  " 5       nO[9        SU 35      e[;        U UUUUUS9nUSL a  SUl        Ub  SUl        U(       a  [)        5       (       a  UR?                  5       nU$ )	u
  

Return a Tensor with the ``fill_value`` which size is same as ``shape``.

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

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.
        Alias: ``size``.
    fill_value(Scalar|Tensor): The constant value used to initialize the Tensor to be created.
        If ``fill_value`` is an Tensor, it should be an 0-D Tensor which represents a scalar.
    dtype(str|paddle.dtype|np.dtype, optional): Data type of the output Tensor
        which can be float16, float32, float64, int32, int64, if dtype is `None`, the data
        type of created Tensor is `float32`.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor: Tensor which is created according to ``shape``, ``fill_value`` and ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # shape is a list/tuple
        >>> data1 = paddle.full(shape=[3, 2], fill_value=1.)
        >>> print(data1.numpy())
        [[1. 1.]
         [1. 1.]
         [1. 1.]]

        >>> # shape is a Tensor
        >>> shape = paddle.to_tensor([3, 2])
        >>> data2 = paddle.full(shape=shape, fill_value=2.)
        >>> print(data2.numpy())
        [[2. 2.]
         [2. 2.]
         [2. 2.]]

        >>> # shape is a Tensor List
        >>> shape = [paddle.to_tensor(3), paddle.to_tensor(2)]
        >>> data3 = paddle.full(shape=shape, fill_value=3.)
        >>> print(data3.numpy())
        [[3. 3.]
         [3. 3.]
         [3. 3.]]

        >>> # fill_value is a Tensor.
        >>> val = paddle.full([], 2.0, "float32")
        >>> data5 = paddle.full(shape=[3, 2], fill_value=val)
        >>> print(data5.numpy())
        [[2. 2.]
         [2. 2.]
         [2. 2.]]
zmThe fill_value should be int, float, bool, complex, np.number, string numeric values or Tensor, but received r   r@   r   r   )r?   r9   rP   rq   r   rN   TF) r   r  r  r   r   r   r   r   r3   r4   r   r   rf   r@   builtinscomplexr   r   r   r   r   r   r   r   r   r   r   r  r   r   rO   r   )	r?   r  r9   rN   rq   rr   rs   r   r   s	            r:   r   r     s   ^ 	djj//6::;K;KL  {  }A  BL  }M  |N  NO  P
 	
 }j4))E
X%5%577 E,,.E ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  F $? %Co''""$Mr<   rw   r(  c          	        Uc  U nSn Uc  XU4 H  n	[        U	[        [        R                  R                  45      (       a6  [        R
                  " U	5      (       d  [        R                  " 5       n  OUSnMh  [        U	[        R                  5      (       d,  [        U	[        5      (       d  [        R                  " 5       n  OSnM     Sn
[        U [        [        R                  R                  45      (       + =(       ae    [        U[        [        R                  R                  45      (       + =(       a/    [        U[        [        R                  R                  45      (       + n[        5       (       d,  U(       a%  [        [        R                  " X-
  U-  5      5      /n
[        U[        R                  R                  [        R                   45      (       d  [#        U5      n[%        5       (       GaC  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[        R0                  5      (       a+  UR3                  5       (       a  [        R*                  " 5       nOw[        U[        R4                  5      (       d4  [        U[        R0                  5      (       a+  UR7                  5       (       a  [        R,                  " 5       nO[9        SU 35      eU(       ak  [;        5       (       a\  [<        R>                  " U UUUUUS9nU(       + Ul         Ub  U(       + Ul         U(       a  [        5       (       a  URC                  5       nU$ [        U [        [        R                  R                  45      (       dK  [E        S5         [        RF                  " U 5      (       d  [I        SU  S35      e[K        S	/X0S
S9n SSS5        O_U RL                  U:w  aO  [        5       (       a*  [        RF                  " U 5      (       d  [I        SU  S35      e[        RN                  " X5      n [        U[        [        R                  R                  45      (       dK  [E        S5         [        RF                  " U5      (       d  [I        SU S35      e[K        S	/X1S
S9nSSS5        O_URL                  U:w  aO  [        5       (       a*  [        RF                  " U5      (       d  [I        SU S35      e[        RN                  " X5      n[        U[        [        R                  R                  45      (       d!  [E        S5         [K        S	/X2S
S9nSSS5        O&URL                  U:w  a  [        RN                  " X#5      n[%        5       (       ar  [<        R>                  " U UUUUb  ['        U5      O	[)        5       US9nU(       + Ul         Ub  U(       + Ul         U(       a  [        5       (       a  URC                  5       nU$ [Q        US/ SQS5        [S        S0 [U        5       D6nURW                  X:S9nURY                  SXUS.SU0S9  S
Ul         U
b  URZ                  R]                  U
5        U$ ! , (       d  f       GNN= f! , (       d  f       GN= f! , (       d  f       GN#= f)a  
Returns a 1-D Tensor with spaced values within a given interval.

Values are generated into the half-open interval [``start``, ``end``) with
the ``step``. (the interval including ``start`` but excluding ``end``).

If ``dtype`` is float32 or float64, we advise adding a small epsilon to
``end`` to avoid floating point rounding errors when comparing against ``end``.

Parameters:
    start(float|int|Tensor): Start of interval. The interval includes this
        value. If ``end`` is None, the half-open interval is [0, ``start``).
        If ``start`` is a Tensor, it is a 0-D Tensor which represents a scalar
        and data type is int32, int64, float32, float64. Default is 0.
    end(float|int|Tensor, optional): End of interval. The interval does not
        include this value. If ``end`` is a Tensor, it is a 0-D Tensor which
        represents a scalar and data type is int32, int64, float32, float64.
        If ``end`` is None, the half-open interval is [0, ``start``).
        Default is None.
    step(float|int|Tensor, optional): Spacing between values. For any out,
        it is the instance between two adjacent values, out[i+1] - out[i].
        If ``step`` is a Tensor, it is a 0-D Tensor which represents a scalar
        and data type is int32, int64, float32, float64. . Default is 1.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of the
        output tensor. Supported data types: int32, int64, float32, float64.
        If ``dtype`` is None, the data type is float32. Default is None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor: A 1-D Tensor with values from the interval [``start``, ``end``)
    taken with common difference ``step`` beginning from ``start``. Its
    data type is set by ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> out1 = paddle.arange(5)
        >>> print(out1.numpy())
        [0 1 2 3 4]

        >>> out2 = paddle.arange(3, 9, 2.0)
        >>> print(out2.numpy())
        [3. 5. 7.]

        >>> # use 4.999 instead of 5.0 to avoid floating point rounding errors
        >>> out3 = paddle.arange(4.999, dtype='float32')
        >>> print(out3.numpy())
        [0. 1. 2. 3. 4.]

        >>> start_var = paddle.to_tensor(3)
        >>> out4 = paddle.arange(start_var, 7)
        >>> print(out4.numpy())
        [3 4 5 6]

Nr   rJ   r   ry   rv   z1The value of start must be finite, but received: r   rw   Trx   z/The value of end must be finite, but received: r9   )rE   rF   rI   rJ   rD   rL   zrange/arangerange)r?   )r}   EndStepr   rf   r   r   )rB  )/r   r   r3   r4   r   
is_integerr   rV   r9  rX   r   mathceilr   r-   r.   r5   r   r   r   r   r   r   r   r   r   r   r  r   r    r   arangerO   r   r   isfiniter   r   r9   r   r   r   rY   r   r   r   r   )rz   rn   r   r9   rq   rr   rs   r   rN   val	out_shapeis_value_inputr   r`   s                 r:   rI  rI  c  s   V {}%C#&***:*:;<<((--"446E#E!#rzz22:c3;O;O"446E#E & Iux)9)9:;; 	?36::+;+; <==	?4(FJJ,<,<!=>>  CK4#789:	edll22DMMBCC*51 ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  +--
 $10?$1 1C/++&&(Feh

(8(89::% ;;u%% GwaP  "1#utDE !  
	V__U%;%;CE7!L  E)cHfjj&6&6788% ;;s## EcU!L   U4@C !  
e	V__S%9%9A#aH  kk#%dXvzz'7'7899%  !eTBD ! 	u	{{4' % "&),.
 $10?$1 1C/++&&(FI		
 11777O"=CL 	 	

 ! HHy)
K !  !  ! s$   #7[<7[[%
[
["%
[4zpaddle.range is deprecated and will be removed in a future release because its behavior is inconsistent with Python's range builtin.Instead, use paddle.arange, which produces values in [start, end))reasonlevel)rq   rr   rs   rN   c          	        Uc  U nSn Uc  [         R                  " 5       n[        U [        [         R                  R
                  45      (       + =(       ae    [        U[        [         R                  R
                  45      (       + =(       a/    [        U[        [         R                  R
                  45      (       + n[        U[        R                  R                  [        R                  45      (       d  [        U5      nU(       a[  [        5       (       aL  [        R                  " U UUUUb  [        U5      O	[        5       US9n	U(       + U	l        Ub  U(       + Ul        U	$ [        U [        [         R                  R
                  45      (       d!  [#        S5         [%        S/X0SS9n SSS5        O&U R&                  U:w  a  [         R(                  " X5      n [        U[        [         R                  R
                  45      (       d!  [#        S5         [%        S/X1SS9nSSS5        O&UR&                  U:w  a  [         R(                  " X5      n[        U[        [         R                  R
                  45      (       d!  [#        S5         [%        S/X2SS9nSSS5        O&UR&                  U:w  a  [         R(                  " X#5      n[        R                  " U UUUUb  [        U5      O	[        5       US9n	U(       + U	l        Ub  U(       + Ul        U	$ ! , (       d  f       GNG= f! , (       d  f       N= f! , (       d  f       N}= f)a  
Returns a 1-D Tensor of size $$ \lfloor \dfrac{end - start}{step} \rfloor + 1 $$ with values
from ``start`` to ``end`` with ``step``. ``step`` is the gap between two values in the tensor.

$$
out_{i+1} = out_{i} + step
$$

Values are generated into the half-open interval [``start``, ``end``) with
the ``step``. (the interval including ``start`` but excluding ``end``).

If ``dtype`` is float32 or float64, we advise adding a small epsilon to
``end`` to avoid floating point rounding errors when comparing against ``end``.

Parameters:
    start(float|int|Tensor): Start of interval. The interval includes this
        value. If ``end`` is None, the half-open interval is [0, ``start``).
        If ``start`` is a Tensor, it is a 0-D Tensor which represents a scalar
        and data type is int32, int64, float32, float64. Default is 0.
    end(float|int|Tensor, optional): End of interval. The interval does not
        include this value. If ``end`` is a Tensor, it is a 0-D Tensor which
        represents a scalar and data type is int32, int64, float32, float64.
        If ``end`` is None, the half-open interval is [0, ``start``).
        Default is None.
    step(float|int|Tensor, optional): Spacing between values. For any out,
        it is the instance between two adjacent values, out[i+1] - out[i].
        If ``step`` is a Tensor, it is a 0-D Tensor which represents a scalar
        and data type is int32, int64, float32, float64. . Default is 1.
    dtype(str|np.dtype, optional): The data type of the
        output tensor. Supported data types: int32, int64, float32, float64.
        If ``dtype`` is None, the data type is float32. Default is None.
    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.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor: A 1-D Tensor with values from the interval [``start``, ``end``)
    taken with common difference ``step`` beginning from ``start``. Its
    data type is set by ``dtype``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> out1 = paddle.range(5)
        >>> print(out1.numpy())
        [0 1 2 3 4 5]

        >>> out2 = paddle.range(3, 9, 2.0)
        >>> print(out2.numpy())
        [3. 5. 7. 9.]

        >>> # use 4.999 instead of 5.0 to avoid floating point rounding errors
        >>> out3 = paddle.range(4.999, dtype='float32')
        >>> print(out3.numpy())
        [0. 1. 2. 3. 4.]

        >>> start_var = paddle.to_tensor(3)
        >>> out4 = paddle.range(start_var, 7)
        >>> print(out4.numpy())
        [3 4 5 6 7]

Nr   ry   rv   rw   Trx   )r3   r   r   r   r4   r   r   r-   r.   r5   r   r    r   range_v2r   r   rO   r   r   r9   r   )
rz   rn   r   r9   rq   rr   rs   rN   rM  r   s
             r:   rB  rB  B	  s   j {}((* ux)9)9:;; 	?36::+;+; <==	?4(FJJ,<,<!=>>  edll22DMMBCC*51+-- % "&),.
 $10?$1 1Ceh

(8(89::% !1#utDE ! 		E)cHfjj&6&6788% U4@C ! 	e	kk#%dXvzz'7'7899%  !eTBD ! 	u	{{4'__ ! f%(*F  -,F
 --MA !  !  ! s$   LL!L2
L!
L/2
M c                J   U R                   nU R                  R                  SS5      nUc
   SU 35       e[        US/ SQU5        [	        UR
                  5      S:  a  [        SU S35      eU R                  R                  SS	5      n[        U[        45      (       d  [        S
U S35      eU R                  R                  SS5      nUc  U R                  UR                  S9nOU R                  XBR                  SS9nU R                  SSU0UUS:X  a  SOSS.SU0S9  U$ )zBase op of tril_op and triu_opr  Nzx cannot be None in )	rD   rL   rE   rF   rI   rJ   r@   r   r   r   zx shape in z must be at least 2-Ddiagonalr   zdiagonal in z must be a python IntrN   r8   Frk   	tril_triur  r   T)rS  lowerr   r   )
layer_typekwargsgetr   r   r?   r   r   rX   r   r   r9   rl   r   )r`   r  r  rS  rN   rq   s         r:   _tril_triu_oprY  	  sF   G#t$A=:0	::=	
	
 	  177|a;wi/DEFF}}  Q/Hh'',wi/DEFF==VT*D|77agg7F$$WW% % 
 Qx $.TE
    Jr<   c                N    [        5       (       a  [        R                  " X5      $ g)z
Inplace version of ``tril`` API, the output Tensor will be inplaced with input ``x``.
Please refer to :ref:`api_paddle_tril`.
N)r   r   tril_r  rS  rN   s      r:   r[  r[  
  !     ||A(( r<   c                N    [        5       (       a  [        R                  " X5      $ g)z
Inplace version of ``triu`` API, the output Tensor will be inplaced with input ``x``.
Please refer to :ref:`api_paddle_triu`.
N)r   r   triu_r\  s      r:   r_  r_  
  r]  r<   c                    g r,   r  )argsrN   indexings      r:   meshgridrc  (
  s    
 r<   )rN   rb  c                    g r,   r  )rN   rb  ra  s      r:   rc  rc  0
  s     r<   c                 |   UR                  SS5      nUR                  SS5      nUc  Sn[        U 5      S:X  a#  [        U S   [        [
        45      (       a  U S   n US;  a  [        SU 35      eUS	:H  =(       a    [        U 5      S
:  nU(       a  U S   U S   /U S
S Q7n [        5       (       a   [        R                  " [	        U 5      5      nO[        S0 [        5       D6n[        U [        [
        45      (       d  [        S5      e[        U 5       H  u  px[        UR                  S/ SQS5        M!     [        U 5      n	[         R"                  " U	5       V
s/ s H  n
UR%                  X
   R                  S9PM      nn
UR'                  SS[	        U 5      0SU0S9  U(       a  US   US   sUS'   US'   U$ s  sn
f )u  

Takes a list of N tensors as input :attr:`*args`, each of which is 1-dimensional vector, and creates N-dimensional grids.

Args:
    *args(Tensor|list of Tensor) : tensors (tuple(list) of tensor): the shapes of input k tensors are (N1,),
        (N2,),..., (Nk,). Support data types: ``float64``, ``bfloat16``, ``float16``, ``float32``, ``int32``, ``int64``, ``complex64``, ``complex128``.
    **kwargs (optional): Currently, only accept name in **kwargs
        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`.
    indexing (Optional[str]) : the indexing mode, either “xy” or “ij”, defaults to “ij”.If “xy” is selected, the first dimension corresponds to the cardinality
        of the second input and the second dimension corresponds to the cardinality of the first input. If “ij” is selected, the dimensions are in the
        same order as the cardinality of the inputs.
Returns:
     Tensor: k tensors. The shape of each tensor is (N1, N2, ..., Nk)

Examples:
    .. code-block:: pycon

        >>> import paddle

        >>> x = paddle.randint(low=0, high=100, shape=[100])
        >>> y = paddle.randint(low=0, high=100, shape=[200])

        >>> grid_x, grid_y = paddle.meshgrid(x, y)

        >>> print(grid_x.shape)
        paddle.Size([100, 200])
        >>> print(grid_y.shape)
        paddle.Size([100, 200])

rN   Nrb  ijrw   r   )rf  xyz1meshgrid: indexing must be 'ij' or 'xy', but got rg  r   rc  z2The type of input args in meshgrid should be list.zcreate data type)rL   rD   rE   rF   rI   rJ   r   r   r8   r  r   rE  )rc  )rX  popr   r   rT   rU   r   r   r   rc  r   rY   r   r   r   r9   r?  rB  r   r   )ra  rW  rN   rb  swap_xyrq   r`   idinput_ro   is              r:   rc  rc  6
  s   B ::fd#Dzz*d+H
4yA~*T!WtUm<<Aw|#?zJ
 	
 $13t9>GQa,48,ood4j)4684$u..D  $D/JB"	  *" $i ^^C(
( 55DGMM5J( 	 
 	S$t*$5s| 	 	
 QQAAJ
s   %F9c                *   U H  nUS:  d  M  [        S5      e   [        U5      nX@R                  U   :w  a  [        SU SU R                  U    35      e/ nSnU H3  nXc-   n[        R                  " X/U/U/S9nUR                  U5        UnM5     U$ )a~  
Splits the input tensor into multiple sub tensors according to given split sizes.

Args:
    self (Tensor): The input tensor to be split.
    split_sizes (list[int]): A list of non negative integers specifying
        the sizes of each split along dimension ``dim``. The sum of all
        elements in this list must equal the size of ``self`` along ``dim``.
    dim (int, optional): The dimension along which to split the tensor.
        Defaults to 0.

Returns:
    list[Tensor]: A list of sub tensors resulting from splitting ``self``
    along the specified dimension.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.to_tensor([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
        >>> # Split into two parts along the first dimension, of sizes 1 and 2
        >>> splits = paddle.Tensor.split_with_sizes(x, [1, 2], dim=0)
        >>> print(splits)
r   zCsplit_with_sizes expects split_sizes have only non-negative entrieszSplit sizes add up to z but got the tensor's size of )axesstartsends)r   sumr?   r3   sliceappend)	r   split_sizesdimr   totaloutsrz   rn   rq   s	            r:   split_with_sizesrx  
  s    6 !8U   E

3$UG+I$**UX/IZ[
 	
 DElll4eUG3%HC	  Kr<   c                Z   [        U [        5      (       d  [        U 5      n [        5       (       a  [        R
                  " XX#5      $ SU /0nXUS.nS nU" XX#5        [        S	0 [        5       D6nUR                  U R                  S9nUR                  SSU /0XUS.SU/0S9  SUl        U$ )
ax	  
Creates a tensor whose diagonals of certain 2D planes (specified by dim1 and dim2)
are filled by ``input``. By default, a 2D plane formed by the last two dimensions
of the returned tensor will be selected.

The argument ``offset`` determines which diagonal is generated:

- If offset = 0, it is the main diagonal.
- If offset > 0, it is above the main diagonal.
- If offset < 0, it is below the main diagonal.

Args:
    input(Tensor|numpy.ndarray): The input tensor. Must be at least 1-dimensional. The input data type should be float32, float64, int32, int64.
    offset(int, optional): Which diagonal to consider. Default: 0 (main diagonal).
    dim1(int, optional): The first dimension with respect to which to take diagonal. Default: -2.
    dim2(int, optional): The second dimension with respect to which to take diagonal. Default: -1.

Returns:
    Tensor, the output data type is the same as input data type.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> diag_embed_input = paddle.arange(6)

        >>> diag_embed_output1 = paddle.diag_embed(diag_embed_input)
        >>> print(diag_embed_output1)
        Tensor(shape=[6, 6], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 0],
         [0, 0, 2, 0, 0, 0],
         [0, 0, 0, 3, 0, 0],
         [0, 0, 0, 0, 4, 0],
         [0, 0, 0, 0, 0, 5]])

        >>> diag_embed_output2 = paddle.diag_embed(diag_embed_input, offset=-1, dim1=0,dim2=1 )
        >>> print(diag_embed_output2)
        Tensor(shape=[7, 7], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 0, 0],
         [0, 0, 2, 0, 0, 0, 0],
         [0, 0, 0, 3, 0, 0, 0],
         [0, 0, 0, 0, 4, 0, 0],
         [0, 0, 0, 0, 0, 5, 0]])

        >>> diag_embed_input_2dim = paddle.reshape(diag_embed_input,[2,3])
        >>> print(diag_embed_input_2dim)
        Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 1, 2],
        [3, 4, 5]])
        >>> diag_embed_output3 = paddle.diag_embed(diag_embed_input_2dim,offset= 0, dim1=0, dim2=2 )
        >>> print(diag_embed_output3)
        Tensor(shape=[3, 2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[[0, 0, 0],
          [3, 0, 0]],
         [[0, 1, 0],
          [0, 4, 0]],
         [[0, 0, 2],
          [0, 0, 5]]])
Input)offsetdim1dim2c                Z   [        U R                  S/ SQS5        [        U R                  5      n[	        U5      S:  d   S[	        U5       S35       e[
        R                  " U5      [	        U5      ::  d'   S[	        U5      S-   *  S[	        U5       S	U S
35       e[
        R                  " U5      [	        U5      ::  d'   S[	        U5      S-   *  S[	        U5       S	U S
35       eUS:  a  UO[	        U5      U-   S-   nUS:  a  UO[	        U5      U-   S-   nXV:w  d   SU SU S35       eg )Nrz  )rI   rJ   rD   rE   rF   
diag_embedrw   zHInput must be at least 1-dimensional, But received Input's dimensional: z.
z2Dim1 is out of range (expected to be in range of [z, z], but got z).
z2Dim2 is out of range (expected to be in range of [r   z?dim1 and dim2 cannot be the same dimension.But received dim1 = z	, dim2 = 
)r   r9   rT   r?   r   rV   abs)r  r{  r|  r}  input_shapedim1_dim2_s          r:   __check_input!diag_embed.<locals>.__check_input  s|   KK?		
 5;;';1$ 	
114[1A0B#G	
$
 vvd|s;// 	
@3{CSVWCWAX@YY[\_`k\l[mmxy}x~  C  D	
/ vvd|s;// 	
@3{CSVWCWAX@YY[\_`k\l[mmxy}x~  C  D	
/ 	s;'7$'>'B	s;'7$'>'B~ 	
##'&	$r;	
~r<   r  r8   r   r   T)r  )r   r   r   r   r   r  r   rY   r   r9   r   rO   )	r  r{  r|  r}  r   r   r  r`   rq   s	            r:   r  r  
  s    D eX&&u  ;;wFT:E
: %,22F

3
3%++
3
FC
%!t<	   CJr<   c                   [        5       (       a_  [        U R                  5      S::  a  [        R                  " XS5      $ [        R
                  " U SS5      n[        R                  " X1S5      $ Sn[        U S[        S5        [        U R                  S/ SQS5        [        US[        S5        [        S0 [        5       D6nUR                  U R                  S9nUR                  U R                  5      nUR                  U R                  S9n[        U R                  5      S::  a  UR                  S	S
U 0SU0XS.S9  O8UR                  SS
U 0XgS.SSS.S9  SUl        UR                  S	S
U0SU0XS.S9  SUl        U$ )a
  
If ``x`` is a vector (1-D tensor), a 2-D square tensor with the elements of ``x`` as the diagonal is returned.

If ``x`` is a tensor (more than 1-D), a 2-D square tensor with the elements of flattened ``x`` as the diagonal is returned.

The argument ``offset`` controls the diagonal offset.


If ``offset`` = 0, it is the main diagonal.

If ``offset`` > 0, it is superdiagonal.

If ``offset`` < 0, it is subdiagonal.

Args:
    x (Tensor): The input tensor. It can be any shape. Its data type should be float16, float32, float64, int32, int64.
    offset (int, optional): The diagonal offset. A positive value represents superdiagonal, 0 represents the main diagonal, and a negative value represents subdiagonal. Default: 0 (main diagonal).
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor, a square matrix. The output data type is the same as input data type.

Examples:
    .. code-block:: python
        :name: diagflat-example-1

        >>> import paddle

        >>> x = paddle.to_tensor([1, 2, 3])
        >>> y = paddle.diagflat(x)
        >>> print(y)
        Tensor(shape=[3, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[1, 0, 0],
         [0, 2, 0],
         [0, 0, 3]])

        >>> y = paddle.diagflat(x, offset=1)
        >>> print(y)
        Tensor(shape=[4, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 1, 0, 0],
         [0, 0, 2, 0],
         [0, 0, 0, 3],
         [0, 0, 0, 0]])

        >>> y = paddle.diagflat(x, offset=-1)
        >>> print(y)
        Tensor(shape=[4, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 0, 0, 0],
         [1, 0, 0, 0],
         [0, 2, 0, 0],
         [0, 0, 3, 0]])

    .. code-block:: python
        :name: diagflat-example-2

        >>> import paddle

        >>> x = paddle.to_tensor([[1, 2], [3, 4]])
        >>> y = paddle.diagflat(x)
        >>> print(y)
        Tensor(shape=[4, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[1, 0, 0, 0],
         [0, 2, 0, 0],
         [0, 0, 3, 0],
         [0, 0, 0, 4]])

        >>> y = paddle.diagflat(x, offset=1)
        >>> print(y)
        Tensor(shape=[5, 5], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 1, 0, 0, 0],
         [0, 0, 2, 0, 0],
         [0, 0, 0, 3, 0],
         [0, 0, 0, 0, 4],
         [0, 0, 0, 0, 0]])

        >>> y = paddle.diagflat(x, offset=-1)
        >>> print(y)
        Tensor(shape=[5, 5], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 0, 0, 0, 0],
         [1, 0, 0, 0, 0],
         [0, 2, 0, 0, 0],
         [0, 0, 3, 0, 0],
         [0, 0, 0, 4, 0]])

rw   r   r  r  diagflat)rD   rE   rF   rI   rJ   rL   r{  r8   diag_v2r  r   r{  padding_valuerf   r   r   r   flatten_contiguous_range)r   XShape)
start_axis	stop_axisT)r  )r   r   r?   r   diagflattenr   r   r   r9   rX   r   rY   r   r   rO   )	r  r{  rN   yr  r`   out1
out1_shapeout2s	            r:   r  r  :  s   p qww<1;;q!,,q!R(A;;q!,,1cHz2GGI		
 	68cJ7468488qww8G>>qwwG
88qww8Gqww<1Qx!'H	   /Qx $;%&R8	   "&DT{!'H	   "r<   c                :   [        5       (       a  [        R                  " XU5      $ [        U S[        S5        [        U R                  S/ SQS5        [        US[        S5        [        US[        [        4S5        [        U R                  5      S:w  a:  [        U R                  5      S:w  a!  [        S[        U R                  5       35      e[        S0 [        5       D6nUR                  U R                  S	9nUR                  SS
U 0SU0XS.S9  SUl        U$ )a
  
If ``x`` is a vector (1-D tensor), a 2-D square tensor with the elements of ``x`` as the diagonal is returned.

If ``x`` is a matrix (2-D tensor), a 1-D tensor with the diagonal elements of ``x`` is returned.

The argument ``offset`` controls the diagonal offset:

If ``offset`` = 0, it is the main diagonal.

If ``offset`` > 0, it is superdiagonal.

If ``offset`` < 0, it is subdiagonal.

Args:
    x (Tensor): The input tensor. Its shape is either 1-D or 2-D. Its data type should be float16, float32, float64, int32, int64, complex64, complex128.
    offset (int, optional): The diagonal offset. A positive value represents superdiagonal, 0 represents the main diagonal, and a negative value represents subdiagonal.
    padding_value (int|float, optional): Use this value to fill the area outside the specified diagonal band. Only takes effect when the input is a 1-D Tensor. The default value is 0.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor, a square matrix or a vector. The output data type is the same as input data type.

Examples:
    .. code-block:: python
        :name: diag-example-1

        >>> import paddle

        >>> paddle.disable_static()
        >>> x = paddle.to_tensor([1, 2, 3])
        >>> y = paddle.diag(x)
        >>> print(y)
        Tensor(shape=[3, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[1, 0, 0],
         [0, 2, 0],
         [0, 0, 3]])

        >>> y = paddle.diag(x, offset=1)
        >>> print(y)
        Tensor(shape=[4, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 1, 0, 0],
         [0, 0, 2, 0],
         [0, 0, 0, 3],
         [0, 0, 0, 0]])

        >>> y = paddle.diag(x, padding_value=6)
        >>> print(y)
        Tensor(shape=[3, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[1, 6, 6],
         [6, 2, 6],
         [6, 6, 3]])

    .. code-block:: python
        :name: diag-example-2

        >>> import paddle

        >>> paddle.disable_static()
        >>> x = paddle.to_tensor([[1, 2, 3], [4, 5, 6]])
        >>> y = paddle.diag(x)
        >>> print(y)
        Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [1, 5])

        >>> y = paddle.diag(x, offset=1)
        >>> print(y)
        Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True,
        [2, 6])

        >>> y = paddle.diag(x, offset=-1)
        >>> print(y)
        Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True,
        [4])
r  r  )	rD   rL   rE   rF   rL   rI   rJ   r   r   r{  r  rw   r   z=The dimension of input x must be either 1 or 2, but received r8   r  r   r  r  T)r  )r   r   r  r   r   r   r9   rX   r^   r   r?   r   r   rY   r   r   rO   )r  r{  r  rN   r`   rq   s         r:   r  r    s   ` {{1m441cHy1GG
 	
  	68cI6=/C<Kqww<1QWW!2OPSTUT[T[P\~^  3&(377agg7F8CL#D	 	 	
 !
r<   c                  Uc  [         R                  " 5       n[        U5      n[        5       (       Ga  [	        5       (       a   [         R
                  R                  U 5      n O[        US/ SQS5        [         R
                  R                  U 5        [        U [        R                  5      (       a  U R                  5       n [        U [        [        45      (       aD  [         R
                  R                  U 5      (       a  [         R
                  R!                  U 5      n O5[        U [         R"                  R$                  5      (       a  O['        S5      eUb  [)        U5      O	[+        5       nU(       Ga#  [	        5       (       Ga  UGb  [        U[,        R.                  [,        R0                  45      (       d  [        U[,        R2                  5      (       d4  [        U[,        R4                  5      (       a+  UR7                  5       (       a  [,        R.                  " 5       nOw[        U[,        R8                  5      (       d4  [        U[,        R4                  5      (       a+  UR;                  5       (       a  [,        R0                  " 5       nO[=        SU 35      e[>        R@                  " U [C        U5      UUS9nU(       a  [	        5       (       a  URE                  5       nUSL a  SUl#        Ub  SUl#        U$ [I        S0 [K        5       D6n0 n	[        US/ SQS5        [M        U S	[N        [        [        4S5        [        U [N        5      (       a  [        U RP                  S	S
S/S5        0 n
[         R
                  RS                  XU SS9  URU                  US9n[C        U5      U
S'   URW                  SU	SU/0U
SS9  SUl#        U$ )a&	  
Returns a Tensor with uninitialized data which size is same as ``shape``.

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): Data type of the output Tensor
        which can be bool, float16, float32, float64, int32, int64, complex64, complex128 if dtype is `None`, the data
        type of created Tensor use global default dtype (see ``get_default_dtype``
        for details).
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor: Tensor which is created according to ``shape`` and ``dtype``, and is uninitialized.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # shape is a list/tuple
        >>> data1 = paddle.empty(shape=[3, 2])
        >>> print(data1.numpy())
        >>> # doctest: +SKIP('change everytime')
        [[1. 1.]
         [1. 1.]
         [1. 1.]]

        >>> # shape is a Tensor
        >>> shape = paddle.to_tensor([3, 2])
        >>> data2 = paddle.empty(shape=shape)
        >>> print(data2.numpy())
        >>> # doctest: +SKIP('change everytime')
        [[1. 1.]
         [1. 1.]
         [1. 1.]]

        >>> # shape is a Tensor List
        >>> shape = [paddle.to_tensor(3), paddle.to_tensor(2)]
        >>> data3 = paddle.empty(shape=shape)
        >>> print(data3.numpy())
        >>> # doctest: +SKIP('change everytime')
        [[1. 1.]
         [1. 1.]
         [1. 1.]]
r9   )r@   rD   rE   rF   rL   rG   rH   rI   rJ   r   r   r  emptyr  r   ry   TFr?   rI   rJ   r  r8   r   r  )r  ),r3   r   r   r   r   r   r!  r   r"  r   rV   rW   tolistrT   rU   r#  r$  r4   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r   r   rO   r   rY   r   r   r9   r&  r   r   )r?   r9   rN   rq   rr   rs   r   r   r`   r   r   s              r:   r  r  <  s   B }((*% ELL66u=E #( LL$$U+%,,%$//<<,,U33"LL<<UCEE6::#3#344 OPP ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  &u-	
 /++&&(FD #(F $)!11 #	
& 	5'HdE#:GDeX&&Ww.@'J,,eW 	- 	
 77e7D3E:gSEN 	 	
 !
r<   c               X   Uc  U R                   nUc  U R                  n[        U5      n[        5       (       Ga  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[        5       (       a  U R"                  nO[$        R"                  " U 5      n[&        R(                  " U[+        U5      U5      nUSL a  SUl        U(       a  [        5       (       a  UR/                  5       nU$ [1        S0 [3        5       D6n[5        U S/ SQS5        [7        US/ SQS5        UR9                  US9n	0 n
0 n[+        U5      US'   [$        R"                  " U 5      n[$        R:                  R=                  XUSS	9  UR?                  S
U
SU	/0USS9  SU	l        U	$ )a  
Returns a Tensor with uninitialized data which has identical shape of ``x`` and ``dtype``.
If the ``dtype`` is None, the data type of Tensor is same with ``x``.

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

Args:
    x(Tensor): The input tensor which specifies shape and data type. The data type can be bool, float16, float32, float64, int32, int64.
    dtype(str|paddle.dtype|np.dtype, optional): The data type of output. The data type can be one
        of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
        data type is the same as input.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    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.
    pin_memory(bool, optional): If set, return tensor would be allocated in the pinned memory. Works only for CPU tensors. Default: False

Returns:
    Tensor: Tensor which is created according to ``x`` and ``dtype``, and is uninitialized.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> paddle.set_device("cpu")  # and use cpu device

        >>> x = paddle.randn([2, 3], 'float32')
        >>> output = paddle.empty_like(x)
        >>> print(output)
        >>> # doctest: +SKIP('change everytime')
        [[1.8491974e+20 1.8037303e+28 1.7443726e+28]
         [4.9640171e+28 3.0186127e+32 5.6715899e-11]]
r   TF
empty_liker  )r@   rD   rE   rF   rG   rH   rI   rJ   rL   r   r   r9   r8   r  r  r   r  )r  ) r9   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r?   r3   r   r  r   rO   r   r   rY   r   r   r   r   r&  r   )r  r9   rN   rr   rs   r   x_shaper   r`   rq   r   r   r?   s                r:   r  r    s^   ^ }~% E ! f%(* 	 !!"--t/B/BC  &$..1164::..63F3F3H3H--/FDMM2264::..63F3F3H3H,,.":6(C  ggGll1oG&u-

 D #(F /++&&(F 6VX6  !	
$ 	 !	
$ 77e7D3E:gQ,,e\ 	- 	
 	SEN 	 	
 !
r<   c                   XL a1  [        U [        [        R                  R                  45      (       a  U $ U n[        S0 [        5       D6n[        US[        [        R                  R                  [        R                  [        [        [        [        [        4S5        [        R                  " U5      (       a-  [        U[         5      (       d  [        R"                  " U/5      nO1[        U[        [        45      (       a  [        R"                  " U5      n[        U[        [$        R&                  R(                  [        R                  R                  45      (       a  [+        5       (       a4  Uc  [,        R.                  " U5      nU$ [,        R0                  " X!5      n U$ [3        UR4                  S/ SQSS5        Uc  UR7                  UR4                  S9nUR9                  SSU/0SU/0S9   U$ [        U[        R                  5      (       Ga-  [;        UR<                  5      S	:  a  [?        S
 U 5       5      (       ah  [A        S U 5       5      (       d  [C        S5      eS n[        [E        XB5      5      n[        RF                  " U5      n[        RH                  " US5      nU$ UR4                  S:X  a   [C        S5      e[K        UR4                  5      n[3        US/ SQSS5        SnURM                  5       RO                  5       n	Sn
URP                  U
:  a*  S	SK)J*n  U" SS9n[W        S5      nURY                  U5        Ue[+        5       (       a  Uc  [[        [        UR<                  5      U5      n[]        5       (       a7  [,        R^                  " U[        UR<                  5      UU	[a        5       5        U$ [,        R^                  " U[        UR<                  5      UU	[a        5       5      n U$ Uc  UR7                  UR4                  S9nUR9                  SSU/0SUS[        UR<                  5      X0S9  U$ )a  

Copy value of the :attr:`x` to the :attr:`output`.

Parameters:
    x (Tensor|np.ndarray|list|tuple|scalar): A Tensor, numpy ndarray, tuple/list of scalar,
        or scalar. Its data type can be float16, float32, float64, int32, int64 or bool. Note: the float64 data will be converted to float32 because of current platform protobuf
        data limitation.
    output (Tensor|None, optional): A Tensor. If :attr:`output` is None, a new Tensor will be created as :attr:`output`. Default: None.

Returns:
    Tensor: A Tensor with the same shape, data type and value as :attr:`x`.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import numpy as np
        >>> data = paddle.full(shape=[3, 2], fill_value=2.5, dtype='float64')
        >>> print(data.numpy())
        [[2.5 2.5]
         [2.5 2.5]
         [2.5 2.5]]
        >>> array = np.array([[1, 1], [3, 4], [1, 3]]).astype(
        ...     np.int64
        ... )
        >>> result1 = paddle.zeros(shape=[3, 3], dtype='float32')
        >>> paddle.assign(array, result1)
        >>> print(result1.numpy())
        [[1 1]
         [3 4]
         [1 3]]
        >>> result2 = paddle.assign(data)
        >>> print(result2.numpy())
        [[2.5 2.5]
         [2.5 2.5]
         [2.5 2.5]]
        >>> result3 = paddle.assign(np.array([[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]], dtype='float32'))
        >>> print(result3.numpy())
        [[2.5 2.5]
         [2.5 2.5]
         [2.5 2.5]]
r   r  )rD   rL   rE   rF   rH   rI   rJ   rK   rG   r@   r   r   z/(When the type of input in assign is Variable.)r8   r  r   rE  r   c              3  v   #    U  H/  n[        U[        [        R                  R                  45      v   M1     g 7fr,   )r   r   r3   r4   r   .0r  s     r:   	<genexpr>assign.<locals>.<genexpr>  s,      (
AFAJq8VZZ%5%5677s   79c              3     #    U  H^  n[        U[        [        R                  R                  [
        R                  R                  45      (       d  MM  UR                  S :H  v   M`     g7f))rw   N)	r   r   r   r   r   r3   r4   r   r?   r  s     r:   r  r    sI      A$**"3"3VZZ5E5EF  4s   AA(A(zLUnsupported paddle.assign([Variable, Variable...]) with non-scalar variable.c                    [        U [        [        R                  R                  [
        R                  R                  45      (       d  [        U 5      $ U $ r,   )	r   r   r   r   r   r3   r4   r   r   )r  s    r:   convert_scalarassign.<locals>.convert_scalar  s@    !$**"3"3VZZ5E5EF  "!9$r<   r  r   zrThe type of received input == `object`, it is not supported to convert to tensor, such as [[Var], [Var], [3], [4]])rE   rF   rI   rJ   r@   r   r   z2(When the type of input in assign is numpy array.)valuesl        )SotExtraInfoT)need_breakgraphzXThe size of input is too big. Please consider saving it to file and 'load_op' to load itassign_valuer9   r?   )rf   r   r   )r   )1r   r   r3   r4   r   r   rY   r   rV   rW   rT   rU   r^   rX   r@   r   r   r   r   r   r   r   r   r   assign_out_r   r9   r   r   r   r?   anyallr   mapr   squeezer   ravelr  r   paddle.jit.sot.utils.exceptionsr  r   attachr0  r   assign_value_r   )r  r   r  r`   r  r   r   r9   
value_namer  max_element_numr  sot_extra_infoerrs                 r:   r   r     s   Z 	{z!h

0@0@%ABBE.VX.FJJJJ		
 	  
{{5*UC"8"8%!	ED%=	)	) %(DJJ$5$5vzz7G7GHII!##~u-B M  ++E:~ M{  A%( ~BB++ C  sUGnuvh>O  J ME 
E2::	&	&u{{aC (
AF(
 %
 %
      b  !^!;<M,,}-C..b)CJ;;("L E  +5;;7 @	
 
%%'%::'D)$?N=C !!#&I!##~tEKK0%8  $$%+-< M-  --%+-, M ~BB++ C  #)UT%++.   Mr<   c                "    U R                  5       $ )aX  
Returns a copy of input Tensor. It will always have a Tensor copy.

In addition, This function is derivable, so gradients will flow back from the output to input.

Parameters:
    x (Tensor): The input Tensor.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor, A Tensor copied from ``input``.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import numpy as np

        >>> x = paddle.ones([2])
        >>> x.stop_gradient = False
        >>> x.retain_grads()
        >>> clone_x = paddle.clone(x)
        >>> clone_x.retain_grads()

        >>> y = clone_x**3
        >>> y.backward()
        >>> print(clone_x.grad.numpy())  # type: ignore
        [3. 3.]
        >>> print(x.grad.numpy())  # type: ignore
        [3. 3.]
)clone)r  rN   s     r:   r  r  f  s    @ 779r<   c                   SnUc  SnO[         R                  " 5       nUR                  U5        UR                  5       (       a  SnO_UR	                  5       (       a  SnOGUR                  5       (       a  SnO/UR                  5       (       a  SnOUR                  5       (       a  Sn[        5       (       a  [        R                  " X5      $ [        S0 [        5       D6n[        U S[        S5        [        U [        [         R                   R"                  45      (       a  [%        U R&                  S/ S	QSS
5        Uc  UR)                  U R&                  S9nSU0nUR+                  SSU /0SU/0US9  U$ )a  

The OP copies the :attr:`input` to the :attr:`output`.
NOTE: currently, only support CUDAPlace <-> CUDAPinnedPlace.

Parameters:
    input (Tensor): A tensor. Its data type supports float16, float32, float64, int32, int64, and bool.
    device (Place): Target place for the output.
    output (Tensor, optional): A tensor. If :attr:`output` is None, a new tensor will
        be created as :attr:`output`. Default: None.

Returns:
    Tensor, A tensor with the same shape, data type and value as :attr:`input`.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> data = paddle.full(shape=[3, 2], fill_value=2.5, dtype='float64')
        >>> print(data.numpy())
        [[2.5 2.5]
         [2.5 2.5]
         [2.5 2.5]]
        >>> # doctest: +SKIP('NOTE(zhiqiu): not public')
        >>> result = paddle._memcpy(data, place=paddle.CPUPlace())
        >>> print(result2)
        [[2.5 2.5]
         [2.5 2.5]
         [2.5 2.5]]
r  r   rw   r         memcpyr  )	rD   rL   rE   rF   rI   rJ   rK   rG   r@   z/(When the type of input in memcpy is Variable.)r8   dst_place_typer  r   r  )r  )r   r   	set_placeis_cpu_placer   is_cuda_pinned_placer  is_custom_placer    r   r  r   rY   r   r   r   r   r   r   r9   r   r   )r  r   r   r  pr`   r   s          r:   _memcpyr    sR   @ N}JJL	E>>N^^N##%%N^^N  N}}}}U33.VX.Fug84%(DJJ$5$5677KK
 =	
" ~:::M~.E
eW~!	   Mr<   ry   c               2   [        5       (       a  [        R                  " XUS9$ [        U SSS/S5        [        USSS/S5        Sn[	        U40 [        5       D6nXS.nUR                  [        U R                  5      S9nS	U0n0 nUR                  XFXS
9  U$ )a  Return a complex tensor given the real and image component.

Args:
    real (Tensor): The real component. The data type should be 'float32' or 'float64'.
    imag (Tensor): The image component. The data type should be the same as ``real``.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    out(Tensor|None, optional): The output tensor. Default: None.

Returns:
    Tensor, The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``real`` and ``imag``.

Note:
    ``paddle.complex`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .

    .. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor

Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.arange(2, dtype=paddle.float32).unsqueeze(-1)
        >>> y = paddle.arange(3, dtype=paddle.float32)
        >>> z = paddle.complex(x, y)
        >>> print(z)
        Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
        [[0j    , 1j    , 2j    ],
         [(1+0j), (1+1j), (1+2j)]])
ry   realrE   rF   r@  imag)r  Yr8   r   r   )
r   r   r@  r   r   rY   r   r>   r9   r   )	r  r  rN   rq   r  r`   r   r   r   s	            r:   r@  r@    s    F ~~dc22 &9i0)	
 	!&9i0)	
 W11'77(4 8 
 #,u 	 	
 
r<   rJ   c           
     R   [        U[        R                  R                  [        R                  45      (       d  [        U5      n[        U [        5      (       a  U S:  a  [        S5      eUb'  [        U[        5      (       a  US:  a  [        S5      eOU n[        5       (       a'  Uc  U n[        R                  " XX#[        5       5      nU$ [        U[        5      (       d  [        S5      e[        S
0 [        5       D6nUR                  US9nUR                  S0 SU/0XX#S.S	9  U$ )a  
Return the indices of the lower triangular part of the 2-D matrix
whose row and col is known. Indices are ordered based on row and then columns.
The lower triangular part of the matrix is defined as the elements on
and below the diagonal.

Args:
    row (int): The input x which is a int number describe the number of row of the matrix.
    col (int): The input x which is a int number describe the number of col of the matrix.
    offset (int, optional): The offset to consider, default value is 0.

        - If offset = 0, all elements on and below the main diagonal are retained.
        - If offset > 0, include just as many diagonals above the main diagonal.
        - If offset < 0, excludes just as many diagonals below the main diagonal.

    dtype (str|core.VarDesc.VarType|core.DataType, optional): the data type of the output tensor, can be int32, int64.

Returns:
    Tensor: Results of the indices of lower triangular part of a row * col matrix,
    where the first row contains row coordinates of and the second row contains column coordinates.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> # example 1, default offset value
        >>> data1 = paddle.tril_indices(4,4,0)
        >>> print(data1)
        Tensor(shape=[2, 10], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 1, 1, 2, 2, 2, 3, 3, 3, 3],
         [0, 0, 1, 0, 1, 2, 0, 1, 2, 3]])

        >>> # example 2, positive offset value
        >>> data2 = paddle.tril_indices(4,4,2)
        >>> print(data2)
        Tensor(shape=[2, 15], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],
         [0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]])

        >>> # example 3, negative offset value
        >>> data3 = paddle.tril_indices(4,4,-1)
        >>> print(data3)
        Tensor(shape=[2, 6], dtype=int64, place=Place(cpu), stop_gradient=True,
        [[1, 2, 2, 3, 3, 3],
         [0, 0, 1, 0, 1, 2]])
r    row should be a non-negative int col should be a non-negative intzoffset should be a  inttril_indicesr8   rq   )rowscolsr{  r9   r  )r  )r   r   r-   r.   r5   r   rX   r   r   r   r  r   r   rY   r   r   rowcolr{  r9   rq   r`   s         r:   r  r    s   d edll22DMMBCC*51c337:;;
#s##sQw>?? (/ ;C!!f%<%>
 
&#&&5668vx877e7DSENvN	 	 	
 Jr<   c           
     R   [        U[        R                  R                  [        R                  45      (       d  [        U5      n[        U [        5      (       a  U S:  a  [        S5      eUb'  [        U[        5      (       a  US:  a  [        S5      eOU n[        5       (       a'  Uc  U n[        R                  " XX#[        5       5      nU$ [        U[        5      (       d  [        S5      e[        S
0 [        5       D6nUR                  US9nUR                  S0 SU/0XX#S.S	9  U$ )a)  
Return the indices of the upper triangular part of the 2-D matrix
whose row and col is known. Indices are ordered based on row and then columns.
The upper triangular part of the matrix is defined as the elements on
and above the diagonal.

Args:
    row (int): The input x which is a int number describe the number of row of the matrix.
    col (int|None, optional): The input x which is a int number describe the number of col of the matrix.
        default value for col is None, then it will be set equal to row, indicting a square matrix.
    offset (int, optional): The offset to consider, default value is 0.

        - If offset = 0, all elements on and above the main diagonal are retained.
        - If offset > 0, include just as few diagonals above the main diagonal.
        - If offset < 0, excludes just as few diagonals below the main diagonal.

    dtype (str|np.dtype|core.VarDesc.VarType|core.DataType, optional): the data type of the output tensor,
        can be int32, int64, default value is int64.
Returns:
    Tensor: Results of the indices of upper triangular part of a row * col matrix,
    where the first row contains row coordinates of and the second row contains column coordinates.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> # example 1, default offset value
        >>> data1 = paddle.triu_indices(4,4,0)
        >>> print(data1.numpy())
        [[0 0 0 0 1 1 1 2 2 3]
         [0 1 2 3 1 2 3 2 3 3]]
        >>> # example 2, positive offset value
        >>> data2 = paddle.triu_indices(4,4,2)
        >>> print(data2.numpy())
        [[0 0 1]
         [2 3 3]]
        >>> # example 3, negative offset value
        >>> data3 = paddle.triu_indices(4,4,-1)
        >>> print(data3.numpy())
        [[0 0 0 0 1 1 1 1 2 2 2 3 3]
         [0 1 2 3 0 1 2 3 1 2 3 2 3]]
r   r  r  zoffset should be a inttriu_indicesr8   rq   )r  r  r{  r9   r  )r  )r   r   r-   r.   r5   r   rX   r   r   r   r  r   r   rY   r   r   r  s         r:   r  r  p  s   \ edll22DMMBCC*51c337:;;
#s##sQw>?? (/ ;C!!f%<%>
 
&#&&4558vx877e7DSENVL	 	 	
 Jr<   c                   [        U SSS/S5        [        USSS/S5        [        R                  " U [        R                  " U5      -  U [        R                  " U5      -  X2S9$ )a  Return a Cartesian coordinates corresponding to the polar coordinates complex tensor given the ``abs`` and ``angle`` component.

Args:
    abs (Tensor): The abs component. The data type should be 'float32' or 'float64'.
    angle (Tensor): The angle component. The data type should be the same as ``abs``.
    name (str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
    out (Tensor, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.

Returns:
    Tensor, The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``abs`` and ``angle``.

Note:
    ``paddle.polar`` supports broadcasting. If you want know more about broadcasting, please refer to `Introduction to Tensor`_ .

    .. _Introduction to Tensor: ../../guides/beginner/tensor_en.html#chapter5-broadcasting-of-tensor

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import numpy as np

        >>> abs = paddle.to_tensor([1, 2], dtype=paddle.float64)
        >>> angle = paddle.to_tensor([np.pi / 2, 5 * np.pi / 4], dtype=paddle.float64)
        >>> out = paddle.polar(abs, angle)
        >>> print(out)
        Tensor(shape=[2], dtype=complex128, place=Place(cpu), stop_gradient=True,
        [ (6.123233995736766e-17+1j)             ,
         (-1.4142135623730954-1.414213562373095j)])
r  rE   rF   zpaddle.polarangle)rq   rN   )r   r3   r@  cossin)r  r  rN   rq   s       r:   polarr    sd    J S%)Y)?PwI. >>fjjvzz%'8!8c r<   c                   U R                  5         [        R                  " U5      R                  U R                  5      n[        R                  " S5      R                  U R                  5      nU R                  U5      R                  [        R                  5      R                  5       R                  U5      R                  U5        U $ )a5  Fills the tensor with numbers drawn from the Cauchy distribution.

Args:
    x (Tensor): the tensor will be filled, The data type is float32 or float64.
    loc (scalar, optional):  Location of the peak of the distribution. The data type is float32 or float64.
    scale (scalar, optional): The half-width at half-maximum (HWHM). The data type is float32 or float64. Must be positive values.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor: input tensor with numbers drawn from the Cauchy distribution.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.randn([3, 4])
        >>> x.cauchy_(1, 2)
        >>> # doctest: +SKIP('random check')
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[ 3.80087137,  2.25415039,  2.77960515,  7.64125967],
         [ 0.76541221,  2.74023032,  1.99383152, -0.12685823],
         [ 1.45228469,  1.76275957, -4.30458832, 34.74880219]])

g      ?)normal_r3   r   r   r9   	subtract_scale_rV   pitan_add_)r  locscalerN   halfs        r:   cauchy_r    s    @ IIK


3

&
&qww
/CC ''0DKKRUU#((*11%8==cBHr<   c                r   [         R                  " [        U R                  5      S9R                  n[
        R                  " U5      R                  U R                  5      nU R                  [        U5      [        S5      S9  U R                  5       R                  [
        R                  " U* 5      5        U $ )a  Fills the tensor with numbers drawn from the Geometric distribution.

Args:
    x (Tensor): the tensor will be filled, The data type is float32 or float64.
    probs (float|Tensor): Probability parameter.
        The value of probs must be positive. When the parameter is a tensor, probs is probability of success for each trial.
    name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.

Returns:
    Tensor: input tensor with numbers drawn from the Geometric distribution.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> x = paddle.randn([3, 4])
        >>> x.geometric_(0.3)
        >>> # doctest: +SKIP('random check')
        >>> print(x)
        Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[2.42739224, 4.78268528, 1.23302543, 3.76555204],
         [1.38877118, 0.16075331, 0.16401523, 2.47349310],
         [1.72872102, 2.76533413, 0.33410925, 1.63351011]])

r8   rw   )minmax)rV   finfor   r9   tinyr3   r   r   uniform_r^   log_divide_log1p)r  probsrN   r  s       r:   
geometric_r    s|    > 88-0166DU#**1773EJJ5;E!HJ-FFHV\\E(+,Hr<   c                b   [        5       (       Ga  U R                  (       a*  U R                  (       d  [        SU R                   S35      eUc'  [
        R                  " S/U R                  S9nS/nS/nO`[        U[        [        R                  R                  45      (       d  [        S[        U5       35      e[        UR                  S/ SQS	5        Uc0  Uc  UR                  nO [
        R                  " U5      R                  nUc  UR                   n["        R$                  " XX#U5      $ g)
a>  
set x with specified source Tensor's underlying storage, shape, stride and offset.

Note that the ``x`` will share the same data with ``source`` Tensor.

Args:
    x (Tensor): An arbitrary Tensor. The data type supports ``bfloat16``, ``float16``, ``float32``, ``float64``,
        ``bool``, ``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``complex64`` or ``complex128``.
    source (Tensor|None, optional): Define the target Tensor to use. The data type supports `bfloat16`, ``float16``,
        ``float32``, ``float64``, ``bool``, ``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``complex64`` or
        ``complex128``. Default: None, which means to set ``x`` with an empty source tensor.
    shape (list|tuple|None, optional): Define the target shape. Each element of it should be integer. Default: None,
        which means it will use the specified ``source``'s shape as default value.
    stride (list|tuple|None, optional): Define the target stride. Each element of it should be integer. Default: None,
        and when ``shape`` is also None, it will use the specified ``source``'s stride as default value; when ``shape``
        is specified, it will use the default stride corresponding to the specified ``shape``.
    offset (int, optional): Define the target offset from x's holder. Default: 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, the Tensor with the same data type as ``x``.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> src = paddle.to_tensor([[11., 22., 33.]])
        >>> src2 = paddle.to_tensor([11., 22., 33., 44., 55., 66.])

        >>> x = paddle.to_tensor([1., 2., 3., 4., 5.])
        >>> x.set_()
        >>> print(x)
        Tensor(shape=[0], dtype=float32, place=Place(cpu), stop_gradient=True,
        [])

        >>> x = paddle.to_tensor([1., 2., 3., 4., 5.])
        >>> x.set_(src)
        >>> print(x)
        Tensor(shape=[1, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[11., 22., 33.]])

        >>> print(x._is_shared_buffer_with(src))
        True

        >>> x = paddle.to_tensor([1., 2., 3., 4., 5.])
        >>> x.set_(src, shape=[2, 1])
        >>> print(x)
        Tensor(shape=[2, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[11.],
         [22.]])

        >>> x = paddle.to_tensor([1., 2., 3., 4., 5.])
        >>> x.set_(src2, shape=[3], stride=[2])
        >>> print(x)
        Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [11., 33., 55.])

        >>> x = paddle.to_tensor([1., 2., 3., 4., 5.])
        >>> x.set_(src2, shape=[5], offset=4)
        >>> print(x)
        Tensor(shape=[5], dtype=float32, place=Place(cpu), stop_gradient=True,
        [22., 33., 44., 55., 66.])

z(InvalidArgument) Leaf Tensor z7 that doesn't stop gradient can't use inplace strategy.Nr   r8   z4Input (source) should be paddle.Tensor but received sourcer@   rD   rL   rE   rF   rG   rH   rI   rJ   rK   r   r   set)r   is_leafrO   r   rN   r3   r  r9   r   r   r   r   r   rf   r   stridesr?   r   set_)r  r  r?   strider{  rN   s         r:   r  r  >  s   T  99Q__0 9$ $  >\\1#QWW5FCESFfx1B1B&CDD J4PV<.Y   #& >}e,44=LLE{{1eV<<[ r<   c                    [        5       (       a  [        U R                  S/ SQS5        [        U[        [
        45      (       d  [        S[        U5       35      e[        R                  " U5      n[        R                  " U R                  5      nXE:  ag  U(       a`  U* U-  * nU R                  5       n[        R                  " U4[        R                  " U5      4US-
  -  -   5      SU nU R                  X5      $ U R                  X5      $ g)a&  
Resize ``x`` with specified ``shape``.

Args:
    x (Tensor): An arbitrary Tensor. The data type supports ``bfloat16``, ``float16``, ``float32``, ``float64``,
        ``bool``, ``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``complex64`` or ``complex128``.
    shape (list|tuple): Define the target shape. Each element of it should be integer.
    fill_zero (bool, optional): If the size of specified ``shape`` is greater than the original Tensor size, the
        new Tensor will be filled with zero if ``fill_zero`` is True. Default: False, which means the filled value
        will be undetermined.
    name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Tensor, the resized Tensor.

Examples:
    .. code-block:: python

        >>> import paddle

        >>> x = paddle.to_tensor([1., 2., 3.])
        >>> x.resize_([2, 1])
        >>> print(x)
        Tensor(shape=[2, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[1.],
         [2.]])

        >>> x = paddle.to_tensor([1., 2., 3.])
        >>> x.resize_([2, 3], fill_zero=True)
        >>> print(x)
        Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[1., 2., 3.],
         [0., 0., 0.]])

r  r  resizez3Input (shape) should be list or tuple but received rw   N)r   r   r9   r   rT   rU   r   rf   rG  prodr?   r  r3   concatr2  r  )	r  r?   	fill_zerorN   new_sizeold_sizerepeats	flatten_xtmps	            r:   resize_r    s    T GG #	
& %$//Ed5k]S  99U#99QWW%Y!	X-.G		I-- 1 1) <>'A+NNxC 66#%%vvaE r<   c                "   ^   " U 4S jS5      nU$ )Nc                  "   > \ rS rSrU 4S jrSrg)1dtype_tensor_factory.<locals>._DtypeTensorFactoryi  c                  > [        U5      S:X  a  [        R                  " S/TS9$ [        U5      S:X  a6  [        US   [        [
        45      (       a  [        R                  " US   TS9$ [        S U 5       5      (       a  [        R                  " [	        U5      TS9$ UR                  ST5        [        R                  " U0 UD6$ )Nr   )r?   r9   rw   r8   c              3  B   #    U  H  n[        U[        5      v   M     g 7fr,   )r   rX   )r  args     r:   r  Ldtype_tensor_factory.<locals>._DtypeTensorFactory.__new__.<locals>.<genexpr>  s     :TcZS))Ts   r9   )
r   r3   r  r   rT   rU   r   r  
setdefaultr   )clsra  rW  r9   s      r:   __new__9dtype_tensor_factory.<locals>._DtypeTensorFactory.__new__	  s    4yA~||1#U;;TaJtAwu$F$F}}T!WE:::T:::||$t*EBB!!'51}}d5f55r<   r  N)r  r  r  r  r  r	  r8   s   r:   _DtypeTensorFactoryr    s    		6 		6r<   r  r  )r9   r  s   ` r:   dtype_tensor_factoryr    s    
6 
6 r<   rE   rF   rD   r   rK   rG   rH   rI   )r9   r$   r   r$   )FFN)r?   r)   rP   r^   r9   r$   rM   r@   rQ   r@   rN   
str | Noner   r   )NNFN)r?   r)   r9   r$   rN   r  rd   zParamAttrLike | Nonerh   r@   re   z(paddle.nn.initializer.Initializer | Noner   r   )NF)r9   r$   rN   r  rM   r@   r   r   )NN)rz   float | paddle.Tensorrm   r  ro   int | paddle.Tensorr9   r  rN   r  rq   paddle.Tensor | Nonerr   PlaceLike | Noners   r@   r   r   )g      $@NN)rz   r  rm   r  ro   r  r   r  r9   r  rN   r  r   r   )NNT)
r   r*   r9   r  r   r  rO   r@   r   r   )NT)r   r*   r9   r  rO   r@   r   r   )NNFF)r   "TensorLike | NestedNumericSequencer9   r  rr   r  rs   r@   r   r@   r   r   )
r   r  r9   r  r   r  rO   r@   r   r   )rW   zNDArray[Any]r   r   )
r   r  r9   r  rr   r  r   zbool | Noners   r@   )r  r   r  Numeric | strr9   r  rN   r  rr   r  rs   r@   r   r@   r   r   )FNNN)r?   r)   r9   r$   rP   zbool | float | paddle.TensorrQ   r@   rq   r  r   r  rN   r  r   r   )r?   r)   r9   r  rN   r  rq   r  rr   r  rs   r@   r   r@   r   r   )r  r   r9   r  rN   r  rr   r  rs   r@   r   r@   r   r   )NNN)r3  r  r5  zint | paddle.Tensor | Noner9   r  rN   r  rq   r  rr   r  rs   r@   r   r@   r   r   )r?   r)   r  r  r9   r  rN   r  rq   r  rr   r  rs   r@   r   r@   r   r   )r   Nrw   N)rz   r  rn   float | paddle.Tensor | Noner   r  r9   r  rq   r  rr   r  rs   r@   r   r@   rN   r  r   r   )rz   r  rn   r  r   r  r9   r$   rq   r  rr   r  rs   r@   rN   r  )r`   r   r   r   )r   N)r  r   rS  rX   rN   r  r   r  )ra  zSequence[paddle.Tensor]rN   r  rb  r  r   list[paddle.Tensor])ra  r   rN   r  rb  r  r   r  )r   )r   r   rt  z	list[int]ru  rX   r   r  )r   r  )
r  r*   r{  rX   r|  rX   r}  rX   r   r   )r  r   r{  rX   rN   r  r   r   )r   r   N)
r  r   r{  rX   r  rX   rN   r  r   r   r,   )r  r*   r   r  r   r   )r  r   rN   r  r   r   )r   r   )
r  r   r  r   rN   r  rq   r  r   r   )r   rJ   )r  rX   r  rX   r{  rX   r   r   )Nr   rJ   )r  rX   r  z
int | Noner{  rX   r   r   )
r  r   r  r   rN   r  rq   r  r   r   )r   rw   N)
r  r   r  r&   r  r&   rN   r  r   r   )r  r   r  r  rN   r  r   r   )NNNr   N)r  r   r  r  r?   Sequence[int] | Noner  r  r{  rX   rN   r  r   r   )FN)
r  r   r?   zSequence[int]r  r@   rN   r  r   r   )w
__future__r   r?  rG  r  r   r   typingr   r   r   rV   r3   r   paddle._C_opsr   r   paddle.utilsr	   paddle.utils.decorator_utilsr
   r   r   r   paddle.utils.inplace_utilsr   base.data_feederr   r   r   r   base.frameworkr   r   base.param_attrr   r   r   r   r   r   r   r   r   r   r   r    collections.abcr!   r"   numpy.typingr#   paddle._typingr$   r%   r&   r'   r(   r)   r*   __all__r   r;   r>   rB   rc   rj   ru   r   r   r   r   r   r   r   r   r   r  r   r+  r.  r0  r2  r=  r   rI  rB  rY  r[  r_  rc  rx  r  r  r  r  r  r   r  r  r@  r  r  r  r  r  r  r  r  FloatTensorDoubleTensor
HalfTensorBFloat16Tensor
ByteTensor
CharTensorShortTensor	IntTensor
LongTensor
BoolTensorr  r<   r:   <module>r2     s   #    	  *    $ #  D  4 '   ($    

" SSS S 	S
 S S Sr !%DHTTT T 	T
 T BT Tp DI))&)<@))X &%5'"23
 #[ !%#[ [
[ 
[ 	[
 [ 
[ [ [ [ 4[D #'"@ @
@ 
@  	@
 @ @ @J #"	F

F
F
 F
 	F

 F
V #F
FF F 	FV ##w
,ww w 	w
 w wx #"	Q
,QQ Q 	Q
 QhH ##Q	+Q Q 	Q
 Q Qh3&++"".. 3l #w  #	J  $JJJ J 	J J J J J !Jb  $"rrr (r 	r
 
r r r rj  #C
 !%#CCC C
 
C C C C C CL cG9%& #9
  $999 9
 9 9 9 9 '9x  #L
 !%#LLL L
 
L L L L L L^ cG9%& #:
  $::: :
 : : : : ':z *c"]C$89 /3"	P !%#P!P+P P 	P 
P P P P P :Pf gx() #	F !%#FFF F 	F 
F F F F F *FT $%(,"#"	\ !%#\ \	%\  \ 	\ 
\ \ \ \ \ \~ 	L  $%(,"#	Q !%#Q Q	%Q  Q 	Q 
Q Q Q QQh.b <@	)	) #	)/9	)	) 	) <@	)	) #	)/9	)	) 	) 
 
!
  	 
 
-1$ *=G 

Xx =>/
/&//69//f EGtt"t.1t>Attp ;?EE!E-7EET 	www w 	w
 wt  #y
 !%#yyy y
 
y y y y y yx cG9%& #W
  $WWW W
 W W W W 'WtOd HSr 8
 !%8
8
8 8
 
8 8x 07R	RR #RRl >EO	OO.1OOj ,
 !%,	,, ,
 
, ,^  	##	# # 	#
 # #L  "" " " 	" "J  $("&#'v=v= v=  v= !	v=
 v= v= v= v=r  	K K K  K  	K 
 K  K \  #9-#I.!),
%j1!'*
!&)
"7+ )	!'*
!&)
r<   