o
    ߥi                     @   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	 e	j
eejdG dd	 d	eZd
S )    )Dict)Metrics)default_group   )Metric)METRICS)	group_keymodule_namec                       sT   e Zd ZdZ fddZdedefddZdd	 ZdddZdd Z	dd Z
  ZS )PredictionSavingWrapperz{The wrapper to save predictions to file.
    Args:
        saving_fn: The saving_fn used to save predictions to files.
    c                    s   t  jdi | || _d S )N )super__init__	saving_fn)selfr   kwargs	__class__r   `/home/ubuntu/.local/lib/python3.10/site-packages/modelscope/metrics/prediction_saving_wrapper.pyr      s   
z PredictionSavingWrapper.__init__outputsinputsc                 C   s   |  || d S N)r   )r   r   r   r   r   r   add   s   zPredictionSavingWrapper.addc                 C   s   i S r   r   r   r   r   r   evaluate      z PredictionSavingWrapper.evaluateotherc                 C      d S r   r   )r   r   r   r   r   merge   r   zPredictionSavingWrapper.mergec                 C   r   r   r   r   r   r   r   __getstate__    r   z$PredictionSavingWrapper.__getstate__c                 C   r   r   r   )r   stater   r   r   __setstate__#   r   z$PredictionSavingWrapper.__setstate__)r   r
   )__name__
__module____qualname____doc__r   r   r   r   r   r   r    __classcell__r   r   r   r   r
      s    
r
   N)typingr   modelscope.metainfor   modelscope.utils.registryr   baser   builderr   register_moduleprediction_saving_wrapperr
   r   r   r   r   <module>   s   