
    l$es              	          d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZ ddlmZ  ee          Ze G d d	                      Ze G d
 d                      Z G d de          Z G d de          Z G d de          Zdeeeef                  de
eee         f         fdZd Zdedee         deeeef                  fdZdS )    N)defaultdict)	dataclass)AnyDictListOptionalTupleUnion)	yaml_dump   )
get_loggerc                      e Zd ZU dZeed<   eed<   eed<   eed<   eed<   dZee         ed<   dZ	ee         ed	<   dZ
ee         ed
<   dZee         ed<   dZeeeef                  ed<   dZee         ed<   dZee         ed<   dZeeeef                  ed<   dZee         ed<   dZee         ed<   edefd            Zdd defdZdS )
EvalResultu
  
    Flattened representation of individual evaluation results found in model-index of Model Cards.

    For more information on the model-index spec, see https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1.

    Args:
        task_type (`str`):
            The task identifier. Example: "image-classification".
        dataset_type (`str`):
            The dataset identifier. Example: "common_voice". Use dataset id from https://hf.co/datasets.
        dataset_name (`str`):
            A pretty name for the dataset. Example: "Common Voice (French)".
        metric_type (`str`):
            The metric identifier. Example: "wer". Use metric id from https://hf.co/metrics.
        metric_value (`Any`):
            The metric value. Example: 0.9 or "20.0 ± 1.2".
        task_name (`str`, *optional*):
            A pretty name for the task. Example: "Speech Recognition".
        dataset_config (`str`, *optional*):
            The name of the dataset configuration used in `load_dataset()`.
            Example: fr in `load_dataset("common_voice", "fr")`. See the `datasets` docs for more info:
            https://hf.co/docs/datasets/package_reference/loading_methods#datasets.load_dataset.name
        dataset_split (`str`, *optional*):
            The split used in `load_dataset()`. Example: "test".
        dataset_revision (`str`, *optional*):
            The revision (AKA Git Sha) of the dataset used in `load_dataset()`.
            Example: 5503434ddd753f426f4b38109466949a1217c2bb
        dataset_args (`Dict[str, Any]`, *optional*):
            The arguments passed during `Metric.compute()`. Example for `bleu`: `{"max_order": 4}`
        metric_name (`str`, *optional*):
            A pretty name for the metric. Example: "Test WER".
        metric_config (`str`, *optional*):
            The name of the metric configuration used in `load_metric()`.
            Example: bleurt-large-512 in `load_metric("bleurt", "bleurt-large-512")`.
            See the `datasets` docs for more info: https://huggingface.co/docs/datasets/v2.1.0/en/loading#load-configurations
        metric_args (`Dict[str, Any]`, *optional*):
            The arguments passed during `Metric.compute()`. Example for `bleu`: max_order: 4
        verified (`bool`, *optional*):
            Indicates whether the metrics originate from Hugging Face's [evaluation service](https://huggingface.co/spaces/autoevaluate/model-evaluator) or not. Automatically computed by Hugging Face, do not set.
        verify_token (`str`, *optional*):
            A JSON Web Token that is used to verify whether the metrics originate from Hugging Face's [evaluation service](https://huggingface.co/spaces/autoevaluate/model-evaluator) or not.
    	task_typedataset_typedataset_namemetric_typemetric_valueN	task_namedataset_configdataset_splitdataset_revisiondataset_argsmetric_namemetric_configmetric_argsverifiedverify_tokenreturnc                 B    | j         | j        | j        | j        | j        fS )z9Returns a tuple that uniquely identifies this evaluation.)r   r   r   r   r   selfs    =lib/python3.11/site-packages/huggingface_hub/repocard_data.pyunique_identifierzEvalResult.unique_identifier|   s+     N!
 	
    otherc                     | j                                         D ]7\  }}|dk    r|dk    r%t          | |          t          ||          k    r dS 8dS )zx
        Return True if `self` and `other` describe exactly the same metric but with a
        different value.
        r   r   FT)__dict__itemsgetattr)r"   r&   key_s       r#   is_equal_except_valuez EvalResult.is_equal_except_value   sk    
 m))++ 	 	FCn$$ n$$s););wuc?R?R)R)Ruutr%   )__name__
