
    |jk                    "   d dl mZ d dlmZmZ d dlmZ d dlZd dlmZ d dl	m
Z
mZmZmZmZmZ d dlmZ d dlmZ d d	lmZmZmZ d d
lmZ ddlmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z# erd dlm$Z$ g Z%	 	 	 dPdQdZ&edRdSd            Z'edRdSd            Z(edRdSd             Z)edRdTd!            Z*dRdTd"Z+dRdSd#Z,	 	 	 	 dUdVd+Z- edd,gdd-g          	 dRdd.dWd/            Z.edRdSd0            Z/ edd,gdd-g          	 dRdd.dWd1            Z0 edd,gdd-g          	 dRdd.dWd2            Z1edRdSd3            Z2edRdSd4            Z3 edd,gdd-g          	 dRdd.dWd5            Z4edRdSd6            Z5 edd,gdd-g          	 dRdd.dWd7            Z6edRdSd8            Z7edRdSd9            Z8 edd,gdd-g          	 dRdd.dWd:            Z9edRdSd;            Z: edd<g          dXd?            Z;	 	 	 dPdQd@Z<	 dYdZdAZ=d[dCZ>edRdSdD            Z? edd,gdd-g          	 dYdZdE            Z@	 	 dYd\dFZAe ed,gd-gdG          dRdSdH                        ZB	 dYdZdIZC	 	 dYd\dJZDedRdSdK            ZE	 dYd]dLZFedRdTdM            ZG	 dYd]dNZHedRdTdO            ZIdS )^    )annotations)TYPE_CHECKINGAny)	TypeGuardN)_C_ops)greater_thaniscloselogical_andlogical_not
logical_orlogical_xor)full)broadcast_shape)ParamAliasDecoratorparam_one_aliasparam_two_alias)inplace_apis_in_dygraph_only   )
check_typecheck_variable_and_dtype)Variable)LayerHelperin_dynamic_modein_dynamic_or_pir_modein_pir_mode)TensorTop_namestrxr   yTensor | Noneoutname
str | None	binary_opboolreturnc                   t                      r.t          t          |           }|r |||          S  ||          S t          |dg d|            |t          |dg d|            |t	          |dt
          |            t          | fi t                      }||                    |j	                  }|r|
                    | ||dd|i           n|
                    | d	|id|i           |S )
Nr   )r&   int8int16int32int64float16float32float64uint16	complex64
complex128r    r"   dtypeXYOuttypeinputsoutputsr6   )r   getattrr   r   r   r   r   locals"create_variable_for_type_inferencer4   	append_opr   r   r    r"   r#   r%   ophelpers           c/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/paddle/tensor/logic.py_logical_oprE   7   sg     =VW%% 	2a88O2a55L    !	
 	
 	
$ =$   !  $ ?sE8W555W1111;;;!';JJC 	11%5%5s|      c1Xs|     
    c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``logical_and`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_and`.
    The shape of broadcast output * is different from that of inplace tensor  in the Inplace operation.N)r   shape
