§
    ’©ºj¬  ã            
       ó¦   — 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eef         fd„Zdeded	edeeef         fd
„Z	dededefd„Z
dededefd„ZdS )é    N)ÚTensor)Ú _check_data_shape_to_num_outputs)Ú_check_same_shapeÚpredsÚtargetÚreturnc                 ót   — | j         dk    r| |fS |                      d¦  «        |                     d¦  «        fS )Né   é   )ÚndimÚ	unsqueeze)r   r   s     ú{/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/torchmetrics/functional/regression/log_cosh.pyÚ_unsqueeze_tensorsr      s<   € Ø„z�Q‚€Ø�fˆ}ÐØ�?Š?˜1ÑÔ˜v×/Ò/°Ñ2Ô2Ð2Ð2ó    Únum_outputsc                 ó�  — t          | |¦  «         t          | ||¦  «         t          | |¦  «        \  } }| |z
  }t          j        t          j        |¦  «        t          j        | ¦  «        z   dz  ¦  «                             d¦  «                             ¦   «         }t          j        |j	        d         | j
        ¬¦  «        }||fS )aT  Update and returns variables required to compute LogCosh error.

    Check for same shape of input tensors.

    Args:
        preds: Predicted tensor
        target: Ground truth tensor
        num_outputs: Number of outputs in multioutput setting

    Return:
        Sum of LogCosh error over examples, and total number of examples

    r
   r   )Údevice)r   r   r   ÚtorchÚlogÚexpÚsumÚsqueezeÚtensorÚshaper   )r   r   r   ÚdiffÚsum_log_cosh_errorÚnum_obss         r   Ú_log_cosh_error_updater      s²   € õ �e˜VÑ$Ô$Ð$Ý$ U¨F°KÑ@Ô@Ð@å& u¨fÑ5Ô5�M€Eˆ6Ø�6‰>€DÝœ¥E¤I¨d¡O¤Oµe´iÀÀÑ6FÔ6FÑ$FÈ!Ñ#KÑLÔL×PÒPÐQRÑSÔS×[Ò[Ñ]Ô]ÐÝŒl˜6œ<¨œ?°5´<Ð@Ñ@Ô@€GØ˜wÐ&Ð&r   r   r   c                 ó0   — | |z                        ¦   «         S )z«Compute Mean Squared Error.

    Args:
        sum_log_cosh_error: Sum of LogCosh errors over all observations
        num_obs: Number of predictions or observations

    )r   )r   r   s     r   Ú_log_cosh_error_computer    4   s   € ð  Ñ(×1Ò1Ñ3Ô3Ð3r   c                 ó|   — t          | || j        dk    rdn| j        d         ¬¦  «        \  }}t          ||¦  «        S )aZ  Compute the `LogCosh Error`_.

    .. math:: \text{LogCoshError} = \log\left(\frac{\exp(\hat{y} - y) + \exp(\hat{y - y})}{2}\right)

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

    Args:
        preds: estimated labels with shape ``(batch_size,)`` or `(batch_size, num_outputs)``
        target: ground truth labels with shape ``(batch_size,)`` or `(batch_size, num_outputs)``

    Return:
        Tensor with LogCosh error

    Example (single output regression)::
        >>> from torchmetrics.functional.regression import log_cosh_error
        >>> preds = torch.tensor([3.0, 5.0, 2.5, 7.0])
        >>> target = torch.tensor([2.5, 5.0, 4.0, 8.0])
        >>> log_cosh_error(preds, target)
        tensor(0.3523)

    Example (multi output regression)::
        >>> from torchmetrics.functional.regression import log_cosh_error
        >>> preds = torch.tensor([[3.0, 5.0, 1.2], [-2.1, 2.5, 7.0]])
        >>> target = torch.tensor([[2.5, 5.0, 1.3], [0.3, 4.0, 8.0]])
        >>> log_cosh_error(preds, target)
        tensor([0.9176, 0.4277, 0.2194])

    r   éÿÿÿÿ)r   )r   r   r   r    )r   r   r   r   s       r   Úlog_cosh_errorr#   ?   sL   € õ: #9Øˆv¨¬
°aª¨ 1 1¸U¼[È¼_ð#ñ #ô #ÑÐ˜õ #Ð#5°wÑ?Ô?Ð?r   )r   r   Ú(torchmetrics.functional.regression.utilsr   Útorchmetrics.utilities.checksr   Útupler   Úintr   r    r#   © r   r   ú<module>r)      s  ðð €€€Ø Ð Ð Ð Ð Ð à UÐ UÐ UÐ UÐ UÐ UØ ;Ð ;Ð ;Ð ;Ð ;Ð ;ð3˜fð 3¨fð 3¸¸vÀv¸~Ô9Nð 3ð 3ð 3ð 3ð' &ð '°&ð 'Àsð 'ÈuÐU[Ð]cÐUcÔOdð 'ð 'ð 'ð 'ð04°ð 4Àð 4ÈFð 4ð 4ð 4ð 4ð @˜&ð  @¨&ð  @°Vð  @ð  @ð  @ð  @ð  @ð  @r   