o
    + i2                     @  s<  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 d dl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 ddlmZ ddlmZmZm Z m!Z! erhd dlm"Z" g Z#			dudvddZ$edwdxdd Z%edwdxd!d"Z&edwdxd#d$Z'edwdyd%d&Z(dwdyd'd(Z)dwdxd)d*Z*	+	,	-	dzd{d2d3Z+edd4gdd5g	dwdd6d|d7d8Z,edwdxd9d:Z-dwdxd;d<Z.edwdxd=d>Z/edwdxd?d@Z0dwdxdAdBZ1edwdxdCdDZ2dwdxdEdFZ3edwdxdGdHZ4dwdxdIdJZ5edwdxdKdLZ6dwdxdMdNZ7edwdxdOdPZ8d}dSdTZ9			dudvdUdVZ:	d~ddWdXZ;ddZd[Z<edwdxd\d]Z=edd4gdd5g	d~dd^d_Z>		d~dd`daZ?eed4gd5gdbdwdxdcddZ@	d~ddedfZA		d~ddgdhZBedwdxdidjZC	d~ddkdlZDedwdydmdnZE	d~ddodpZFedwdydqdrZG	+	,	-	dzd{dsdtZHdS )    )annotations)TYPE_CHECKINGAny)	TypeGuardN)_C_ops)greater_thanlogical_andlogical_not
logical_orlogical_xor)full)broadcast_shape)ParamAliasDecorator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                 C  s   t  rtt| }|r|||S ||S t|dg d|  |d ur)t|dg d|  |d ur4t|dt|  t| fi t }|d u rH|j|j	d}|rY|j
| ||dd|id |S |j
| d	|id|id |S )
Nr   )r#   int8int16int32int64float16float32float64uint16	complex64
complex128r   r   dtypeXYOuttypeinputsoutputsr2   )r   getattrr   r   r   r   r   locals"create_variable_for_type_inferencer0   	append_opr   r   r   r   r    r"   ophelper r@   _/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/paddle/tensor/logic.py_logical_op2   s@   

rB   c                 C  F   t | j|j}|| jkrtd| d| j dt r!t| |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    Z	out_shaper@   r@   rA   rI   z      
rI   c                 C  rC   )z
    Inplace version of ``logical_or`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_or`.
    rD   rE   rF   N)r   rG   rH   r   r   logical_or_rJ   r@   r@   rA   rL      rK   rL   c                 C  rC   )z
    Inplace version of ``logical_xor`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_logical_xor`.
    rD   rE   rF   N)r   rG   rH   r   r   logical_xor_rJ   r@   r@   rA   rM      rK   rM   c                 C     t  rt| 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    r@   r@   rA   rO         
rO   c                 C  s   t  rt| S t| dg dd t|dttdfd t r$t| S tdi t	 }|j
dd}d|_|jdd	| gid
|gid |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#   r/   Tr2   r4   r5   )rR   )r   r   rR   r   r   r   r6   r   r   r:   r;   stop_gradientr<   )r   r    r?   Zcondr@   r@   rA   rR      s   

rR   c                 C  sR   t  r	t| |S tdi t }|jdd}|jd| g|gdd|gid |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#   r/   r1   r4   r5   N)rT   )r   r   rT   r   r:   r;   r<   r   r   r    r?   r   r@   r@   rA   rT      s   !rT   h㈵>:0yE>Frtolfloatatol	equal_nanc                 C  sP  t  rt| ||||S t rUt| dg dd t|dg dd t|ttjj	fs3t
dt| t|ttjj	fsEt
dt| t|dtd t| ||||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 }|jd	d
}| |d}d|i}	t|t||d}
|j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 r[   rX   rZ   r#   r/   ZInputOtherr4   rX   rZ   r[   r6   r7   r8   attrsN)r]   )r   r   r]   r   r   
isinstancerY   paddlepirValue	TypeErrorr6   r   r#   r   r:   r;   r   r<   r   r   rX   rZ   r[   r    r?   r   r7   r8   rb   r@   r@   rA   r]   
  sb   8
r]   r\   otherr   c                C  s   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|d}t |tr2t|}t r=tj| ||dS t| dg dd t|dg dd tdi t }|jdd	}d
|_|jd| g|gdd|gid |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 )rG   r0   Z
fill_valuerj   r   r#   r)   r*   r+   uint8r%   r&   r'   r(   r,   r-   r.   equalr   r#   r/   Tr1   r4   r5   N)rm   )rc   intr#   rY   r   complexrd   re   rf   rg   r6   r   r0   	to_tensorr   r   rm   r   r   r:   r;   rS   r<   )r   r   r    r   r?   r@   r@   rA   rm   y  sB   $

