§
    ù²Åj	  ã                   ór   — d dl Z d dlmc mZ ddlmZ 	 	 	 dde j        de j        ded	ed
e	de j        fd„Z
dS )é    Né   )Ú_log_api_usage_onceç      Ð?ÚnoneÚinputsÚtargetsÚalphaÚgammaÚ	reductionÚreturnc                 ó  — t           j                             ¦   «         s2t           j                             ¦   «         st	          t
          ¦  «         t          j        | ¦  «        }t          j        | |d¬¦  «        }||z  d|z
  d|z
  z  z   }|d|z
  |z  z  }|dk    r||z  d|z
  d|z
  z  z   }	|	|z  }|dk    rnI|dk    r| 	                    ¦   «         }n.|dk    r| 
                    ¦   «         }nt          d|› d�¦  «        ‚|S )	a  
    Loss used in RetinaNet for dense detection: https://arxiv.org/abs/1708.02002.

    Args:
        inputs (Tensor): A float tensor of arbitrary shape.
                The predictions for each example.
        targets (Tensor): A float tensor with the same shape as inputs. Stores the binary
                classification label for each element in inputs
                (0 for the negative class and 1 for the positive class).
        alpha (float): Weighting factor in range (0,1) to balance
                positive vs negative examples or -1 for ignore. Default: ``0.25``.
        gamma (float): Exponent of the modulating factor (1 - p_t) to
                balance easy vs hard examples. Default: ``2``.
        reduction (string): ``'none'`` | ``'mean'`` | ``'sum'``
                ``'none'``: No reduction will be applied to the output.
                ``'mean'``: The output will be averaged.
                ``'sum'``: The output will be summed. Default: ``'none'``.
    Returns:
        Loss tensor with the reduction option applied.
    r   )r   é   r   ÚmeanÚsumz$Invalid Value for arg 'reduction': 'z3 
 Supported reduction modes: 'none', 'mean', 'sum')ÚtorchÚjitÚis_scriptingÚ
is_tracingr   Úsigmoid_focal_lossÚsigmoidÚFÚ binary_cross_entropy_with_logitsr   r   Ú
ValueError)
r   r   r	   r
   r   ÚpÚce_lossÚp_tÚlossÚalpha_ts
             úKC:\Projects\Historical\venv\Lib\site-packages\torchvision/ops/focal_loss.pyr   r      s*  € õ: Œ9×!Ò!Ñ#Ô#ð 0­E¬I×,@Ò,@Ñ,BÔ,Bð 0ÝÕ.Ñ/Ô/Ð/ÝŒ�fÑÔ€AÝÔ0°¸ÈFÐSÑSÔS€GØ
ˆg‰+˜˜Q™ 1 w¡;Ñ/Ñ
/€CØ�q˜3‘w 5Ñ(Ñ)€Dà�‚z€zØ˜'‘/ Q¨¡Y°1°w±;Ñ$?Ñ?ˆØ˜‰~ˆð �FÒÐØØ	�fÒ	Ð	Ø�yŠy‰{Œ{ˆˆØ	�eÒ	Ð	Ø�xŠx‰zŒzˆˆåØr°9ÐrÐrÐrñ
ô 
ð 	
ð €Kó    )r   r   r   )r   Útorch.nn.functionalÚnnÚ
functionalr   Úutilsr   ÚTensorÚfloatÚstrr   © r    r   ú<module>r)      s§   ðØ €€€Ø Ð Ð Ð Ð Ð Ð Ð Ð à 'Ð 'Ð 'Ð 'Ð 'Ð 'ð ØØð3ð 3ØŒLð3àŒ\ð3ð ð3ð ð	3ð
 ð3ð „\ð3ð 3ð 3ð 3ð 3ð 3r    