+
    åû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   "ÚWC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\losses\geman_mcclure.pyÚ__annotate__r      s5   € ÷ C^ñ C^˜\ð C^°ð C^È#ð C^Ð[gñ C^ó    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                  ! V4      pRV,          VR,           ,          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# )	a‰  Compute the Geman-McClure loss between a prediction and a target.

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

.. math::

    \text{loss}(x, y) = \frac{2 (x - y)^{2}}{(x - y)^{2} + 4}

Reference:
    [1] https://arxiv.org/pdf/1701.03077.pdf
    [2] Geman-McClure: Geman and McClure, 1985, Bayesian image analysis: an application to single photon
    emission tomography.

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

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.GemanMcclureLoss`: the module form.
    - :func:`~kornia.losses.cauchy_loss`: grows logarithmically, without bound.
    - :func:`~kornia.losses.welsch_loss`: saturates at 1, faster.

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

ÚmeanÚsumÚnonez/Given type of reduction is not supported. Got: g       @g      @zInvalid reduction option.)r   r   r   N)r   r   r   r   ÚtorchÚpromote_typesÚdtypeÚfloat16Úbfloat16ÚfloatÚsquarer   r   ÚNotImplementedErrorÚto)r   r   r   Úoutput_dtypeÚcompute_diffÚdiff2Úlosss   &&&    r   Úgeman_mcclure_lossr'      s  € ôN ˜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Ü�LŠL˜Ó&€EØ��;˜% #�+Õ&€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# )ÚGemanMcclureLossa.  Compute the Geman-McClure loss between a prediction and a target (module form).

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

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

Args:
    reduction: ``'none'`` (default), ``'mean'`` or ``'sum'``, as in :func:`~kornia.losses.geman_mcclure_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.geman_mcclure_loss`: the one-call form.
    - :class:`~kornia.losses.CauchyLoss`: grows logarithmically, without bound.
    - :class:`~kornia.losses.WelschLoss`: saturates at 1, faster.

Example:
    >>> criterion = GemanMcclureLoss(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   ÚGemanMcclureLoss.__annotate__   s   € ÷ #ñ # #ð #°4ñ #r   c                	ó0   <€ \         SV `  4        Wn        R # )N)ÚsuperÚ__init__r   )Úselfr   Ú	__class__s   &&€r   r/   ÚGemanMcclureLoss.__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&   € ÷ Rñ R˜Lð R°ð RÀñ Rr   c                ó0   € \        WV P                  R7      # )aV  Compute the Geman-McClure 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 robust
    penalty limits the contribution of large residuals compared with a
    plain squared-error loss.
)r   r   r   )r'   r   )r0   r   r   s   &&&r   ÚforwardÚGemanMcclureLoss.forwardƒ   s   € ô " tÀ$Ç.Á.ÔQÐQr   )r   ©r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r/   r5   Ú__static_attributes__Ú__classcell__)r1   s   @r   r)   r)   `   s   ø† ñ÷<#ò #÷Ró Rr   r)   r7   )Ú
__future__r   r   r   Úkornia.core.checkr   r   r   r   r'   ÚModuler)   r   r   r   Ú<module>rB      s0   ðõ$ #ã Ý ç uÓ u÷C^ôL/R�r—y‘yö /Rr   