rm   c                 C  rC   )z
    Inplace version of ``equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_equal`.
    rD   rE   rF   N)r   rG   rH   r   r   equal_rJ   r@   r@   rA   rq     rK   rq   c                 C  |   t  r	t| |S t| dg dd t|dg dd tdi t }|jdd}d|_|jd| g|gdd	|gid
 |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.
        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.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.
    Returns:
        Tensor: The 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 ])
    r   rk   greater_equalr   r#   r/   Tr1   r4   r5   N)rs   )	r   r   rs   r   r   r:   r;   rS   r<   rU   r@   r@   rA   rs     s.   rs   c                 C  rC   )z
    Inplace version of ``greater_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_greater_equal`.
    rD   rE   rF   N)r   rG   rH   r   r   greater_equal_rJ   r@   r@   rA   rt   <  rK   rt   c                 C  rC   )z
    Inplace version of ``greater_than`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_greater_than`.
    rD   rE   rF   N)r   rG   rH   r   r   greater_than_rJ   r@   r@   rA   ru   K  rK   ru   c                 C  rr   )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.
        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.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: The 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])
    r   rk   
less_equalr   r#   r/   Tr1   r4   r5   N)rv   )	r   r   rv   r   r   r:   r;   rS   r<   rU   r@   r@   rA   rv   Z  s.   rv   c                 C  rC   )z
    Inplace version of ``less_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_less_equal`.
    rD   rE   rF   N)r   rG   rH   r   r   less_equal_rJ   r@   r@   rA   rw     rK   rw   c                 C  rr   )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.
        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.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: The 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])
    r   rk   	less_thanr   r#   r/   Tr1   r4   r5   Nrx   )	r   r   rx   r   r   r:   r;   rS   r<   rU   r@   r@   rA   rx     .   rx   c                 C  rC   )z
    Inplace version of ``less_than`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_less_than`.
    rD   rE   rF   N)r   rG   rH   r   r   
less_than_rJ   r@   r@   rA   r{   
  rK   r{   c                 C     t | ||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.
        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.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: The 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(x, y)
            >>> print(result1)
            Tensor(shape=[3], dtype=bool, place=Place(cpu), stop_gradient=True,
            [False, True , False])
    ry   r   r   r    r@   r@   rA   less  s   r~   c                 C  r|   )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@   rA   less_9  s   r   c                 C  rr   )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.
        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.
        name (str|None, optional): The default value is None.  Normally there is no need for
            user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

    Returns:
        Tensor: The 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 ])
    r   rk   	not_equalr   r#   r/   Tr1   r4   r5   N)r   )	r   r   r   r   r   r:   r;   rS   r<   rU   r@   r@   rA   r   D  rz   r   c                 C  rC   )z
    Inplace version of ``not_equal`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_not_equal`.
    rD   rE   rF   N)r   rG   rH   r   r   
not_equal_rJ   r@   r@   rA   r     rK   r   r   TypeGuard[Tensor]c                 C  s$   t  rt| tjtjjfS t| tS )a8  

    Tests whether input object is a paddle.Tensor.

    Args:
        x (object): Object to test.

    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   rc   rd   r   re   rf   r   )r   r@   r@   rA   	is_tensor  s   
r   c                 C  s   t  rtt| }|r|||S ||S t|dg d|  |d ur)t|dg d|  |d ur4t|dt|  t| fi t }|rG|j|jksGJ |d u rR|j	|jd}|rc|j
| ||dd|id |S |j
| d	|id|id |S )
Nr   )r#   rl   r%   r&   r'   r(   r   r   r/   r1   r4   r5   r2   )r   r9   r   r   r   r   r   r:   r0   r;   r<   r=   r@   r@   rA   _bitwise_op  sD   

r   c                 C  .   t  r|du rt| |S td| |||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    r@   r@   rA   r     
   $r   
int | boolc                 C  sB   t |ttfrtj|| jd}t|| d d S tdt|j	 d)Nr/   $unsupported operand type(s) for |: '' and 'Tensor')
rc   rn   r#   rd   rp   r0   r   rg   r6   __name__)r   r   Zy_tensorr@   r@   rA   __rand__"  s   r   c                 C  rC   )z
    Inplace version of ``bitwise_and`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_and`.
    rD   rE   rF   N)r   rG   rH   r   r   bitwise_and_rJ   r@   r@   rA   r   ,  rK   r   c                 C  r   )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   r@   r@   rA   r   ;  s
   +r   c                 C  D   t |ttfrtj|| jd}t|| ||dS tdt|j	 dNr/   r   r    r   r   )
rc   rn   r#   rd   rp   r0   r   rg   r6   r   r   r@   r@   rA   __ror__n     r   )r   r   c                 C  rC   )z
    Inplace version of ``bitwise_or`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_or`.
    rD   rE   rF   N)r   rG   rH   r   r   bitwise_or_rJ   r@   r@   rA   r   }  s   
r   c                 C  r   )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   r@   r@   rA   r     r   r   c                 C  r   r   )
rc   rn   r#   rd   rp   r0   r   rg   r6   r   r   r@   r@   rA   __rxor__  r   r   c                 C  rC   )z
    Inplace version of ``bitwise_xor`` API, the output Tensor will be inplaced with input ``x``.
    Please refer to :ref:`api_paddle_bitwise_xor`.
    rD   rE   rF   N)r   rG   rH   r   r   bitwise_xor_rJ   r@   r@   rA   r     rK   r   c                 C  s,   t  r|du rt| S td| 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    r@   r@   rA   r     s
   "
r   c                 C  rN   )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_rP   r@   r@   rA   r      rQ   r   c                 C  s   t | ||d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   r@   r@   rA   bitwise_invert
  s   #r   c                 C  s   t | |d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   rP   r@   r@   rA   bitwise_invert_0  s   r   c                 C  sR  t  rVt rMt| dg dd t|dg dd t|tjjr(t|ddgd nt|dtd t|tjjr?t|ddgd nt|dtd t|dt	d t
| ||||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 }|jdd	}| |d
}d|i}	t|t||d}
|j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`. The behaviour of this
    operator is analogous to :math:`numpy.isclose`, 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, complex64, complex128.
        y(Tensor): The input tensor, it's data type should be float16, float32, float64, complex64, complex128.
        rtol(float, optional): The relative tolerance. Default: :math:`1e-5` .
        atol(float, optional): The absolute tolerance. Default: :math:`1e-8` .
        equal_nan(bool, optional): If :math:`True` , then two :math:`NaNs` will be compared as equal. Default: :math:`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.isclose(x, y, rtol=1e-05, atol=1e-08,
            ...                          equal_nan=False, name="ignore_nan")
            >>> print(result1)
            Tensor(shape=[2], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , False])
            >>> result2 = paddle.isclose(x, y, rtol=1e-05, atol=1e-08,
            ...                          equal_nan=True, name="equal_nan")
            >>> print(result2)
            Tensor(shape=[2], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , False])
            >>> x = paddle.to_tensor([1.0, float('nan')])
            >>> y = paddle.to_tensor([1.0, float('nan')])
            >>> result1 = paddle.isclose(x, y, rtol=1e-05, atol=1e-08,
            ...                          equal_nan=False, name="ignore_nan")
            >>> print(result1)
            Tensor(shape=[2], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True , False])
            >>> result2 = paddle.isclose(x, y, rtol=1e-05, atol=1e-08,
            ...                          equal_nan=True, name="equal_nan")
            >>> print(result2)
            Tensor(shape=[2], dtype=bool, place=Place(cpu), stop_gradient=True,
            [True, True])
    r\   )r)   r*   r+   r-   r.   iscloser+   rX   rZ   r[   r#   r/   r^   r4   r`   ra   N)r   )r   r   r   rc   rd   re   rf   r   rY   r#   r   r   r   r:   r;   r   r<   rh   r@   r@   rA   r   :  sp   >
r   )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   )rV   rW   FN)r   r   r   r   rX   rY   rZ   rY   r[   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   )I
__future__r   typingr   r   Ztyping_extensionsr   rd   r   Zpaddle._C_opsr   r   r	   r
   r   Zpaddle.tensor.creationr   Zpaddle.tensor.mathr   Zpaddle.utils.decorator_utilsr   r   Zpaddle.utils.inplace_utilsr   Zbase.data_feederr   r   Zcommon_ops_importr   Z	frameworkr   r   r   r   r   __all__rB   rI   rL   rM   rO   rR   rT   r]   rm   rq   rs   rt   ru   rv   rw   rx   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r@   r@   r@   rA   <module>   s   H	+1odOPQ 
Q
%3
+
5.*
&