o
    .wi                     @   s   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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	                 C   s   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|	 | d|
 |  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_s r   ^/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/torchmetrics/functional/image/qnr.pyr      s   /)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   r   r    <module>   sF   	
