§
    ’©ºj7
  ã            	       óz   — d dl Z d dl mZ d dlmZ dededeeef         fd„Z	 dd	ed
ededefd„Zdededefd„ZdS )é    N)ÚTensor)Ú_check_same_shapeÚpredsÚtargetÚreturnc                 óÈ   — t          | |¦  «         | |z
                       ¦   «                              ¦   «         }|                     ¦   «                              ¦   «         }||fS )zÕUpdate and returns variables required to compute Weighted Absolute Percentage Error.

    Check for same shape of input tensors.

    Args:
        preds: Predicted tensor
        target: Ground truth tensor

    )r   ÚabsÚsum©r   r   Úsum_abs_errorÚ	sum_scales       úx/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/torchmetrics/functional/regression/wmape.pyÚ/_weighted_mean_absolute_percentage_error_updater      sY   € õ �e˜VÑ$Ô$Ð$à˜V‘^×(Ò(Ñ*Ô*×.Ò.Ñ0Ô0€MØ—
’
‘”× Ò Ñ"Ô"€Ià˜)Ð#Ð#ó    ç-`Àš¡³>r   r   Úepsilonc                 ó4   — | t          j        ||¬¦  «        z  S )zãCompute Weighted Absolute Percentage Error.

    Args:
        sum_abs_error: scalar with sum of absolute errors
        sum_scale: scalar with sum of target values
        epsilon: small float to prevent division by zero

    )Úmin)ÚtorchÚclamp)r   r   r   s      r   Ú0_weighted_mean_absolute_percentage_error_computer   *   s   € ð �5œ; y°gÐ>Ñ>Ô>Ñ>Ð>r   c                 óH   — t          | |¦  «        \  }}t          ||¦  «        S )a½  Compute weighted mean absolute percentage error (`WMAPE`_).

    The output of WMAPE metric is a non-negative floating point, where the optimal value is 0. It is computes as:

    .. math::
        \text{WMAPE} = \frac{\sum_{t=1}^n | y_t - \hat{y}_t | }{\sum_{t=1}^n |y_t| }

    Where :math:`y` is a tensor of target values, and :math:`\hat{y}` is a tensor of predictions.

    Args:
        preds: estimated labels
        target: ground truth labels

    Return:
        Tensor with WMAPE.

    Example:
        >>> from torch import randn
        >>> preds = randn(20,)
        >>> target = randn(20,)
        >>> weighted_mean_absolute_percentage_error(preds, target)
        tensor(1.3967)

    )r   r   r   s       r   Ú'weighted_mean_absolute_percentage_errorr   :   s*   € õ2  OÈuÐV\Ñ]Ô]Ñ€M�9Ý;¸MÈ9ÑUÔUÐUr   )r   )	r   r   Útorchmetrics.utilities.checksr   Útupler   Úfloatr   r   © r   r   ú<module>r      sé   ðð €€€Ø Ð Ð Ð Ð Ð à ;Ð ;Ð ;Ð ;Ð ;Ð ;ð$Øð$àð$ð ˆ6�6ˆ>Ôð$ð $ð $ð $ð0 ð?ð ?Øð?àð?ð ð?ð ð	?ð ?ð ?ð ?ð V°6ð VÀ6ð VÈfð Vð Vð Vð Vð Vð Vr   