Ë
    Ž\;j+  ã                   ó<   — d dl mZ d dlmZ d dlmZ d dlmZ dd„Zy)é    )Ú_legacy_C_ops)Úcheck_variable_and_dtype)ÚLayerHelper)Úin_dynamic_modec                 óŽ  — t        |t        «      r0ddddœj                  |j                  «       «      }|€t	        d«      ‚t        «       rt        j                  | d|«      S t        | ddd	gd
«       d|i}t        di t        «       ¤Ž}|j                  d¬«      }|j                  |«      }|j                  d
d| id|i|¬«       |S )aÎ  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   é   é   )ÚsumÚmeanÚnonezUnsupported reduction type.Ú	reductionÚxÚfloat32Úfloat64Úidentity_loss)Úinput_param_nameÚXÚOut)ÚtypeÚinputsÚoutputsÚattrs)r   )Ú
isinstanceÚstrÚgetÚlowerÚ	Exceptionr   r   r   r   r   ÚlocalsÚinput_dtypeÚ"create_variable_for_type_inferenceÚ	append_op)r   r   r   ÚhelperÚdtypeÚouts         ú`G:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\paddle/incubate/nn/loss.pyr   r      sÔ   € ôH �)œSÔ!Ø q°!Ñ4×8Ñ8¸¿¹Ó9JÓKˆ	ØÐÜÐ9Ó:Ð:äÔÜ×*Ñ*¨1¨k¸9ÓEÐEä˜Q  i°Ð%;¸_ÔMØ˜)Ð$€EÜÑ5¬F«HÑ5€FØ×Ñ°ÐÓ4€EØ
×
3Ñ
3°EÓ
:€CØ
×ÑØ c¨1 X¸¸s°|È5ð ô ð €Jó    N)r   )	Úpaddler   Úpaddle.base.data_feederr   Úpaddle.base.layer_helperr   Úpaddle.frameworkr   r   © r&   r%   Ú<module>r,      s   ðõ !Ý <Ý 0Ý ,ô4r&   