§
    ’©ºj�  ã                   ó®   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ esdgZ	 	 	 	 	 	 ddedededee         dededededed         defd„ZdS )é    )ÚOptional)ÚTensor)ÚLiteral)Úspectral_distortion_index)Úspatial_distortion_index)Ú_TORCHVISION_AVAILABLEÚquality_with_no_referenceNé   é   Úelementwise_meanÚpredsÚmsÚpanÚpan_lrÚalphaÚbetaÚ
norm_orderÚwindow_sizeÚ	reduction)r   ÚsumÚnoneÚreturnc	           	      óF  — t          |t          t          f¦  «        r|dk     rt          d|› d�¦  «        ‚t          |t          t          f¦  «        r|dk     rt          d|› d�¦  «        ‚t	          | |||¦  «        }	t          | ||||||¦  «        }
d|	z
  |z  d|
z
  |z  z  S )a`  Calculate `Quality with No Reference`_ (QualityWithNoReference_) also known as QNR.

    Metric is used to compare the joint spectral and spatial distortion between two images.

    Args:
        preds: High resolution multispectral image.
        ms: Low resolution multispectral image.
        pan: High resolution panchromatic image.
        pan_lr: Low resolution panchromatic image.
        alpha: Relevance of spectral distortion.
        beta: Relevance of spatial distortion.
        norm_order: Order of the norm applied on the difference.
        window_size: Window size of the filter applied to degrade the high resolution panchromatic image.
        reduction: A method to reduce metric score over labels.

            - ``'elementwise_mean'``: takes the mean (default)
            - ``'sum'``: takes the sum
            - ``'none'``: no reduction will be applied

    Return:
        Tensor with QualityWithNoReference score

    Raises:
        ValueError:
            If ``alpha`` or ``beta`` is not a non-negative real number.

    Example:
        >>> from torch import rand
        >>> from torchmetrics.functional.image import quality_with_no_reference
        >>> preds = rand([16, 3, 32, 32])
        >>> ms = rand([16, 3, 16, 16])
        >>> pan = rand([16, 3, 32, 32])
        >>> quality_with_no_reference(preds, ms, pan)
        tensor(0.9694)

    r   z>Expected `alpha` to be a non-negative real number. Got alpha: ú.z<Expected `beta` to be a non-negative real number. Got beta: r
   )Ú
isinstanceÚintÚfloatÚ
ValueErrorr   r   )r   r   r   r   r   r   r   r   r   Úd_lambdaÚd_ss              úq/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/torchmetrics/functional/image/qnr.pyr	   r	      sÃ   € õ^ �e�c¥5˜\Ñ*Ô*ð d¨e°aªi¨iÝÐbÐZ_ÐbÐbÐbÑcÔcÐcÝ�d�S¥%˜LÑ)Ô)ð a¨T°AªX¨XÝÐ_ÐX\Ð_Ð_Ð_Ñ`Ô`Ð`Ý(¨°°JÀ	ÑJÔJ€HÝ
" 5¨"¨c°6¸:À{ÐT]Ñ
^Ô
^€CØ�‰L˜UÑ" a¨#¡g°$Ñ%6Ñ6Ð6ó    )Nr
   r
   r
   r   r   )Útypingr   Útorchr   Útyping_extensionsr   Ú&torchmetrics.functional.image.d_lambdar   Ú!torchmetrics.functional.image.d_sr   Útorchmetrics.utilities.importsr   Ú__doctest_skip__r   r   r	   © r"   r!   ú<module>r+      s&  ðð Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à LÐ LÐ LÐ LÐ LÐ LØ FÐ FÐ FÐ FÐ FÐ FØ AÐ AÐ AÐ AÐ AÐ Aàð 5Ø3Ð4Ðð  $ØØØØØ<Nð57ð 57Øð57àð57ð 
ð57ð �VÔð	57ð
 ð57ð ð57ð ð57ð ð57ð Ð8Ô9ð57ð ð57ð 57ð 57ð 57ð 57ð 57r"   