§
    }Štj†  ã            	       ó  — d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	  ej
        e¦  «        Ze G d„ d¦  «        ¦   «         Ze G d„ d	¦  «        ¦   «         Zd
eee         z  dz  dedz  dee         f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ee         dz  dee         dz  fd„ZdS )é    N)Údefaultdict)Ú	dataclass)ÚAny)ÚloggingÚ	yaml_dumpc                   óŠ  — 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dz  ed<   dZedz  ed	<   dZ	edz  ed
<   dZ
edz  ed<   dZeeef         dz  ed<   dZedz  ed<   dZedz  ed<   dZeeef         dz  ed<   dZedz  ed<   dZedz  ed<   dZedz  ed<   dZedz  ed<   edefd„¦   «         Zdd defd„Zd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.
        source_name (`str`, *optional*):
            The name of the source of the evaluation result. Example: "Open LLM Leaderboard".
        source_url (`str`, *optional*):
            The URL of the source of the evaluation result. Example: "https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard".
    Ú	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Úsource_nameÚ
source_urlÚreturnc                 óB   — | j         | j        | j        | j        | j        fS )z9Returns a tuple that uniquely identifies this evaluation.)r
   r   r   r   r   ©Úselfs    ú[/var/www/html/CA-Chatbot/venv/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×)Ò)Ñ+Ô+ð 	ð 	‰FˆC�Ø�nÒ$Ð$Øð �nÒ$Ð$­°°sÑ);Ô);½wÀuÈcÑ?RÔ?RÒ)RÐ)RØ�u�uøØˆtr!   c                 óD   — | j         �| j        €t          d¦  «        ‚d S d S )NzAIf `source_name` is provided, `source_url` must also be provided.)r   r   Ú
ValueErrorr   s    r   Ú__post_init__zEvalResult.__post_init__Ÿ   s/   € ØÔÐ'¨D¬OÐ,CÝÐ`ÑaÔaÐað (Ð'Ð,CÐ,Cr!   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   r   r   r   r   r   Údictr   r   r   r   Úboolr   r   r   ÚpropertyÚtupler    r)   r,   © r!   r   r	   r	      sà  € € € € € € ð-ð -ðf €N€N�Nð ÐÐÑð ÐÐÑð ÐÐÑð ÐÐÑð !€Iˆs�T‰zÐ Ð Ñ ð "&€N�C˜$‘JÐ%Ð%Ñ%ð !%€M�3˜‘:Ð$Ð$Ñ$ð $(Ð�c˜D‘jÐ'Ð'Ñ'ð +/€L�$�s˜C�x”. 4Ñ'Ð.Ð.Ñ.ð #€K��t‘Ð"Ð"Ñ"ð
 !%€M�3˜‘:Ð$Ð$Ñ$ð *.€K��c˜3�h” $Ñ&Ð-Ð-Ñ-ð !€Hˆd�T‰kÐ Ð Ñ ð  $€L�#˜‘*Ð#Ð#Ñ#ð #€K��t‘Ð"Ð"Ñ"ð "€J��d‘
Ð!Ð!Ñ!àð
 5ð 
ð 
ð 
ñ „Xð
ð¨<ð ¸Dð ð ð ð ðbð bð bð bð bð br!   r	   c                   óÈ   — e Zd ZdZddefd„Zd„ Zd„ Zddee	         dz  d	e	fd
„Z
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	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!   c                 óš   — t          j        | j        ¦  «        }|                      |¦  «         d„ |                     ¦   «         D ¦   «         S )zÂConverts 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.
        c                 ó   — i | ]