__module____qualname____doc__str__annotations__r   r   r   r   r   r   r   r   r   r   r   r   boolr   propertytupler$   r-    r%   r#   r   r      s        ) )^ NNN      $Ix}### %)NHSM((( $(M8C=''' '+hsm*** .2L(4S>*111 "&K#%%%
 $(M8C=''' -1K$sCx.)000  $Hhtn### #'L(3-&&&
5 
 
 
 X
< D      r%   r   c                       e Zd ZdZddefdZdeeef         fdZ	d Z
ddefd	Zd
 ZddededefdZddededefdZdedefdZdededdfdZdedefdZdS )CardDataa  Structure containing metadata from a RepoCard.

    [`CardData`] is the parent class of [`ModelCardData`] and [`DatasetCardData`].

    Metadata can be exported as a dictionary or YAML. Export can be customized to alter the representation of the data
    (example: flatten evaluation results). `CardData` behaves as a dictionary (can get, pop, set values) but do not
    inherit from `dict` to allow this export step.
    Fignore_metadata_errorsc                 :    | j                             |           d S N)r(   update)r"   r:   kwargss      r#   __init__zCardData.__init__   s    V$$$$$r%   r   c                 |    t          j        | j                  }|                     |           t	          |          S )zConverts CardData to a dict.

        Returns:
            `dict`: CardData represented as a dictionary ready to be dumped to a YAML
            block for inclusion in a README.md file.
        )copydeepcopyr(   _to_dict_remove_noner"   	data_dicts     r#   to_dictzCardData.to_dict   s5     M$-00	i   I&&&r%   c                     dS )zUse this method in child classes to alter the dict representation of the data. Alter the dict in-place.

        Args:
            data_dict (`dict`): The raw dict representation of the card data.
        Nr7   rE   s     r#   rC   zCardData._to_dict   s	     	r%   Nc                 n    t          |                                 d|                                          S )a
  Dumps CardData to a YAML block for inclusion in a README.md file.

        Args:
            line_break (str, *optional*):
                The line break to use when dumping to yaml.

        Returns:
            `str`: CardData represented as a YAML block.
        F)	sort_keys
line_break)r   rG   strip)r"   rK   s     r#   to_yamlzCardData.to_yaml   s-     5ZPPPVVXXXr%   c                 *    |                                  S r<   )rM   r!   s    r#   __repr__zCardData.__repr__   s    ||~~r%   r+   defaultc                 8    | j                             ||          S z#Get value for a given metadata key.)r(   getr"   r+   rP   s      r#   rS   zCardData.get       }  g...r%   c                 8    | j                             ||          S )z#Pop value for a given metadata key.)r(   poprT   s      r#   rW   zCardData.pop   rU   r%   c                     | j         |         S rR   r(   r"   r+   s     r#   __getitem__zCardData.__getitem__   s    }S!!r%   valuec                     || j         |<   dS )z#Set value for a given metadata key.NrY   )r"   r+   r\   s      r#   __setitem__zCardData.__setitem__   s    "cr%   c                     || j         v S )z%Check if a given metadata key is set.rY   rZ   s     r#   __contains__zCardData.__contains__   s    dm##r%   )Fr<   )r.   r/   r0   r1   r4   r?   r   r2   r   rG   rC   rM   rO   rS   rW   r[   r^   r`   r7   r%   r#   r9   r9      sn        % %t % % % %
'c3h 
' 
' 
' 
'  
Y 
Y# 
Y 
Y 
Y 
Y  / /s /S /C / / / // /s /S /C / / / /"s "s " " " "#s #3 #4 # # # #$ $ $ $ $ $ $ $r%   r9   c                       e Zd ZdZdddddddddd	deeeee         f                  dee         dee         deee                  d	eee                  d
eee                  deee                  dee         de	f fdZ
d Z xZS )ModelCardDataa  Model Card Metadata that is used by Hugging Face Hub when included at the top of your README.md

    Args:
        language (`Union[str, List[str]]`, *optional*):
            Language of model's training data or metadata. It must be an ISO 639-1, 639-2 or
            639-3 code (two/three letters), or a special value like "code", "multilingual". Defaults to `None`.
        license (`str`, *optional*):
            License of this model. Example: apache-2.0 or any license from
            https://huggingface.co/docs/hub/repositories-licenses. Defaults to None.
        library_name (`str`, *optional*):
            Name of library used by this model. Example: keras or any library from
            https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Libraries.ts.
            Defaults to None.
        tags (`List[str]`, *optional*):
            List of tags to add to your model that can be used when filtering on the Hugging
            Face Hub. Defaults to None.
        datasets (`List[str]`, *optional*):
            List of datasets that were used to train this model. Should be a dataset ID
            found on https://hf.co/datasets. Defaults to None.
        metrics (`List[str]`, *optional*):
            List of metrics used to evaluate this model. Should be a metric name that can be found
            at https://hf.co/metrics. Example: 'accuracy'. Defaults to None.
        eval_results (`Union[List[EvalResult], EvalResult]`, *optional*):
            List of `huggingface_hub.EvalResult` that define evaluation results of the model. If provided,
            `model_name` is used to as a name on PapersWithCode's leaderboards. Defaults to `None`.
        model_name (`str`, *optional*):
            A name for this model. It is used along with
            `eval_results` to construct the `model-index` within the card's metadata. The name
            you supply here is what will be used on PapersWithCode's leaderboards. If None is provided
            then the repo name is used as a default. Defaults to None.
        ignore_metadata_errors (`str`):
            If True, errors while parsing the metadata section will be ignored. Some information might be lost during
            the process. Use it at your own risk.
        kwargs (`dict`, *optional*):
            Additional metadata that will be added to the model card. Defaults to None.

    Example:
        ```python
        >>> from huggingface_hub import ModelCardData
        >>> card_data = ModelCardData(
        ...     language="en",
        ...     license="mit",
        ...     library_name="timm",
        ...     tags=['image-classification', 'resnet'],
        ... )
        >>> card_data.to_dict()
        {'language': 'en', 'license': 'mit', 'library_name': 'timm', 'tags': ['image-classification', 'resnet']}

        ```
    NF)	languagelicenselibrary_nametagsdatasetsmetricseval_results
model_namer:   rc   rd   re   rf   rg   rh   ri   rj   r:   c       	         >   || _         || _        || _        || _        || _        || _        || _        || _        |
                    dd           }|ri	 t          |          \  }}|| _        || _        nG# t          $ r:}|	rt                              d           nt          d| d          Y d }~nd }~ww xY w t                      j        di |
 | j        r@t!          | j                  t"          k    r| j        g| _        | j        t          d          d S d S )Nmodel-indexz<Invalid model-index. Not loading eval results into CardData.z=Invalid `model_index` in metadata cannot be parsed: KeyError z. Pass `ignore_metadata_errors=True` to ignore this error while loading a Model Card. Warning: some information will be lost. Use it at your own risk.z7Passing `eval_results` requires `model_name` to be set.r7   )rc   rd   re   rf   rg   rh   ri   rj   rW   model_index_to_eval_resultsKeyErrorloggerwarning
ValueErrorsuperr?   typer   )r"   rc   rd   re   rf   rg   rh   ri   rj   r:   r>   model_indexerror	__class__s                r#   r?   zModelCardData.__init__  sy    !(	 ($jj55 	+F{+S+S(
L",$0!!   ) NN#abbbb$SX] S S S   cbbbb 	""6""" 	\D%&&*44%)%6$7!& !Z[[[		\ 	\ '&s    A4 4
B8>0B33B8c                 ^    | j         %t          | j        | j                   |d<   |d= |d= dS dS )z[Format the internal data dict. In this case, we convert eval results to a valid model indexNrl   ri   rj   )ri   eval_results_to_model_indexrj   rE   s     r#   rC   zModelCardData._to_dict?  sB    ('B4?TXTe'f'fIm$.)9\+B+B+B )(r%   )r.   r/   r0   r1   r   r
   r2   r   r   r4   r?   rC   __classcell__rv   s   @r#   rb   rb      s4       1 1l 59!%&*$((,'+37$(',-\ -\ -\ 5d3i01-\ #	-\
 sm-\ tCy!-\ 49%-\ $s)$-\ tJ/0-\ SM-\ !%-\ -\ -\ -\ -\ -\^C C C C C C Cr%   rb   c                   &    e Zd ZdZddddddddddddddddeeeee         f                  deeeee         f                  deeeee         f                  deeeee         f                  d	eeeee         f                  d
eeeee         f                  deee                  deeeee         f                  deeeee         f                  dee         dee         dee         deeeee         f                  de	f fdZ
d Z xZS )DatasetCardDataa	  Dataset Card Metadata that is used by Hugging Face Hub when included at the top of your README.md

    Args:
        language (`List[str]`, *optional*):
            Language of dataset's data or metadata. It must be an ISO 639-1, 639-2 or
            639-3 code (two/three letters), or a special value like "code", "multilingual".
        license (`Union[str, List[str]]`, *optional*):
            License(s) of this dataset. Example: apache-2.0 or any license from
            https://huggingface.co/docs/hub/repositories-licenses.
        annotations_creators (`Union[str, List[str]]`, *optional*):
            How the annotations for the dataset were created.
            Options are: 'found', 'crowdsourced', 'expert-generated', 'machine-generated', 'no-annotation', 'other'.
        language_creators (`Union[str, List[str]]`, *optional*):
            How the text-based data in the dataset was created.
            Options are: 'found', 'crowdsourced', 'expert-generated', 'machine-generated', 'other'
        multilinguality (`Union[str, List[str]]`, *optional*):
            Whether the dataset is multilingual.
            Options are: 'monolingual', 'multilingual', 'translation', 'other'.
        size_categories (`Union[str, List[str]]`, *optional*):
            The number of examples in the dataset. Options are: 'n<1K', '1K<n<10K', '10K<n<100K',
            '100K<n<1M', '1M<n<10M', '10M<n<100M', '100M<n<1B', '1B<n<10B', '10B<n<100B', '100B<n<1T', 'n>1T', and 'other'.
        source_datasets (`List[str]]`, *optional*):
            Indicates whether the dataset is an original dataset or extended from another existing dataset.
            Options are: 'original' and 'extended'.
        task_categories (`Union[str, List[str]]`, *optional*):
            What categories of task does the dataset support?
        task_ids (`Union[str, List[str]]`, *optional*):
            What specific tasks does the dataset support?
        paperswithcode_id (`str`, *optional*):
            ID of the dataset on PapersWithCode.
        pretty_name (`str`, *optional*):
            A more human-readable name for the dataset. (ex. "Cats vs. Dogs")
        train_eval_index (`Dict`, *optional*):
            A dictionary that describes the necessary spec for doing evaluation on the Hub.
            If not provided, it will be gathered from the 'train-eval-index' key of the kwargs.
        config_names (`Union[str, List[str]]`, *optional*):
            A list of the available dataset configs for the dataset.
    NF)rc   rd   annotations_creatorslanguage_creatorsmultilingualitysize_categoriessource_datasetstask_categoriestask_idspaperswithcode_idpretty_nametrain_eval_indexconfig_namesr:   rc   rd   r}   r~   r   r   r   r   r   r   r   r   r   r:   c                   || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        |p|                    dd           | _         t                      j        di | d S )Ntrain-eval-indexr7   )r}   r~   rc   rd   r   r   r   r   r   r   r   r   rW   r   rr   r?   )r"   rc   rd   r}   r~   r   r   r   r   r   r   r   r   r   r:   r>   rv   s                   r#   r?   zDatasetCardData.__init__n  s    & %9!!2 .... !2&( !1 XFJJ?QSW4X4X""6"""""r%   c                 6    |                     d          |d<   d S )Nr   r   )rW   rE   s     r#   rC   zDatasetCardData._to_dict  s     (16H(I(I	$%%%r%   )r.   r/   r0   r1   r   r
   r2   r   r   r4   r?   rC   ry   rz   s   @r#   r|   r|   F  s       % %T 5937@D=A;?;?/3;?48+/%)+/8<',!"# "# "# 5d3i01"# %T#Y/0	"#
 'uS$s)^'<="# $E#tCy.$9:"# "%T#Y"78"# "%T#Y"78"# "$s),"# "%T#Y"78"# 5d3i01"# $C="# c]"# #4."# uS$s)^45"#  !%!"# "# "# "# "# "#HJ J J J J J Jr%   r|   c                       e Zd ZdZddddddddddddddee         dee         dee         dee         d	ee         d
ee         dee         dee         deee                  deee                  deee                  def fdZ	 xZ
S )SpaceCardDataa	  Space Card Metadata that is used by Hugging Face Hub when included at the top of your README.md

    To get an exhaustive reference of Spaces configuration, please visit https://huggingface.co/docs/hub/spaces-config-reference#spaces-configuration-reference.

    Args:
        title (`str`, *optional*)
            Title of the Space.
        sdk (`str`, *optional*)
            SDK of the Space (one of `gradio`, `streamlit`, `docker`, or `static`).
        sdk_version (`str`, *optional*)
            Version of the used SDK (if Gradio/Streamlit sdk).
        python_version (`str`, *optional*)
            Python version used in the Space (if Gradio/Streamlit sdk).
        app_file (`str`, *optional*)
            Path to your main application file (which contains either gradio or streamlit Python code, or static html code).
            Path is relative to the root of the repository.
        app_port (`str`, *optional*)
            Port on which your application is running. Used only if sdk is `docker`.
        license (`str`, *optional*)
            License of this model. Example: apache-2.0 or any license from
            https://huggingface.co/docs/hub/repositories-licenses.
        duplicated_from (`str`, *optional*)
            ID of the original Space if this is a duplicated Space.
        models (List[`str`], *optional*)
            List of models related to this Space. Should be a dataset ID found on https://hf.co/models.
        datasets (`List[str]`, *optional*)
            List of datasets related to this Space. Should be a dataset ID found on https://hf.co/datasets.
        tags (`List[str]`, *optional*)
            List of tags to add to your Space that can be used when filtering on the Hub.
        ignore_metadata_errors (`str`):
            If True, errors while parsing the metadata section will be ignored. Some information might be lost during
            the process. Use it at your own risk.
        kwargs (`dict`, *optional*):
            Additional metadata that will be added to the space card.

    Example:
        ```python
        >>> from huggingface_hub import SpaceCardData
        >>> card_data = SpaceCardData(
        ...     title="Dreambooth Training",
        ...     license="mit",
        ...     sdk="gradio",
        ...     duplicated_from="multimodalart/dreambooth-training"
        ... )
        >>> card_data.to_dict()
        {'title': 'Dreambooth Training', 'sdk': 'gradio', 'license': 'mit', 'duplicated_from': 'multimodalart/dreambooth-training'}
        ```
    NF)titlesdksdk_versionpython_versionapp_fileapp_portrd   duplicated_frommodelsrg   rf   r:   r   r   r   r   r   r   rd   r   r   rg   rf   r:   c                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
         t                      j        di | d S )Nr7   )r   r   r   r   r   r   rd   r   r   rg   rf   rr   r?   )r"   r   r   r   r   r   r   rd   r   r   rg   rf   r:   r>   rv   s                 r#   r?   zSpaceCardData.__init__  sx    " 
&,  . 	""6"""""r%   )r.   r/   r0   r1   r   r2   intr   r4   r?   ry   rz   s   @r#   r   r     s+       / /h  $!%)(,"&"&!%)-&*(,$(',# # # }# c]	#
 c]# !# 3-# 3-# ## "## c## 49%# tCy!# !%# # # # # # # # # #r%   r   rt   r   c                    g }| D ]}|d         }|d         }|D ]k}|d         d         }|d                              d          }|d         d         }|d         d         }	|d                              d          }
|d                              d          }|d                              d          }|d                              d	          }|d
         D ]}|d         }|d         }|                     d          }|                     d	          }|                     d          }|                     d          }|                     d          }t          |||	||||
||||||||          }|                    |           m||fS )a  Takes in a model index and returns the model name and a list of `huggingface_hub.EvalResult` objects.

    A detailed spec of the model index can be found here:
    https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1

    Args:
        model_index (`List[Dict[str, Any]]`):
            A model index data structure, likely coming from a README.md file on the
            Hugging Face Hub.

    Returns:
        model_name (`str`):
            The name of the model as found in the model index. This is used as the
            identifier for the model on leaderboards like PapersWithCode.
        eval_results (`List[EvalResult]`):
            A list of `huggingface_hub.EvalResult` objects containing the metrics
            reported in the provided model_index.

    Example:
        ```python
        >>> from huggingface_hub.repocard_data import model_index_to_eval_results
        >>> # Define a minimal model index
        >>> model_index = [
        ...     {
        ...         "name": "my-cool-model",
        ...         "results": [
        ...             {
        ...                 "task": {
        ...                     "type": "image-classification"
        ...                 },
        ...                 "dataset": {
        ...                     "type": "beans",
        ...                     "name": "Beans"
        ...                 },
        ...                 "metrics": [
        ...                     {
        ...                         "type": "accuracy",
        ...                         "value": 0.9
        ...                     }
        ...                 ]
        ...             }
        ...         ]
        ...     }
        ... ]
        >>> model_name, eval_results = model_index_to_eval_results(model_index)
        >>> model_name
        'my-cool-model'
        >>> eval_results[0].task_type
        'image-classification'
        >>> eval_results[0].metric_type
        'accuracy'

        ```
    nameresultstaskrs   datasetconfigsplitrevisionargsrh   r\   r   verifyToken)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rS   r   append)rt   ri   elemr   r   resultr   r   r   r   r   r   r   r   metricr   r   r   r   r   r   r   eval_results                          r#   rm   rm     s   p L '1 '1F|y/ $	1 $	1Fvv.Iv**622I!),V4L!),V4L#I.228<<N"9-11'::M%i044Z@@!),0088L + 1 1$Vn%g$jj00$jj00 &

8 4 4!::j11%zz-88('!-!- +!-'#1"/%5!- + +"/%!-  " ##K000051$	1J r%   c                     t          | t          t          t          f          r" t	          |           d | D                       S t          | t
                    r4 t	          |           d |                                 D                       S | S )zk
    Recursively remove `None` values from a dict. Borrowed from: https://stackoverflow.com/a/20558778
    c              3   8   K   | ]}|t          |          V  d S r<   rD   ).0xs     r#   	<genexpr>z_remove_none.<locals>.<genexpr>P  s(      GGQaGGr%   c              3   `   K   | ])\  }}||	t          |          t          |          fV  *d S r<   r   )r   kvs      r#   r   z_remove_none.<locals>.<genexpr>R  sC      ww1WXWdijiv,q//<??;ivivivivwwr%   )
isinstancelistr6   setrs   dictr)   )objs    r#   rD   rD   K  s     #eS)** tCyyGG#GGGGGG	C		 tCyyww		wwwwww
r%   rj   ri   c           	         t          t                    }|D ]"}||j                                     |           #g }|                                D ]a}|d         }|j        |j        d|j        |j        |j	        |j
        |j        |j        dd |D             d}|                    |           b| |dg}t          |          S )a  Takes in given model name and list of `huggingface_hub.EvalResult` and returns a
    valid model-index that will be compatible with the format expected by the
    Hugging Face Hub.

    Args:
        model_name (`str`):
            Name of the model (ex. "my-cool-model"). This is used as the identifier
            for the model on leaderboards like PapersWithCode.
        eval_results (`List[EvalResult]`):
            List of `huggingface_hub.EvalResult` objects containing the metrics to be
            reported in the model-index.

    Returns:
        model_index (`List[Dict[str, Any]]`): The eval_results converted to a model-index.

    Example:
        ```python
        >>> from huggingface_hub.repocard_data import eval_results_to_model_index, EvalResult
        >>> # Define minimal eval_results
        >>> eval_results = [
        ...     EvalResult(
        ...         task_type="image-classification",  # Required
        ...         dataset_type="beans",  # Required
        ...         dataset_name="Beans",  # Required
        ...         metric_type="accuracy",  # Required
        ...         metric_value=0.9,  # Required
        ...     )
        ... ]
        >>> eval_results_to_model_index("my-cool-model", eval_results)
        [{'name': 'my-cool-model', 'results': [{'task': {'type': 'image-classification'}, 'dataset': {'name': 'Beans', 'type': 'beans'}, 'metrics': [{'type': 'accuracy', 'value': 0.9}]}]}]

        ```
    r   )rs   r   )r   rs   r   r   r   r   c           
      h    g | ]/}|j         |j        |j        |j        |j        |j        |j        d 0S ))rs   r\   r   r   r   r   r   )r   r   r   r   r   r   r   )r   r   s     r#   
<listcomp>z/eval_results_to_model_index.<locals>.<listcomp>  sZ         #.#0".$2". &#)#6   r%   )r   r   rh   )r   r   )r   r   r$   r   valuesr   r   r   r   r   r   r   r   rD   )	rj   ri   task_and_ds_types_mapr   model_index_datar   sample_resultdatart   s	            r#   rx   rx   W  s#   J (--# Q Qk;<CCKPPPP (//11 & &
 &/%/ 
 &2%2'6&4):%2   &  
 
4 	%%%% '	
 	
K $$$r%   )rA   collectionsr   dataclassesr   typingr   r   r   r   r	   r
   huggingface_hub.utilsr   utils.loggingr   r.   ro   r   r9   rb   r|   r   r2   rm   rD   rx   r7   r%   r#   <module>r      sd    # # # # # # ! ! ! ! ! ! : : : : : : : : : : : : : : : : + + + + + + % % % % % % 
H		 D D D D D D D DN B$ B$ B$ B$ B$ B$ B$ B$JgC gC gC gC gCH gC gC gCTMJ MJ MJ MJ MJh MJ MJ MJ`N# N# N# N# N#H N# N# N#baT$sCx.-A aeCQUV`QaLaFb a a a aH	 	 	R%C R%tJ?O R%TXY]^acf^fYgTh R% R% R% R% R% R%r%   