§
    ’©ºjÂ  ã                   óv   — d dl Z d dl mZ d dlmZ d dlmZ dedededefd	„Zd
ededefd„Zdedededefd„Z	dS )é    N)ÚTensor)Ú_check_same_shape)ÚTorchMetricsUserErrorÚpredsÚtargetsÚpÚreturnc                 ó  — t          | |¦  «         t          |t          t          f¦  «        r|dk    st	          d|› �¦  «        ‚t          j        | |z
  ¦  «        }t          j        t          j        ||¦  «        ¦  «        S )a  Update and return variables required to compute Minkowski distance.

    Checks for same shape of input tensors.

    Args:
        preds: Predicted tensor
        targets: Ground truth tensor
        p: Non-negative number acting as the p to the errors

    é   z>Argument ``p`` must be a float or int greater than 1, but got )	r   Ú
isinstanceÚfloatÚintr   ÚtorchÚabsÚsumÚpow)r   r   r   Ú
differences       ú|/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/torchmetrics/functional/regression/minkowski.pyÚ_minkowski_distance_updater      sz   € õ �e˜WÑ%Ô%Ð%å�q�5¥#˜,Ñ'Ô'ð j¨A°ªF¨FÝ#Ð$hÐefÐ$hÐ$hÑiÔiÐiå”˜5 7™?Ñ+Ô+€JÝŒ9•U”Y˜z¨1Ñ-Ô-Ñ.Ô.Ð.ó    Údistancec                 ó2   — t          j        | d|z  ¦  «        S )aÉ  Compute Minkowski Distance.

    Args:
        distance: Sum of the p-th powers of errors over all observations
        p: The non-negative numeric power the errors are to be raised to

    Example:
        >>> preds = torch.tensor([0., 1, 2, 3])
        >>> target = torch.tensor([0., 2, 3, 1])
        >>> distance_p_sum = _minkowski_distance_update(preds, target, 5)
        >>> _minkowski_distance_compute(distance_p_sum, 5)
        tensor(2.0244)

    g      ð?)r   r   )r   r   s     r   Ú_minkowski_distance_computer   )   s   € õ Œ9�X˜s Q™wÑ'Ô'Ð'r   c                 óD   — t          | ||¦  «        }t          ||¦  «        S )a'  Compute the `Minkowski distance`_.

    .. math:: d_{\text{Minkowski}} = \\sum_{i}^N (| y_i - \\hat{y_i} |^p)^\frac{1}{p}

    This metric can be seen as generalized version of the standard euclidean distance which corresponds to minkowski
    distance with p=2.

    Args:
        preds: estimated labels of type Tensor
        targets: ground truth labels of type Tensor
        p: int or float larger than 1, exponent to which the difference between preds and target is to be raised

    Return:
        Tensor with the Minkowski distance

    Example:
        >>> from torchmetrics.functional.regression import minkowski_distance
        >>> x = torch.tensor([1.0, 2.8, 3.5, 4.5])
        >>> y = torch.tensor([6.1, 2.11, 3.1, 5.6])
        >>> minkowski_distance(x, y, p=3)
        tensor(5.1220)

    )r   r   )r   r   r   Úminkowski_dist_sums       r   Úminkowski_distancer   ;   s'   € õ0 4°E¸7ÀAÑFÔFÐÝ&Ð'9¸1Ñ=Ô=Ð=r   )
r   r   Útorchmetrics.utilities.checksr   Ú!torchmetrics.utilities.exceptionsr   r   r   r   r   © r   r   ú<module>r       sÙ   ðð €€€Ø Ð Ð Ð Ð Ð à ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø CÐ CÐ CÐ CÐ CÐ Cð/ fð /°vð /À%ð /ÈFð /ð /ð /ð /ð((¨&ð (°Uð (¸vð (ð (ð (ð (ð$>˜fð >¨vð >¸%ð >ÀFð >ð >ð >ð >ð >ð >r   