ValueErrorr   r   logical_and_r   r    r#   	out_shapes       rD   rM   rM            11IAG FY  F  Fbcbi  F  F  F
 
 	
  )"1a((() )rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``logical_or`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_or`.
    rH   rI   rJ   N)r   rK   rL   r   r   logical_or_rN   s       rD   rR   rR            11IAG FY  F  Fbcbi  F  F  F
 
 	
  (!!Q'''( (rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``logical_xor`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_xor`.
    rH   rI   rJ   N)r   rK   rL   r   r   logical_xor_rN   s       rD   rU   rU      rP   rF   c                J    t                      rt          j        |           S dS )z
    Inplace version of ``logical_not`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_not`.
    N)r   r   logical_not_r   r#   s     rD   rW   rW      -      &"1%%%& &rF   c                   t                      rt          j        |           S t          | dg dd           t	          |dt
          t          d          fd           t                      rt          j        |           S t          di t                      }|
                    d          }d|_        |                    dd	| gid
|gi           |S )a  

    Test whether a Tensor is empty.

    Args:
        x (Tensor): The Tensor to be tested.
        name (str|None, optional): The default value is ``None`` . Normally users don't have to set this parameter. For more information, please refer to :ref:`api_guide_Name` .

    Returns:
        Tensor: A bool scalar Tensor. True if 'x' is an empty Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> input = paddle.rand(shape=[4, 32, 32], dtype='float32')
            >>> res = paddle.is_empty(x=input)
            >>> print(res)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            False)

    r   )r.   r/   r+   r,   is_emptyr#   Nr&   r3   Tr6   r8   r9   )r[   )r   r   r[   r   r   r   r:   r   r   r>   r?   stop_gradientr@   )r   r#   rC   conds       rD   r[   r[      s    0  "q!!!	3888*   tVc4::.
;;;}} 	q!!!446884488v8FF!S1#J 	 	
 	
 	
 rF   c                    t                      rt          j        | |          S t          di t	                      }|                    d          }|                    d| g|gdd|gi           |S )	a  
    Returns the truth value of :math:`x == y`. True if two inputs have the same elements, False otherwise.

    Note:
        The output has no gradient.

    Args:
        x(Tensor): Tensor, data type is bool, float32, float64, int32, int64.
        y(Tensor): Tensor, data type is bool, float32, float64, int32, int64.
        name(str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: output Tensor, data type is bool, value is [False] or [True].

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 2, 3])
            >>> z = paddle.to_tensor([1, 4, 3])
            >>> result1 = paddle.equal_all(x, y)
            >>> print(result1)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            True)
            >>> result2 = paddle.equal_all(x, z)
            >>> print(result2)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            False)
    	equal_allr&   r3   r5   r8   r9   N)r_   )r   r   r_   r   r>   r?   r@   )r   r    r#   rC   r"   s        rD   r_   r_      s    B  
1%%%55FHH5577f7EEA3''SEN 	 	
 	
 	

 
rF   h㈵>:0yE>Frtolfloatatol	equal_nanc                   t                      rt          j        | ||||          S t                      rt	          | dg dd           t	          |dg dd           t          |t          t          j        j	        f          st          dt          |                     t          |t          t          j        j	        f          st          dt          |                     t          |dt          d           t          j        | ||||          S t	          | dg dd           t	          |dg dd           t          |dt          d           t          |dt          d           t          |dt          d           t          di t                      }|                    d	
          }| |d}d|i}	t#          |          t#          |          |d}
|                    d||	|
           |S )a  
    Check if all :math:`x` and :math:`y` satisfy the condition:

    .. math::
        \left| x - y \right| \leq atol + rtol \times \left| y \right|

    elementwise, for all elements of :math:`x` and :math:`y`. This is analogous to :math:`numpy.allclose`, namely that it returns :math:`True` if
    two tensors are elementwise equal within a tolerance.

    Args:
        x (Tensor): The input tensor, it's data type should be float16, float32, float64.
        y (Tensor): The input tensor, it's data type should be float16, float32, float64.
        rtol (float, optional): The relative tolerance. Default: :math:`1e-5` .
        atol (float, optional): The absolute tolerance. Default: :math:`1e-8` .
        equal_nan (bool, optional): ${equal_nan_comment}. Default: False.
        name (str|None, optional): Name for the operation. For more information, please
            refer to :ref:`api_guide_Name`. Default: None.

    Returns:
        Tensor: The output tensor, it's data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([10000., 1e-07])
            >>> y = paddle.to_tensor([10000.1, 1e-08])
            >>> result1 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name="ignore_nan")
            >>> print(result1)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            False)
            >>> result2 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=True, name="equal_nan")
            >>> print(result2)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            False)
            >>> x = paddle.to_tensor([1.0, float('nan')])
            >>> y = paddle.to_tensor([1.0, float('nan')])
            >>> result1 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=False, name="ignore_nan")
            >>> print(result1)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            False)
            >>> result2 = paddle.allclose(x, y, rtol=1e-05, atol=1e-08, equal_nan=True, name="equal_nan")
            >>> print(result2)
            Tensor(shape=[], dtype=bool, place=Place(cpu), stop_gradient=True,
            True)
    input)r&   r+   r,   r-   r.   r/   allclosez4Type of input rtol must be float, but received type z4Type of input atol must be float, but received type re   rb   rd   r&   r3   )InputOtherr8   )rb   rd   re   )r:   r;   r<   attrsN)rh   )r   r   rh   r   r   
isinstancerc   paddlepirValue	TypeErrorr:   r   r&   r   r>   r?   r   r@   )r   r    rb   rd   re   r#   rC   r"   r;   r<   rk   s              rD   rh   rh     sD   p  4q!T4;;;	 2 GGG		
 	
 	
 	!GGG		
 	
 	
 $
(8 9:: 	StDzzSS   $
(8 9:: 	StDzzSS   	9k4<<<q!T4;;; GGG		
 	
 	
 	!GGG		
 	
 	
 	4
3334
3339k4<<<446884477f7EEq))#,TCIIINNFG5 	 	
 	
 	
 
rF   rg   otherr"   c          	        t          |t          t          t          t          t
          t          j        j        f          st          dt          |                     t          |t          t          j        j        t
          f          st          g | j        |          }t          |t
                    rt          j        |          }t                      rt          j        | ||          S t#          | dg dd           t#          |dg dd           t%          di t'                      }|                    d	          }d
|_        |                    d| g|gdd|gi           |S )a   

    This layer returns the truth value of :math:`x == y` elementwise.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): Tensor, data type is bool, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            alias: ``input``
        y (Tensor): Tensor, data type is bool, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            alias: ``other``
        name (str|None, optional): The default value is None. Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): Output tensor. If provided, the result will be stored in this tensor.

    Returns:
        Tensor: output Tensor, it's shape is the same as the input's Tensor,
        and the data type is bool. The result of this op is stop_gradient.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.equal(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , False, False])
    zRType of input args must be float, bool, complex, int or Tensor, but received type )rK   r4   
fill_valuerr   r   r&   r-   r.   r/   uint8r)   r*   r+   r,   r0   r1   r2   equalr    r&   r3   Tr5   r8   r9   N)rw   )rl   intr&   rc   r   complexrm   rn   ro   rp   r:   r   r4   	to_tensorr   r   rw   r   r   r>   r?   r\   r@   r   r    r#   r"   rC   s        rD   rw   rw   ~  s   H 	Cuh1AB  
 jaefgahahjj
 
 	
 a(FJ$4g>?? 8rQ777!W  Q 1|Aqc****    #	
 	
 	
& 	!   #	
 	
 	
& 111177f7EE A3''SEN 	 	
 	
 	

 
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_equal`.
    rH   rI   rJ   N)r   rK   rL   r   r   equal_rN   s       rD   r}   r}     s      11IAG FY  F  Fbcbi  F  F  F
 
 	
  #}Q"""# #rF   c               j    t                      rt          j        | ||          S t          d          )av  
    Returns the truth value of :math:`x > y` elementwise, which is equivalent function to the overloaded operator `>`.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): First input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``input``.
        y (Tensor): Second input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``other``.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): The output tensor. If provided, the result will be stored in this tensor.

    Returns:
        Tensor: The output shape is same as input :attr:`x`. The output data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.gt(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [False, False, True ])
    rr   z.paddle.gt does not support legacy static mode.)r   r   r   NotImplementedError)r   r    r#   r"   s       rD   gtr     s@    D  
"1aS1111!<
 
 	
rF   c               J   t                      rt          j        | ||          S t          | dg dd           t          |dg dd           t	          di t                      }|                    d          }d|_        |                    d| g|gd	d
|gi           |S )a  
    Returns the truth value of :math:`x >= y` elementwise, which is equivalent function to the overloaded operator `>=`.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): First input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``input``.
        y (Tensor): Second input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``other``.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.
    Returns:
        Tensor: The output shape is same as input :attr:`x`. The output data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.greater_equal(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , False, True ])
    rr   r   ru   greater_equalr    r&   r3   Tr5   r8   r9   N)r   )	r   r   r   r   r   r>   r?   r\   r@   r{   s        rD   r   r     s    B  1#Aqc2222    #	
 	
 	
& 	!   #	
 	
 	
& 999977f7EE  A3''SEN 	 	
 	
 	

 
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``greater_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_greater_equal`.
    rH   rI   rJ   N)r   rK   rL   r   r   greater_equal_rN   s       rD   r   r   t  s      11IAG FY  F  Fbcbi  F  F  F
 
 	
  +$Q***+ +rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``greater_than`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_greater_than`.
    rH   rI   rJ   N)r   rK   rL   r   r   greater_than_rN   s       rD   r   r     s      11IAG FY  F  Fbcbi  F  F  F
 
 	
  *#Aq)))* *rF   c               J   t                      rt          j        | ||          S t          | dg dd           t          |dg dd           t	          di t                      }|                    d          }d|_        |                    d| g|gd	d
|gi           |S )a  
    Returns the truth value of :math:`x <= y` elementwise, which is equivalent function to the overloaded operator `<=`.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): First input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``input``.
        y (Tensor): Second input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``other``.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.

    Returns:
        Tensor: The output shape is same as input :attr:`x`. The output data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.less_equal(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , True , False])
    rr   r   ru   
less_equalr    r&   r3   Tr5   r8   r9   N)r   )	r   r   r   r   r   r>   r?   r\   r@   r{   s        rD   r   r     s    D  1 A3////    #	
 	
 	
& 	!   #	
 	
 	
& 66VXX6677f7EE A3''SEN 	 	
 	
 	

 
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``less_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_less_equal`.
    rH   rI   rJ   N)r   rK   rL   r   r   less_equal_rN   s       rD   r   r     rS   rF   c               J   t                      rt          j        | ||          S t          | dg dd           t          |dg dd           t	          di t                      }|                    d          }d|_        |                    d| g|gd	d
|gi           |S )a  
    Returns the truth value of :math:`x < y` elementwise, which is equivalent function to the overloaded operator `<`.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): First input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``input``
        y (Tensor): Second input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``other``
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.

    Returns:
        Tensor: The output shape is same as input :attr:`x`. The output data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.less_than(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [False, True , False])
    rr   r   ru   	less_thanr    r&   r3   Tr5   r8   r9   N)r   )	r   r   r   r   r   r>   r?   r\   r@   r{   s        rD   r   r         D  21#....    #	
 	
 	
& 	!   #	
 	
 	
& 55FHH5577f7EE A3''SEN 	 	
 	
 	

 
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``less_than`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_less_than`.
    rH   rI   rJ   N)r   rK   rL   r   r   
less_than_rN   s       rD   r   r   N        11IAG FY  F  Fbcbi  F  F  F
 
 	
  ' A&&&' 'rF   c                $    t          | ||          S )z
    Inplace version of ``less_`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_less`.
    )r   )r   r    r#   s      rD   less_r   ]  s     aD!!!rF   c               J   t                      rt          j        | ||          S t          | dg dd           t          |dg dd           t	          di t                      }|                    d          }d|_        |                    d| g|gd	d
|gi           |S )a  
    Returns the truth value of :math:`x != y` elementwise, which is equivalent function to the overloaded operator `!=`.

    Note:
        The output has no gradient.

    Args:
        x (Tensor): First input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``input``.
        y (Tensor): Second input to compare which is N-D tensor. The input data type should be bool, bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128.
            Alias: ``other``.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
        out (Tensor, optional): The output tensor. If set, the result will be stored in this tensor. Default is None.

    Returns:
        Tensor: The output shape is same as input :attr:`x`. The output data type is bool.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> x = paddle.to_tensor([1, 2, 3])
            >>> y = paddle.to_tensor([1, 3, 2])
            >>> result1 = paddle.not_equal(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [False, True , True ])
    rr   r   ru   	not_equalr    r&   r3   Tr5   r8   r9   N)r   )	r   r   r   r   r   r>   r?   r\   r@   r{   s        rD   r   r   h  r   rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``not_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_not_equal`.
    rH   rI   rJ   N)r   rK   rL   r   r   
not_equal_rN   s       rD   r   r     r   rF   objr   TypeGuard[Tensor]c                    t                      r+t          | t          j        t          j        j        f          S t          | t                    S )a	  

    Tests whether input object is a paddle.Tensor.

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

    Args:
        x (object): Object to test. alias: ``obj``.

    Returns:
        A boolean value. True if ``x`` is a paddle.Tensor, otherwise False.

    Examples:
        .. code-block:: python

            >>> import paddle

            >>> input1 = paddle.rand(shape=[2, 3, 5], dtype='float32')
            >>> check = paddle.is_tensor(input1)
            >>> print(check)
            True

            >>> input3 = [1, 4]
            >>> check = paddle.is_tensor(input3)
            >>> print(check)
            False

    )r   rl   rm   r   rn   ro   r   )r   s    rD   	is_tensorr     s?    @  '!fmVZ-=>???!X&&&rF   c                   t                      r.t          t          |           }|r |||          S  ||          S t          |dg d|            |t          |dg d|            |t	          |dt
          |            t          | fi t                      }|r|j        |j        k    sJ ||	                    |j                  }|r|
                    | ||dd|i           n|
                    | d	|id|i           |S )
Nr   )r&   rv   r)   r*   r+   r,   r    r"   r3   r5   r8   r9   r6   )r   r=   r   r   r   r   r   r>   r4   r?   r@   rA   s           rD   _bitwise_opr     st     'VW%% 	2a88O2a55L @@@		
 	
 	
 =$DDD	   ?sE8W555W1111 	&7ag%%%%;;;!';JJC 	11%5%5s|      c1Xs|     
rF   c                v    t                      r|t          j        | |          S t          d| |||d          S )a  

    Apply ``bitwise_and`` on Tensor ``X`` and ``Y`` .

    .. math::
        Out = X \& Y

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

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

    Args:
        x (Tensor): Input Tensor of ``bitwise_and`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        y (Tensor): Input Tensor of ``bitwise_and`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        out (Tensor|None, optional): Result of ``bitwise_and`` . It is a N-D Tensor with the same data type of input Tensor. Default: None.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: Result of ``bitwise_and`` . It is a N-D Tensor with the same data type of input Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([-5, -1, 1])
            >>> y = paddle.to_tensor([4,  2, -3])
            >>> res = paddle.bitwise_and(x, y)
            >>> print(res)
            Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
            [0, 2, 1])
    Nbitwise_andTr   r   r    r#   r"   r%   )r   r   r   r   r   r    r"   r#   s       rD   r   r   &  N    H  (CK!!Q'''adt   rF   
int | boolc                    t          |t          t          f          r-t          j        || j                  }t          || d d           S t          dt          |          j	         d          )Nr3   $unsupported operand type(s) for |: '' and 'Tensor')
rl   rx   r&   rm   rz   r4   r   rp   r:   __name__)r   r    y_tensors      rD   __rand__r   Q  sl    !c4[!! 
#AQW5558Qd333S4773CSSS
 
 	
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``bitwise_and`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_and`.
    rH   rI   rJ   N)r   rK   rL   r   r   bitwise_and_rN   s       rD   r   r   [  s      11IAG FY  F  Fbcbi  F  F  F
 
 	
  )"1a((() )rF   c                v    t                      r|t          j        | |          S t          d| |||d          S )a  

    Apply ``bitwise_or`` on Tensor ``X`` and ``Y`` .

    .. math::
        Out = X | Y

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

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

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

    Args:
        x (Tensor): Input Tensor of ``bitwise_or`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
            alias: ``input``.
        y (Tensor): Input Tensor of ``bitwise_or`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
            alias: ``oth``.
        out (Tensor|None, optional): Result of ``bitwise_or`` . It is a N-D Tensor with the same data type of input Tensor. Default: None.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: Result of ``bitwise_or`` . It is a N-D Tensor with the same data type of input Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([-5, -1, 1])
            >>> y = paddle.to_tensor([4,  2, -3])
            >>> res = paddle.bitwise_or(x, y)
            >>> print(res)
            Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
            [-1, -1, -3])
    N
