+
    åûj�  ã                  ó„   € ^ RI Ht ^ 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# )é    )Úannotations)ÚOptionalN)Ú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úOptional[str]Úreturn© )Úformats   "ÚPC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\losses\welsch.pyÚ__annotate__r      s5   € ÷ H^ñ H^�lð H^¨,ð H^À=ð H^Ð^jñ H^ó    c                ór  € \        V 4       \        V4       \        W4       \        W4       \        VRJ ;'       g    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V^,          p\        P                  ! RV,          4      p\        P                  ! VR8  RV,          RV,           ,          RRV,          P                  4       ,
          4      pVe   VR8X  d   M;VR8X  d   VP                  4       pM#VR8X  d   VP                  4       pM\        R	4      hV\        P                  \        P                  39   d   VP!                  V4      # T# )as  Compute the Welsch (Leclerc) loss between a prediction and a target.

``loss = welsch_loss(img1, img2)`` penalises each residual :math:`x - y` of ``img1`` (:math:`x`) and ``img2``
(:math:`y`) quadratically near 0 and saturates at 1, and its gradient vanishes for large residuals.

.. math::

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

Reference:
    [1] https://arxiv.org/pdf/1701.03077.pdf
    [2] Welsch: https://www.tandfonline.com/doi/abs/10.1080/03610917808812083
    [3] Leclerc: https://link.springer.com/article/10.1007/BF00054839

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

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

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

See Also:
    - :class:`~kornia.losses.WelschLoss`: the module form.
    - :func:`~kornia.losses.geman_mcclure_loss`: saturates at 2, more slowly.

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

NÚmeanÚsumÚnonez/Given type of reduction is not supported. Got: g      Ð?g      ð?g       @zInvalid reduction option.)r   r   r   g      à¿)r   r	   r   r   ÚtorchÚpromote_typesÚdtypeÚfloat16Úbfloat16ÚfloatÚtanhÚwhereÚexpr   r   ÚNotImplementedErrorÚto)r   r   r   Úoutput_dtypeÚdiffÚsquaredÚtÚlosss   &&&     r   Úwelsch_lossr+      sV  € ôN ˜4Ô ä˜4Ô ä˜DÔ'ä˜TÔ(äØ�TÐ×AÐA˜YÐ*AÑAØ
9¸)¸ÐEôô ×&Ò& t§z¡z°4·:±:Ó>€LØ*6¼5¿=¹=Ì%Ï.É.Ð:YÔ*Yˆ4�:‰:‹<˜$Ÿ*™*›,Ö&Ð_cÕ_j€DØ�A�g€GÜ�
Š
�4˜'•>Ó"€AÜ�;Š;�w ‘} c¨A¥g°°qµÕ&9¸3À$ÈÅ.×AUÑAUÓAWÕ;WÓX€Dð Ò˜I¨Ô/ØØ	�fÔ	Ø�y‰y‹{‰Ø	�eÔ	Ø�x‰x‹z‰ä!Ð"=Ó>Ð>à$0´U·]±]ÄEÇNÁNÐ4SÔ$Sˆ4�7‰7�<Ó Ð]ÐY]Ð]r   c                  óB   a € ] tR t^htRtRR V 3R llltR R ltRtV ;t# )Ú
WelschLossaÚ  Compute the Welsch (Leclerc) loss between a prediction and a target (module form).

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

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

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

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

See Also:
    - :func:`~kornia.losses.welsch_loss`: the one-call form.
    - :class:`~kornia.losses.GemanMcclureLoss`: saturates at 2, more slowly.

Example:
    >>> criterion = WelschLoss(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   ÚWelschLoss.__annotate__†   s   € ÷ #ñ # -ð #¸Tñ #r   c                	ó0   <€ \         SV `  4        Wn        R # )N)ÚsuperÚ__init__r   )Úselfr   Ú	__class__s   &&€r   r3   ÚWelschLoss.__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   r0   Š   s&   € ÷ Kñ K˜Lð K°ð KÀñ Kr   c                ó0   € \        WV P                  R7      # )aD  Compute the Welsch 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 Welsch
    penalty saturates for large residuals, reducing the influence of
    strong outliers.
)r   r   r   )r+   r   )r4   r   r   s   &&&r   ÚforwardÚWelschLoss.forwardŠ   s   € ô  ¸4¿>¹>ÔJÐJr   )r   ©r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r3   r9   Ú__static_attributes__Ú__classcell__)r5   s   @r   r-   r-   h   s   ø† ñ÷:#ò #÷Kó Kr   r-   r;   )Ú
__future__r   Útypingr   r   r   Úkornia.core.checkr   r   r   r	   r+   ÚModuler-   r   r   r   Ú<module>rG      s6   ðõ$ #å ã Ý ÷ vÓ u÷H^ôV.K�—‘ö .Kr   