\  }}|®||“ŒS r<   r7   )Ú.0r'   Úvalues      r   ú
<dictcomp>z$CardData.to_dict.<locals>.<dictcomp>¼   s#   € ÐTÐTÐT™z˜s EÀ%ÐBS��UÐBSÐBSÐBSr!   )ÚcopyÚdeepcopyr$   Ú_to_dictr%   ©r   Ú	data_dicts     r   Úto_dictzCardData.to_dict²   sE   € õ ”M $¤-Ñ0Ô0ˆ	Ø�Š�iÑ Ô Ð ØTÐT¨Y¯_ª_Ñ->Ô->ÐTÑTÔTÐTr!   c                 ó   — dS )zÍUse 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   rH   s     r   rG   zCardData._to_dict¾   s	   € ð 	ˆr!   NÚoriginal_orderr   c                 óâ   ‡ ‡— |r6t          |¦  «        Šˆ fd„|ˆfd„‰ j        D ¦   «         z   D ¦   «         ‰ _        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.
            original_order (`list[str]`, *optional*):
                If provided, reorder the metadata fields to match this list before dumping.
                Any keys not in `original_order` are appended after the listed keys, preserving
                their existing relative order. Useful for round-tripping a YAML block without
                shuffling its keys.

        Returns:
            `str`: CardData represented as a YAML block.
        c                 ó>   •— i | ]}|‰j         v ¯|‰j         |         “ŒS r7   ©r$   )rB   Úkr   s     €r   rD   z$CardData.to_yaml.<locals>.<dictcomp>×   s9   ø€ ð ð ð àØ˜œÐ%Ð%ð �4”= Ô#à%Ð%Ð%r!   c                 ó   •— g | ]}|‰v¯|‘Œ	S r7   r7   )rB   rP   Úoriginal_order_sets     €r   ú
<listcomp>z$CardData.to_yaml.<locals>.<listcomp>Ù   s$   ø€ Ð*cÐ*cÐ*c°ÀqÐPbÐGbÐGb¨1ÐGbÐGbÐGbr!   F)Ú	sort_keysÚ
line_break)Úsetr$   r   rJ   Ústrip)r   rU   rL   rR   s   `  @r   Úto_yamlzCardData.to_yamlÆ   s�   øø€ ð ð 	Ý!$ ^Ñ!4Ô!4Ððð ð ð à'Ð*cÐ*cÐ*cÐ*c°d´mÐ*cÑ*cÔ*cÑcðñ ô ˆDŒMõ
 ˜Ÿš™œ°5ÀZÐPÑPÔP×VÒVÑXÔXÐXr!   c                 ó*   — t          | j        ¦  «        S r<   )Úreprr$   r   s    r   Ú__repr__zCardData.__repr__Þ   s   € Ý�D”MÑ"Ô"Ð"r!   c                 ó*   — |                       ¦   «         S r<   )rX   r   s    r   Ú__str__zCardData.__str__á   s   € Ø�|Š|‰~Œ~Ðr!   r'   Údefaultc                 óB   — | j                              |¦  «        }|€|n|S ©z#Get value for a given metadata key.)r$   Úget)r   r'   r^   rC   s       r   ra   zCardData.getä   s%   € à”×!Ò! #Ñ&Ô&ˆØ˜-ˆwˆw¨UÐ2r!   c                 ó8   — | j                              ||¦  «        S )z#Pop value for a given metadata key.)r$   Úpop)r   r'   r^   s      r   rc   zCardData.popé   s   € àŒ}× Ò   gÑ.Ô.Ð.r!   c                 ó   — | j         |         S r`   rO   ©r   r'   s     r   Ú__getitem__zCardData.__getitem__í   s   € àŒ}˜SÔ!Ð!r!   rC   c                 ó   — || j         |<   dS )z#Set value for a given metadata key.NrO   )r   r'   rC   s      r   Ú__setitem__zCardData.__setitem__ñ   s   € à"ˆŒ�cÑÐÐr!   c                 ó   — || j         v S )z%Check if a given metadata key is set.rO   re   s     r   Ú__contains__zCardData.__contains__õ   s   € à�d”mÐ#Ð#r!   c                 ó*   — t          | j        ¦  «        S )z'Return the number of metadata keys set.)Úlenr$   r   s    r   Ú__len__zCardData.__len__ù   s   € å�4”=Ñ!Ô!Ð!r!   )F)NNr<   )r-   r.   r/   r0   r4   r?   rJ   rG   Úlistr1   rX   r[   r]   r   ra   rc   rf   rh   rj   Úintrm   r7   r!   r   r9   r9   ¤   s™  € € € € € ðð ð%ð %¨tð %ð %ð %ð %ð
