+
    åûj~  ã                  óx   € ^ RI Ht ^ RIt^ RIHt ^ RIHtHtHtHt R	R R llt	 ! R R]P                  4      tR# )
é    )ÚannotationsN)Únn)ÚKORNIA_CHECKÚKORNIA_CHECK_IS_TENSORÚKORNIA_CHECK_SAME_DEVICEÚKORNIA_CHECK_SAME_SHAPEc               ó(   € V ^8„  d   QhRRRRRRRR/# )é   Úimg1útorch.TensorÚimg2Ú	reductionÚstrÚreturn© )Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\losses\cauchy.pyÚ__annotate__r      s5   € ÷ A^ñ A^�lð A^¨,ð A^À3ð A^ÐT`ñ A^ó    c                óØ  € \        V 4       \        V4       \        W4       \        W4       \        VR9   RV 24       \        P
                  ! V P                  VP                  4      pV\        P                  \        P                  39   d&   V P                  4       VP                  4       ,
          MW,
          p\        P                  ! R\        P                  ! V4      ,          4      pVR8X  d   VP                  4       pM/VR8X  d   VP                  4       pMVR8X  g   Vf   M\        R4      hV\        P                  \        P                  39   d   VP                  V4      # T# )aN  Compute the Cauchy (Lorentzian) loss between a prediction and a target.

``loss = cauchy_loss(img1, img2)`` penalises each residual :math:`x - y` of ``img1`` (:math:`x`) and ``img2``
(:math:`y`) quadratically near 0 and only logarithmically beyond, without bound.

.. math::

    \text{loss}(x, y) = \log\left(\frac{1}{2} (x - y)^{2} + 1\right)

Reference:
    [1] https://arxiv.org/pdf/1701.03077.pdf
    [2] Cauchy: https://files.is.tue.mpg.de/black/papers/cviu.63.1.1996.pdf

Convention:
    See the Convention block of :func:`~kornia.losses.charbonnier_loss`; this is Barron's loss with
    :math:`\alpha = 0`.

Args:
    img1: prediction with shape ``(*)``.
    img2: target with the same shape as ``img1``.
    reduction: ``'none'`` (default) keeps one loss per element, ``'mean'`` averages them, ``'sum'`` adds them.

Returns:
    the loss with the shape of the inputs for ``reduction='none'``, a scalar otherwise.

See Also:
    - :class:`~kornia.losses.CauchyLoss`: the module form.
    - :func:`~kornia.losses.charbonnier_loss`: grows linearly for large residuals.
    - :func:`~kornia.losses.geman_mcclure_loss`: saturates at 2 for large residuals.

Example:
    >>> img1 = torch.randn(2, 3, 32, 32, requires_grad=True)
    >>> img2 = torch.randn(2, 3, 32, 32)
    >>> output = cauchy_loss(img1, img2, reduction="mean")
    >>> output.backward()

ÚmeanÚsumÚnonez/Given type of reduction is not supported. Got: g      à?zInvalid reduction option.)r   r   r   N)r   r   r   r   ÚtorchÚpromote_typesÚdtypeÚfloat16Úbfloat16ÚfloatÚlog1pÚsquarer   r   ÚNotImplementedErrorÚto)r   r   r   Úoutput_dtypeÚcompute_diffÚlosss   &&&   r   Úcauchy_lossr'      s  € ôL ˜4Ô ä˜4Ô ä˜DÔ'ä˜TÔ(äØÐ2Ñ2Ð6eÐfoÐepÐ4qôô
 ×&Ò& t§z¡z°4·:±:Ó>€LØ2>Ä5Ç=Á=ÔRW×R`ÑR`ÐBaÔ2a�4—:‘:“< $§*¡*£,Ö.ÐgkÕgr€LÜ�;Š;�sœUŸ\š\¨,Ó7Õ7Ó8€Dð �FÔØ�y‰y‹{‰Ø	�eÔ	Ø�x‰x‹z‰Ø	�fÔ	 	Ò 1Øä!Ð"=Ó>Ð>à$0´U·]±]ÄEÇNÁNÐ4SÔ$Sˆ4�7‰7�<Ó Ð]ÐY]Ð]r   c                  óB   a € ] tR t^^tRtRR V 3R llltR R ltRtV ;t# )Ú
CauchyLossa!  Compute the Cauchy (Lorentzian) loss between a prediction and a target (module form).

``criterion = CauchyLoss(reduction)`` stores ``reduction``, and ``loss = criterion(img1, img2)`` is
:func:`~kornia.losses.cauchy_loss`.

Convention:
    See the Convention block of :func:`~kornia.losses.cauchy_loss`.

Args:
    reduction: ``'none'`` (default), ``'mean'`` or ``'sum'``, as in :func:`~kornia.losses.cauchy_loss`.

Shape:
    - img1: prediction ``(*)``.
    - img2: target with the same shape as ``img1``.
    - Output: the shape of the inputs for ``reduction='none'``, a scalar otherwise.

See Also:
    - :func:`~kornia.losses.cauchy_loss`: the one-call form.
    - :class:`~kornia.losses.CharbonnierLoss`: grows linearly for large residuals.
    - :class:`~kornia.losses.GemanMcclureLoss`: saturates at 2 for large residuals.

Example:
    >>> criterion = CauchyLoss(reduction="mean")
    >>> img1 = torch.randn(2, 3, 32, 32, requires_grad=True)
    >>> img2 = torch.randn(2, 3, 32, 32)
    >>> output = criterion(img1, img2)
    >>> output.backward()

c               ó    € V ^8„  d   QhRRRR/# )r
   r   r   r   ÚNoner   )r   s   "r   r   ÚCauchyLoss.__annotate__}   s   € ÷ #ñ # #ð #°4ñ #r   c                	ó0   <€ \         SV `  4        Wn        R # )N)ÚsuperÚ__init__r   )Úselfr   Ú	__class__s   &&€r   r/   ÚCauchyLoss.__init__}   s   ø€ Ü‰ÑÔØ"Žr   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r   r   r   r   r   )r   s   "r   r   r,   �   s&   € ÷ Kñ K˜Lð K°ð KÀñ Kr   c                ó0   € \        WV P                  R7      # )aZ  Compute the Cauchy robust regression loss.

Args:
    img1: Predicted tensor with arbitrary shape.
    img2: Target tensor with the same shape as ``img1``.

Returns:
    Loss tensor reduced according to ``self.reduction``. The Cauchy
    penalty grows more slowly than squared error for large residuals,
    making it less sensitive to outliers.
)r   r   r   )r'   r   )r0   r   r   s   &&&r   ÚforwardÚCauchyLoss.forward�   s   € ô  ¸4¿>¹>ÔJÐJr   )r   ©r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r/   r5   Ú__static_attributes__Ú__classcell__)r1   s   @r   r)   r)   ^   s   ø† ñ÷<#ò #÷Kó Kr   r)   r7   )Ú
__future__r   r   r   Úkornia.core.checkr   r   r   r   r'   ÚModuler)   r   r   r   Ú<module>rB      s0   ðõ$ #ã Ý ç uÓ u÷A^ôH/K�—‘ö /Kr   