
    ϑi                        % S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  \(       a0  S SKJrJrJr  S SKJr  \S	   rS
\S'   \S   rS
\S'   \\\4   rS
\S'   SSS jjrg)    )annotations)TYPE_CHECKING)_C_ops)check_variable_and_dtype)LayerHelper)in_dynamic_or_pir_mode)Literal	TypeAliasUnion)Tensor)meansumnoner
   _ReduceModeStringLiteral)r         _ReduceModeNumberLiteral_ReduceModec                   [        U[        5      (       a1  SSSS.R                  UR                  5       5      nUc  [	        S5      e[        5       (       a  [        R                  " X5      $ [        U SSS/S	5        S
U0n[        S0 [        5       D6nUR                  SS9nUR                  U5      nUR                  S	SU 0SU0US9  U$ )ar  Marks a tensor as being part of the loss calculation for IPU.

This operator is used to handle on the (final) loss of a model so that
it is used as the start of backpropagation.

When `reduction` is `none`, return raw `Out`.

When `reduction` is `mean`, return

.. math::
    Out = MEAN(Out)

When `reduction` is `sum`, return

.. math::
    Out = SUM(Out)

Parameters:
    x (Variable): The input tensor. The shapes is [N, *], where N is batch size and `*` means any number of
         additional dimensions. It's data type should be float32, float64 on CPU and float16, float32 on IPU.
    reduction(str|int, optional): Reduce the loss output. Supported string values are: 'sum', 'mean', 'none'
                        the corresponding int values are 0, 1, 2 respectively. The default value is "none".

Returns:
    Variable: The loss ``Tensor`` with the specified reduction applied.

Examples:

    .. code-block:: python

        >>> import paddle
        >>> paddle.enable_static()
        >>> loss = paddle.static.data(name="loss", shape=[-1, 1], dtype="float32")
        >>> out = paddle.incubate.identity_loss(loss, reduction=1)
r   r   r   )r   r   r   zUnsupported reduction type.xfloat32float64identity_loss	reduction)input_param_nameXOut)typeinputsoutputsattrs)r   )
isinstancestrgetlower	TypeErrorr   r   r   r   r   localsinput_dtype"create_variable_for_type_inference	append_op)r   r   r!   helperdtypeouts         W/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/incubate/nn/loss.pyr   r   $   s    H )S!!q!4889JK	9::##A11Qi%;_M)$E5FH5F4E

3
3E
:C
c1Xs|5   J    N)r   )r   r   r   r   returnr   )
__future__r   typingr   paddler   paddle.base.data_feederr   paddle.base.layer_helperr   paddle.frameworkr   r	   r
   r   r   r   __annotations__r   r   r    r/   r.   <module>r9      se    #    < 0 300*12G*HiH*1'*:i:" "::K 
4r/   