a
    þd+
  ã                   @   sz   d dl mZmZ d dlZd dlmZ d dlmZ eeeeef dœdd„Zeeeef edœd	d
„Z	eeedœdd„Z
dS )é    )ÚTupleÚUnionN)ÚTensor)Ú_check_same_shape)ÚpredsÚtargetÚreturnc                 C   s<   t | |ƒ t t t | ¡t |¡ d¡¡}| ¡ }||fS )z³Return variables required to compute Mean Squared Log Error. Checks for same shape of tensors.

    Args:
        preds: Predicted tensor
        target: Ground truth tensor

    é   )r   ÚtorchÚsumÚpowÚlog1pZnumel©r   r   Úsum_squared_log_errorÚn_obs© r   ús/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchmetrics/functional/regression/log_mse.pyÚ_mean_squared_log_error_update   s    
"r   )r   r   r   c                 C   s   | | S )a  Compute Mean Squared Log Error.

    Args:
        sum_squared_log_error:
            Sum of square of log errors over all observations ``(log error = log(target) - log(prediction))``
        n_obs: Number of predictions or observations

    Example:
        >>> preds = torch.tensor([0., 1, 2, 3])
        >>> target = torch.tensor([0., 1, 2, 2])
        >>> sum_squared_log_error, n_obs = _mean_squared_log_error_update(preds, target)
        >>> _mean_squared_log_error_compute(sum_squared_log_error, n_obs)
        tensor(0.0207)

    r   )r   r   r   r   r   Ú_mean_squared_log_error_compute$   s    r   c                 C   s   t | |ƒ\}}t||ƒS )aà  Compute mean squared log error.

    Args:
        preds: estimated labels
        target: ground truth labels

    Return:
        Tensor with RMSLE

    Example:
        >>> from torchmetrics.functional.regression import mean_squared_log_error
        >>> x = torch.tensor([0., 1, 2, 3])
        >>> y = torch.tensor([0., 1, 2, 2])
        >>> mean_squared_log_error(x, y)
        tensor(0.0207)

    .. note::
        Half precision is only support on GPU for this metric

    )r   r   r   r   r   r   Úmean_squared_log_error7   s    r   )Útypingr   r   r
   r   Ztorchmetrics.utilities.checksr   Úintr   r   r   r   r   r   r   Ú<module>   s   