a
    dV                     @   s   d dl mZ d dlmZ G dd deZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZ	G dd deZ
dS )    )StrEnum)Literalc                       sF   e Zd ZdZeedddZed
eed d d fdd	Z	  Z
S )EnumStrz
Base Enum.returnc                   C   s   dS )NZTask r   r   r   e/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchmetrics/utilities/enums.py_name   s    zEnumStr._namekey)r
   valueany)r   sourcer   c                    s   zt  j|dd|d}W n\ tyx } zDdd | jD }td|   d| | d| d	|W Y d
}~n
d
}~0 0 | |S )a  Load from string.

        Raises:
            ValueError:
                If required value is not among the supported options.

        >>> class MyEnum(EnumStr):
        ...     a = "aaa"
        ...     b = "bbb"
        >>> MyEnum.from_str("a")
        <MyEnum.a: 'aaa'>
        >>> MyEnum.from_str("c")
        Traceback (most recent call last):
          ...
        ValueError: Invalid Task: expected one of ['a', 'b'], but got c.

        -_)r   c                 S   s   g | ]}|  qS r   )lower).0mr   r   r   
<listcomp>/       z$EnumStr.from_str.<locals>.<listcomp>zInvalid z: expected one of z
, but got .N)superfrom_strreplace
ValueError_member_names_r	   Z_allowed_matches)clsr   r   meerrZ_allowed_im	__class__r   r   r      s     zEnumStr.from_str)r
   )__name__
__module____qualname____doc__staticmethodstrr	   classmethodr   r   __classcell__r   r   r   r   r      s
   r   c                   @   s2   e Zd ZdZeedddZdZdZdZ	dZ
d	S )
DataTypezOEnum to represent data type.

    >>> "Binary" in list(DataType)
    True

    r   c                   C   s   dS )Nz	Data typer   r   r   r   r   r	   >   s    zDataType._namebinaryzmulti-labelzmulti-classzmulti-dim multi-classN)r    r!   r"   r#   r$   r%   r	   BINARY
MULTILABEL
MULTICLASSZMULTIDIM_MULTICLASSr   r   r   r   r(   6   s   r(   c                   @   s6   e Zd ZdZeedddZdZdZdZ	dZ
d	ZdS )
AverageMethodzEnum to represent average method.

    >>> None in list(AverageMethod)
    True
    >>> AverageMethod.NONE == None
    True
    >>> AverageMethod.NONE == 'none'
    True

    r   c                   C   s   dS )NzAverage methodr   r   r   r   r   r	   T   s    zAverageMethod._namemicromacroZweightedNZsamples)r    r!   r"   r#   r$   r%   r	   ZMICROZMACROZWEIGHTEDNONEZSAMPLESr   r   r   r   r-   H   s   r-   c                   @   s*   e Zd ZdZeedddZdZdZdS )MDMCAverageMethodz7Enum to represent multi-dim multi-class average method.r   c                   C   s   dS )NzMDMC Average methodr   r   r   r   r   r	   b   s    zMDMCAverageMethod._nameglobalZ
samplewiseN)	r    r!   r"   r#   r$   r%   r	   GLOBALZ
SAMPLEWISEr   r   r   r   r1   _   s
   r1   c                   @   s.   e Zd ZdZeedddZdZdZdZ	dS )	ClassificationTaskz}Enum to represent the different tasks in classification metrics.

    >>> "binary" in list(ClassificationTask)
    True

    r   c                   C   s   dS NZClassificationr   r   r   r   r   r	   r   s    zClassificationTask._namer)   
multiclass
multilabelN)
r    r!   r"   r#   r$   r%   r	   r*   r,   r+   r   r   r   r   r4   j   s   r4   c                   @   s*   e Zd ZdZeedddZdZdZdS )ClassificationTaskNoBinaryzEnum to represent the different tasks in classification metrics.

    >>> "binary" in list(ClassificationTaskNoBinary)
    False

    r   c                   C   s   dS r5   r   r   r   r   r   r	      s    z ClassificationTaskNoBinary._namer7   r6   N)	r    r!   r"   r#   r$   r%   r	   r+   r,   r   r   r   r   r8   {   s
   r8   c                   @   s*   e Zd ZdZeedddZdZdZdS )ClassificationTaskNoMultilabelzEnum to represent the different tasks in classification metrics.

    >>> "multilabel" in list(ClassificationTaskNoMultilabel)
    False

    r   c                   C   s   dS r5   r   r   r   r   r   r	      s    z$ClassificationTaskNoMultilabel._namer)   r6   N)	r    r!   r"   r#   r$   r%   r	   r*   r,   r   r   r   r   r9      s
   r9   N)Zlightning_utilities.core.enumsr   Ztyping_extensionsr   r   r(   r-   r1   r4   r8   r9   r   r   r   r   <module>   s   $