Uð 
Uð 
Uðð ð ðYð Y°t¸C´yÀ4Ñ7Gð YÐSVð Yð Yð Yð Yð0#ð #ð #ðð ð ð3ð 3�sð 3 Sð 3°Cð 3ð 3ð 3ð 3ð
/ð /�sð / Sð /°Cð /ð /ð /ð /ð"˜sð " sð "ð "ð "ð "ð#˜sð #¨3ð #°4ð #ð #ð #ð #ð$ ð $¨ð $ð $ð $ð $ð"˜ð "ð "ð "ð "ð "ð "r!   r9   Úeval_resultsÚ
model_namer   c                 óü   — | €g S t          | t          ¦  «        r| g} t          | t          ¦  «        rt          d„ | D ¦   «         ¦  «        s t	          dt          | ¦  «        › d�¦  «        ‚|€t	          d¦  «        ‚| S )Nc              3   ó@   K  — | ]}t          |t          ¦  «        V — Œd S r<   )Ú
isinstancer	   )rB   Úrs     r   ú	<genexpr>z)_validate_eval_results.<locals>.<genexpr>  s-   è è € Ð4eÐ4eÐSTµZÀÅ:Ñ5NÔ5NÐ4eÐ4eÐ4eÐ4eÐ4eÐ4er!   zM`eval_results` should be of type `EvalResult` or a list of `EvalResult`, got ú.z7Passing `eval_results` requires `model_name` to be set.)rt   r	   rn   Úallr+   Útype)rp   rq   s     r   Ú_validate_eval_resultsrz   þ   s    € ð ÐØˆ	Ý�,¥
Ñ+Ô+ð &Ø$�~ˆÝ�l¥DÑ)Ô)ð 
µÐ4eÐ4eÐXdÐ4eÑ4eÔ4eÑ1eÔ1eð 
ÝØqÕ\`ÐamÑ\nÔ\nÐqÐqÐqñ
ô 
ð 	
ð ÐÝÐRÑSÔSÐSØÐr!   c                   ó  ‡ — e Zd ZdZddddddddddddddœdeee         z  dz  deee         z  dz  dee         dz  deee         z  dz  d	edz  d
edz  dedz  dedz  dee         dz  dedz  dedz  dee         dz  defˆ fd„Zd„ Z	ˆ xZ
S )ÚModelCardDataaQ  Model Card Metadata that is used by Hugging Face Hub when included at the top of your README.md

    Args:
        base_model (`str` or `list[str]`, *optional*):
            The identifier of the base model from which the model derives. This is applicable for example if your model is a
            fine-tune or adapter of an existing model. The value must be the ID of a model on the Hub (or a list of IDs
            if your model derives from multiple models). Defaults to None.
        datasets (`Union[str, list[str]]`, *optional*):
            Dataset or list of datasets that were used to train this model. Should be a dataset ID
            found on https://hf.co/datasets. 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`.
        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`.
        library_name (`str`, *optional*):
            Name of library used by this model. Example: keras or any library from
            https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/model-libraries.ts.
            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.
        license_name (`str`, *optional*):
            Name of the license of this model. Defaults to None. To be used in conjunction with `license_link`.
            Common licenses (Apache-2.0, MIT, CC-BY-SA-4.0) do not need a name. In that case, use `license` instead.
        license_link (`str`, *optional*):
            Link to the license of this model. Defaults to None. To be used in conjunction with `license_name`.
            Common licenses (Apache-2.0, MIT, CC-BY-SA-4.0) do not need a link. In that case, use `license` instead.
        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.
        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.
        pipeline_tag (`str`, *optional*):
            The pipeline tag associated with the model. Example: "text-classification".
        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.
        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)Ú
base_modelÚdatasetsrp   ÚlanguageÚlibrary_nameÚlicenseÚlicense_nameÚlicense_linkÚmetricsrq   Úpipeline_tagÚtagsr:   r}   r~   rp   r   r€   r�   r‚   rƒ   r„   rq   r…   r†   r:   c                ó  •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        t          |¦  «        | _        |                     dd ¦  «        }|rx	 t          |¦  «        \  }
}|
| _	        || _        nV# t          t           f$ rB}|rt"                               d¦  «         nt'          d|j        › d|› d�¦  «        ‚Y d }~nd }~ww xY w t+          ¦   «         j        di |¤Ž | j        rn	 t/          | j        | j	        ¦  «        | _        d S # t0          $ r?}|rt"                               d|› d�¦  «         nt'          d|› �¦  «        |‚Y d }~d S d }~ww xY wd S )	Númodel-indexz<Invalid model-index. Not loading eval results into CardData.z4Invalid `model_index` in metadata cannot be parsed: ú 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.z!Failed to validate eval_results: z). Not loading eval results into CardData.r7   )r}   r~   rp   r   r€   r�   r‚   rƒ   r„   rq   r…   Ú_to_unique_listr†   rc   Úmodel_index_to_eval_resultsÚKeyErrorÚ	TypeErrorÚloggerÚwarningr+   Ú	__class__Úsuperr?   rz   Ú	Exception)r   r}   r~   rp   r   r€   r�   r‚   rƒ   r„   rq   r…   r†   r:   r>   Úmodel_indexÚerrorÚer�   s                     €r   r?   zModelCardData.__init__O  s  ø€ ð$ %ˆŒØ ˆŒØ(ˆÔØ ˆŒØ(ˆÔØˆŒØ(ˆÔØ(ˆÔØˆŒØ$ˆŒØ(ˆÔÝ# DÑ)Ô)ˆŒ	à—j’j °Ñ5Ô5ˆØð 	ðÝ+FÀ{Ñ+SÔ+SÑ(�
˜LØ",�”Ø$0�Ô!Ð!øÝ�iÐ(ð ð ð Ø)ð Ý—N’NÐ#aÑbÔbÐbÐbå$ðSÈuÌð Sð SÐafð Sð Sð Sñô ð ð cÐbÐbÐbÐbøøøøðøøøð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"àÔð 	UðUÝ$:¸4Ô;LÈdÌoÑ$^Ô$^�Ô!Ð!Ð!øÝð Uð Uð UØ)ð UÝ—N’NÐ#sÀqÐ#sÐ#sÐ#sÑtÔtÐtÐtå$Ð%LÈÐ%LÐ%LÑMÔMÐSTÐTð uÐtÐtÐtÐtÐtøøøøðUøøøð	Uð 	Us0   Á< B ÂC0Â.8C+Ã+C0ÄD5 Ä5
E>Ä?4E9Å9E>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 indexNrˆ   rp   rq   )rp   Úeval_results_to_model_indexrq   rH   s     r   rG   zModelCardData._to_dict‰  sB   € àÔÐ(Ý'BÀ4Ä?ÐTXÔTeÑ'fÔ'fˆI�mÑ$Ø˜.Ð)¨9°\Ð+BÐ+BÐ+Bð )Ð(r!   )r-   r.   r/   r0   r1   rn   r	   r4   r?   rG   Ú__classcell__©r�   s   @r   r|   r|     s„  ø€ € € € € ð=ð =ðD .2Ø+/Ø04Ø+/Ø#'Ø"Ø#'Ø#'Ø$(Ø!%Ø#'Ø!%Ø',ð8Uð 8Uð 8Uð ˜$˜sœ)‘O dÑ*ð8Uð ˜˜Sœ	‘/ DÑ(ð	8Uð
 ˜:Ô&¨Ñ-ð8Uð ˜˜Sœ	‘/ DÑ(ð8Uð ˜D‘jð8Uð �t‘ð8Uð ˜D‘jð8Uð ˜D‘jð8Uð �c”˜TÑ!ð8Uð ˜$‘Jð8Uð ˜D‘jð8Uð �3Œi˜$Ñð8Uð !%ð8Uð 8Uð 8Uð 8Uð 8Uð 8UðtCð Cð Cð Cð Cð Cð Cr!   r|   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         z  dz  deee         z  dz  deee         z  dz  deee         z  dz  d	eee         z  dz  d
eee         z  dz  dee         dz  deee         z  dz  deee         z  dz  dedz  dedz  dedz  deee         z  dz  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)r   r�   Úannotations_creatorsÚlanguage_creatorsÚmultilingualityÚsize_categoriesÚsource_datasetsÚtask_categoriesÚtask_idsÚpaperswithcode_idÚpretty_nameÚtrain_eval_indexÚconfig_namesr:   r   r�   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�   r   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¦   rc   r¥   r‘   r?   )r   r   r�   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   r¦   r:   r>   r�   s                   €r   r?   zDatasetCardData.__init__¸  s¤   ø€ ð& %9ˆÔ!Ø!2ˆÔØ ˆŒØˆŒØ.ˆÔØ.ˆÔØ.ˆÔØ.ˆÔØ ˆŒØ!2ˆÔØ&ˆÔØ(ˆÔð !1Ð X°F·J²JÐ?QÐSWÑ4XÔ4XˆÔØ�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Ð"Ð"r!   c                 ó6   — |                      d¦  «        |d<   d S )Nr¥   r¨   )rc   rH   s     r   rG   zDatasetCardData._to_dictÜ  s    € Ø(1¯ªÐ6HÑ(IÔ(Iˆ	Ð$Ñ%Ð%Ð%r!   )r-   r.   r/   r0   r1   rn   r3   r4   r?   rG   r˜   r™   s   @r   r›   r›   �  s«  ø€ € € € € ð%ð %ðT ,0Ø*.Ø7;Ø48Ø26Ø26Ø,0Ø26Ø+/Ø(,Ø"&Ø(,Ø/3Ø',ð!"#ð "#ð "#ð ˜˜Sœ	‘/ DÑ(ð"#ð �t˜C”y‘ 4Ñ'ð	"#ð
 " D¨¤I™o°Ñ4ð"#ð   c¤™?¨TÑ1ð"#ð ˜t Cœy™¨4Ñ/ð"#ð ˜t Cœy™¨4Ñ/ð"#ð ˜cœ TÑ)ð"#ð ˜t Cœy™¨4Ñ/ð"#ð ˜˜Sœ	‘/ DÑ(ð"#ð  ™:ð"#ð ˜4‘Zð"#ð  ™+ð"#ð ˜D œI‘o¨Ñ,ð"#ð  !%ð!"#ð "#ð "#ð "#ð "#ð "#ð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dz  dedz  dedz  dedz  d	edz  d
edz  dedz  dedz  dee         dz  dee         dz  dee         dz  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_portr�   Úduplicated_fromÚmodelsr~   r†   r:   r¬   r­   r®   r¯   r°   r±   r�   r²   r³   r~   r†   r:   c                óî   •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        t          |¦  «        | _         t          ¦   «         j        di |¤Ž d S )Nr7   )r¬   r­   r®   r¯   r°   r±   r�   r²   r³   r~   rŠ   r†   r‘   r?   )r   r¬   r­   r®   r¯   r°   r±   r�   r²   r³   r~   r†   r:   r>   r�   s                 €r   r?   zSpaceCardData.__init__  s€   ø€ ð" ˆŒ
ØˆŒØ&ˆÔØ,ˆÔØ ˆŒØ ˆŒØˆŒØ.ˆÔØˆŒØ ˆŒÝ# DÑ)Ô)ˆŒ	Ø�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Ð"Ð"r!   )
r-   r.   r/   r0   r1   ro   rn   r4   r?   r˜   r™   s   @r   r«   r«   à  s+  ø€ € € € € ð/ð /ðh !ØØ"&Ø%)Ø#Ø#Ø"Ø&*Ø#'Ø%)Ø!%Ø',ð#ð #ð #ð �T‰zð#ð �4‰Zð	#ð
 ˜4‘Zð#ð ˜d™
ð#ð ˜‘*ð#ð ˜‘*ð#ð �t‘ð#ð ˜t™ð#ð �S”	˜DÑ ð#ð �s”)˜dÑ"ð#ð �3Œi˜$Ñð#ð !%ð#ð #ð #ð #ð #ð #ð #ð #ð #ð #r!   r«   r“   c           	      óü  — g }| D �]ó}|d         }|d         }|D �]Ü}|d         d         }|d                               d¦  «        }|d         d         }|d         d         }	|d                               d¦  «        }
|d                               d¦  «        }|d                               d¦  «        }|d                               d	¦  «        }|                      d
i ¦  «                              d¦  «        }|                      d
i ¦  «                              d¦  «        }|d         D ]Í}|d         }|d         }|                      d¦  «        }|                      d	¦  «        }|                      d¦  «        }|                      d¦  «        }|                      d¦  «        }t          d i d|“d|“d|	“d|“d|“d|“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“d|“Ž}|                     |¦  «         ŒÎ�ŒÞ�Œõ||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Útaskry   ÚdatasetÚconfigÚsplitÚrevisionÚargsÚsourceÚurlr„   rC   r   ÚverifyTokenr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r7   )ra   r	   Úappend)r“   rp   Úelemr¶   r·   Úresultr
   r   r   r   r   r   r   r   r   r   Úmetricr   r   r   r   r   r   r   Úeval_results                            r   r‹   r‹   1  s©  € ðp €LØð +1ñ +1ˆØ�FŒ|ˆØ�y”/ˆØð (	1ñ (	1ˆFØ˜vœ vÔ.ˆIØ˜vœ×*Ò*¨6Ñ2Ô2ˆIØ! )Ô,¨VÔ4ˆLØ! )Ô,¨VÔ4ˆLØ# IÔ.×2Ò2°8Ñ<Ô<ˆNØ" 9Ô-×1Ò1°'Ñ:Ô:ˆMØ% iÔ0×4Ò4°ZÑ@Ô@ÐØ! )Ô,×0Ò0°Ñ8Ô8ˆLØ Ÿ*š* X¨rÑ2Ô2×6Ò6°vÑ>Ô>ˆKØŸš H¨bÑ1Ô1×5Ò5°eÑ<Ô<ˆJà  Ô+ð 1ð 1�Ø$ Vœn�Ø% gœ�Ø$Ÿjšj¨Ñ0Ô0�Ø$Ÿjšj¨Ñ0Ô0�Ø &§
¢
¨8Ñ 4Ô 4�Ø!Ÿ:š: jÑ1Ô1�Ø%Ÿzšz¨-Ñ8Ô8�å(ð ð ð Ø'˜iðà!- ðð ". ðð !, ð	ð
 ". ðð (˜iðð $2 >ðð #0 -ðð &6Ð%5ðð ". ðð !, ðð !, ðð #0 -ðð &˜Xðð ". ðð  !, ð!ð"  *˜zð#�ð& ×#Ò# KÑ0Ô0Ð0Ð0ñ91ñ(	1ðR �ÐÐ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<   ©Ú_remove_none)rB   Úxs     r   rv   z_remove_none.<locals>.<genexpr>ž  s(   è è € ÐGÐG¨Q¸¸� a™œ¸¸¸¸ÐGÐGr!   c              3   ó`   K  — | ])\  }}|®|®	t          |¦  «        t          |¦  «        fV — Œ*d S r<   rÈ   )rB   rP   Úvs      r   rv   z_remove_none.<locals>.<genexpr>   sC   è è € ÐwÐwÁÀÀ1ÐWXÐWdÐijÐiv�, q™/œ/­<¸©?¬?Ð;ÐivÐivÐivÐivÐwÐwr!   )rt   rn   r6   rV   ry   r3   r%   )Úobjs    r   rÉ   rÉ   ™  s†   € õ �#��e¥SÐ)Ñ*Ô*ð Ø�t�C‰yŒyÐGÐG°#ÐGÑGÔGÑGÔGÐGÝ	�C�Ñ	Ô	ð Ø�t�C‰yŒyÐwÐwÈÏ	Ê	ÉÌÐwÑwÔwÑwÔwÐwàˆ
