
    i                         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y)    )Optional)Tensor)Literal)spectral_distortion_index)spatial_distortion_index)_TORCHVISION_AVAILABLEquality_with_no_referenceNpredsmspanpan_lralphabeta
norm_orderwindow_size	reduction)elementwise_meansumnonereturnc	           	      
   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:    )
isinstanceintfloat
ValueErrorr   r   )r
   r   r   r   r   r   r   r   r   d_lambdad_ss              v/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torchmetrics/functional/image/qnr.pyr	   r	      s    ^ ec5\*eaiYZ_Y``abccdS%L)TAXWX\W]]^_``(J	JH
"5"c6:{T]
^CLU"a#g$%666    )Nr   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 F A34  $<N575757 
57 V	57
 57 57 57 57 8957 57r!   