Ë
    þÍ:jÂ  ã                   ót   — 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	y)é    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       ú�/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torchmetrics/functional/regression/minkowski.pyÚ_minkowski_distance_updater      sc   € ô �e˜WÔ%ä�qœ5¤#˜,Ô'¨A°ªFÜ#Ð&dÐefÐdgÐ$hÓiÐiä—‘˜5 7™?Ó+€JÜ�9‰9”U—Y‘Y˜z¨1Ó-Ó.Ð.ó    Údistancec                 ó4   — 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‰9�X˜s Q™wÓ'Ð'r   c                 ó4   — 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ÐÜ&Ð'9¸1Ó=Ð=r   )
r   r   Útorchmetrics.utilities.checksr   Ú!torchmetrics.utilities.exceptionsr   r   r   r   r   © r   r   ú<module>r       so   ðó Ý å ;Ý Cð/ fð /°vð /À%ð /ÈFó /ð((¨&ð (°Uð (¸vó (ð$>˜fð >¨vð >¸%ð >ÀFô >r   