r!   c           	      óÚ  — t          t          ¦  «        }|D ]"}||j                                      |¦  «         Œ#g }|                     ¦   «         D ]‡}|d         }|j        |j        dœ|j        |j        |j	        |j
        |j        |j        dœd„ |D ¦   «         dœ}|j        �d|j        i}|j        �
|j        |d<   ||d	<   |                     |¦  «         Œˆ| |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   )ry   r¶   )r¶   ry   rº   r»   r¼   r½   c           
      óh   — g | ]/}|j         |j        |j        |j        |j        |j        |j        d œ‘Œ0S ))ry   rC   r¶   rº   r½   r   rÀ   )r   r   r   r   r   r   r   )rB   rÃ   s     r   rS   z/eval_results_to_model_index.<locals>.<listcomp>à  sZ   € ð ð ð ð ð #Ô.Ø#Ô0Ø"Ô.Ø$Ô2Ø"Ô.Ø &¤Ø#)Ô#6ðð ðð ð r!   )r¸   r¹   r„   Nr¿   r¶   r¾   )r¶   r·   )r   rn   r    rÁ   Úvaluesr
   r   r   r   r   r   r   r   r   r   rÉ   )
rq   rp   Útask_and_ds_types_maprÅ   Úmodel_index_datar·   Úsample_resultÚdatar¾   r“   s
             r   r—   r—   ¥  s\  € õJ :EÅTÑ9JÔ9JÐØ#ð Qð QˆØ˜kÔ;Ô<×CÒCÀKÑPÔPÐPÐPð .0ÐØ(×/Ò/Ñ1Ô1ð $&ð $&ˆà œ
