o
    ß¥µi®  ã                   @   s0   d dl mZmZ d dlmZ G dd„ deƒZdS )é    )ÚABCÚabstractmethod)ÚDictc                   @   sH   e Zd ZdZdd„ Zededefdd„ƒZedd	„ ƒZeddd„ƒZ	dS )ÚMetriczÙThe metric base class for computing metrics.

    The subclasses can either compute a single metric like 'accuracy', or compute the
    complex metrics for a specific task with or without other Metric subclasses.
    c                 O   s   d S )N© )ÚselfÚargsÚkwargsr   r   úK/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/metrics/base.pyÚ__init__   s   zMetric.__init__ÚoutputsÚinputsc                 C   ó   dS )a3   Append logits and labels within an eval loop.

        Will be called after every batch finished to gather the model predictions and the labels.

        Args:
            outputs: The model prediction outputs.
            inputs: The mini batch inputs from the dataloader.

        Returns: None

        Nr   )r   r   r   r   r   r
   Úadd   s   z
Metric.addc                 C   r   )z²Evaluate the metrics after the eval finished.

        Will be called after the whole validation finished.

        Returns: The actual metric dict with standard names.

        Nr   )r   r   r   r
   Úevaluate   s   	zMetric.evaluateÚotherc                 C   r   )a*   When using data parallel, the data required for different metric calculations

        are stored in their respective Metric classes,

        and we need to merge these data to uniformly calculate metric.

        Args:
            other: Another Metric instance.

        Returns: None

        Nr   )r   r   r   r   r
   Úmerge*   s   zMetric.mergeN)r   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r
   r      s    

r   N)Úabcr   r   Útypingr   r   r   r   r   r
   Ú<module>   s   