bitwise_orTr   )r   r   r   r   r   s       rD   r   r   j  sN    V  'CK A&&&QTsd   rF   c                    t          |t          t          f          r.t          j        || j                  }t          || ||          S t          dt          |          j	         d          Nr3   r"   r#   r   r   )
rl   rx   r&   rm   rz   r4   r   rp   r:   r   r   s       rD   __ror__r     sq     !c4[!! 
Qag...!QCd3333S4773CSSS
 
 	
rF   )r   r    c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``bitwise_or`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_or`.
    rH   rI   rJ   N)r   rK   rL   r   r   bitwise_or_rN   s       rD   r   r     s      11IAG FY  F  Fbcbi  F  F  F
 
 	
  (!!Q'''( (rF   c                v    t                      r|t          j        | |          S t          d| |||d          S )a  

    Apply ``bitwise_xor`` on Tensor ``X`` and ``Y`` .

    .. math::
        Out = X ^\wedge Y

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

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

    Args:
        x (Tensor): Input Tensor of ``bitwise_xor`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        y (Tensor): Input Tensor of ``bitwise_xor`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        out (Tensor|None, optional): Result of ``bitwise_xor`` . It is a N-D Tensor with the same data type of input Tensor. Default: None.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: Result of ``bitwise_xor`` . It is a N-D Tensor with the same data type of input Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([-5, -1, 1])
            >>> y = paddle.to_tensor([4,  2, -3])
            >>> res = paddle.bitwise_xor(x, y)
            >>> print(res)
            Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
            [-1, -3, -4])
    Nbitwise_xorTr   )r   r   r   r   r   s       rD   r   r     r   rF   c                    t          |t          t          f          r.t          j        || j                  }t          || ||          S t          dt          |          j	         d          r   )
rl   rx   r&   rm   rz   r4   r   rp   r:   r   r   s       rD   __rxor__r     sq     !c4[!! 
Qag...1aSt4444S4773CSSS
 
 	
rF   c                    t          | j        |j                  }|| j        k    rt          d| d| j         d          t                      rt	          j        | |          S dS )z
    Inplace version of ``bitwise_xor`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_xor`.
    rH   rI   rJ   N)r   rK   rL   r   r   bitwise_xor_rN   s       rD   r   r     rP   rF   c                t    t                      r|t          j        |           S t          d| d||d          S )a  

    Apply ``bitwise_not`` on Tensor ``X``.

    .. math::
        Out = \sim X

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

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

    Args:
        x (Tensor): Input Tensor of ``bitwise_not`` . It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        out (Tensor|None, optional): Result of ``bitwise_not`` . It is a N-D Tensor with the same data type of input Tensor. Default: None.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: Result of ``bitwise_not`` . It is a N-D Tensor with the same data type of input Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([-5, -1, 1])
            >>> res = paddle.bitwise_not(x)
            >>> print(res)
            Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
            [ 4,  0, -2])
    Nbitwise_notFr   )r   r   r   r   r   r"   r#   s      rD   r   r     sL    D  %CK!!$$$d3%   rF   c                J    t                      rt          j        |           S dS )z
    Inplace version of ``bitwise_not`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_not`.
    N)r   r   bitwise_not_rX   s     rD   r   r   /  rY   rF   c                &    t          | ||          S )a~  
    Apply ``bitwise_not`` (bitwise inversion) on Tensor ``x``.

    This is an alias to the ``paddle.bitwise_not`` function.

    .. math::
        Out = \sim X

    Note:
        ``paddle.bitwise_invert`` is functionally equivalent to ``paddle.bitwise_not``.

    Args:
        x (Tensor): Input Tensor of ``bitwise_invert``. It is a N-D Tensor of bool, uint8, int8, int16, int32, int64.
        out (Tensor|None, optional): Result of ``bitwise_invert``. It is a N-D Tensor with the same data type as the input Tensor. Default: None.
        name (str|None, optional): The default value is None. This property is typically not set by the user.
            For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: Result of ``bitwise_invert``. It is a N-D Tensor with the same data type as the input Tensor.

    Examples:
        .. code-block:: python

            >>> import paddle
            >>> x = paddle.to_tensor([-5, -1, 1])
            >>> res = x.bitwise_invert()
            >>> print(res)
            Tensor(shape=[3], dtype=int64, place=Place(cpu), stop_gradient=True,
            [ 4,  0, -2])

    r   )r   r   s      rD   bitwise_invertr   9  s    F qc----rF   c                $    t          | |          S )z
    Inplace version of ``bitwise_invert`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_invert_`.
    )r#   )r   rX   s     rD   bitwise_invert_r   _  s     %%%%rF   )NNT)r   r   r   r   r    r!   r"   r!   r#   r$   r%   r&   r'   r   )N)r   r   r    r   r#   r$   r'   r   )r   r   r#   r$   r'   r   )r`   ra   FN)r   r   r    r   rb   rc   rd   rc   re   r&   r#   r$   r'   r   )
r   r   r    r   r#   r$   r"   r!   r'   r   )r   r   r'   r   )NN)
r   r   r    r   r"   r!   r#   r$   r'   r   )r   r   r    r   )
r   r   r    r   r"   r!   r#   r$   r'   r   )r   r   r"   r!   r#   r$   r'   r   )J
__future__r   typingr   r   typing_extensionsr   rm   r   paddle._C_opsr   r	   r
   r   r   r   paddle.tensor.creationr   paddle.tensor.mathr   paddle.utils.decorator_utilsr   r   r   paddle.utils.inplace_utilsr   base.data_feederr   r   common_ops_importr   	frameworkr   r   r   r   r   __all__rE   rM   rR   rU   rW   r[   r_   rh   rw   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    rF   rD   <module>r      s	   # " " " " " % % % % % % % % ' ' ' ' ' '                       ( ' ' ' ' ' . . . . . .         
 D C C C C C C C C C C C C C ( ( ( ( ( (             
 E E E E EP ) ) ) ) ) ( ( ( ( ( ) ) ) ) ) & & & & &( ( ( ( (V+ + + + +b l l l l l^ #w#w00-1aKOa a a a a 10aH # # # # #" #w#w00-1&
KO&
 &
 &
 &
 &
 10&
R #w#w00-1QKOQ Q Q Q Q 10Qh + + + + + * * * * * #w#w00-1RKOR R R R R 10Rj ( ( ( ( ( #w#w00-1SKOS S S S S 10Sl ' ' ' ' ' " " " " " #w#w00-1SKOS S S S S 10Sl ' ' ' ' ' #u"' "' "' "'R / / / / /f IM( ( ( ( (V
 
 
 
 ) ) ) ) ) #w#w00HL/ / / / 10/j 	
 
 
 
 
 G9G95566( ( ( ( 76 ( IM( ( ( ( (\ 	
 
 
 
 
 ) ) ) ) ) >B' ' ' ' 'T & & & & & >B#. #. #. #. #.L & & & & & & &rF   