ˆð &Ô/Ø%Ô/ðð ð
 &Ô2Ø%Ô2Ø'Ô6Ø&Ô4Ø)Ô:Ø%Ô2ðð ðð ð &ðñ ô ð 
ð  
ˆð4 Ô#Ð/à�}Ô/ð&ˆFð Ô(Ð4Ø!.Ô!:��v‘Ø#ˆD�‰NØ×Ò Ñ%Ô%Ð%Ð%ð Ø'ð	
ð 	
ð€Kõ ˜Ñ$Ô$Ð$r!   r†   c                 óN   — | €| S g }| D ]}||vr|                      |¦  «         Œ|S r<   )rÁ   )r†   Úunique_tagsÚtags      r   rŠ   rŠ     sF   € Ø€|ØˆØ€KØð $ð $ˆØ�kÐ!Ð!Ø×Ò˜sÑ#Ô#Ð#øØÐr!   )rE   Úcollectionsr   Údataclassesr   Útypingr   Úhuggingface_hub.utilsr   r   Ú
get_loggerr-   rŽ   r	   r9   rn   r1   rz   r|   r›   r«   r3   r6   r‹   rÉ   r—   rŠ   r7   r!   r   ú<module>rÝ      s¾  ðØ €€€Ø #Ð #Ð #Ð #Ð #Ð #Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4ð 
ˆÔ	˜HÑ	%Ô	%€ð ðTbð Tbð Tbð Tbð Tbñ Tbô Tbñ „ðTbðn ðV"ð V"ð V"ð V"ð V"ñ V"ô V"ñ „ðV"ðrØ˜t JÔ/Ñ/°$Ñ6ðà�d‘
ðð 
ˆ*Ôðð ð ð ð"~Cð ~Cð ~Cð ~Cð ~C�Hñ ~Cô ~Cð ~CðB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e¨T°$°s¸C°x´.Ô-Að eÀeÈCÐQUÐV`ÔQaÐLaÔFbð eð eð eð eðP	ð 	ð 	ðY%¨Cð Y%¸tÀJÔ?Oð Y%ÐTXÐY]Ð^aÐcfÐ^fÔYgÔThð Y%ð Y%ð Y%ð Y%ðx˜$˜sœ) dÑ*ð ¨t°C¬y¸4Ñ/?ð ð ð ð ð ð r!   