Ë
    Q^(h"…  ã            	       ó´  — 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mZ  ej                  e«      Ze G d„ d«      «       Ze G d„ d	«      «       Zd
e	eeee   f      de	e   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e      de	ee      fd„Zy)é    N)Údefaultdict)Ú	dataclass)ÚAnyÚDictÚListÚOptionalÚTupleÚUnion)ÚloggingÚ	yaml_dumpc                   óv  — 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<   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d„Zy)Ú
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                 ót   — | j                   | j                  | j                  | j                  | j                  fS )z9Returns a tuple that uniquely identifies this evaluation.)r   r   r   r   r   ©Úselfs    ú[/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/huggingface_hub/repocard_data.pyÚunique_identifierzEvalResult.unique_identifier†   s9   € ð �N‰NØ×ÑØ×ÑØ×ÑØ×!Ñ!ð
ð 	
ó    Úotherc                 ó–   — | j                   j                  «       D ],  \  }}|dk(  rŒ|dk7  sŒt        | |«      t        ||«      k7  sŒ, y y)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‘   sV   € ð
 —m‘m×)Ñ)Ó+ò 	‰FˆC�Ø�nÒ$Øð �nÓ$¬°°sÓ);¼wÀuÈcÓ?RÓ)RÙð	ð r&   c                 óL   — | j                   �| j                  €t        d«      ‚y y )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©OÐ,CÜÐ`ÓaÐað -DÐ'r&   )r    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r   r   r   r   r   r   r   r   r   r   r   r   Úboolr   r   r   ÚpropertyÚtupler%   r.   r1   © r&   r$   r   r      s4  … ñ-ðf ƒNð Óð Óð Óð Óð  $€Iˆx˜‰}Ó#ð %)€N�H˜S‘MÓ(ð $(€M�8˜C‘=Ó'ð '+Ð�h˜s‘mÓ*ð .2€L�(˜4  S ™>Ñ*Ó1ð "&€K�˜#‘Ó%ð
 $(€M�8˜C‘=Ó'ð -1€K�˜$˜s C˜x™.Ñ)Ó0ð  $€Hˆh�t‰nÓ#ð #'€L�(˜3‘-Ó&ð "&€K�˜#‘Ó%ð !%€J�˜‘Ó$àð
 5ò 
ó ð
ð¨<ð ¸Dó ôbr&   r   c                   óÀ   — e Zd ZdZddefd„Zd„ Zd„ Zddee	e
      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y)Ú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.
    Úignore_metadata_errorsc                 ó:   — | j                   j                  |«       y ©N)r)   Úupdate)r#   r>   Úkwargss      r$   Ú__init__zCardData.__init__¯   s   € Ø�‰×Ñ˜VÕ$r&   c                 ó¼   — t        j                  | j                  «      }| j                  |«       |j	                  «       D ��ci c]  \  }}|€Œ	||“Œ c}}S c c}}w )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.
        )ÚcopyÚdeepcopyr)   Ú_to_dictr*   )r#   Ú	data_dictr,   Úvalues       r$   Úto_dictzCardData.to_dict²   sJ   € ô —M‘M $§-¡-Ó0ˆ	Ø�‰�iÔ Ø-6¯_©_Ó->×T™z˜s EÀ%ÑBS��U‘
ÓTÐTùÓTs   Á
AÁAc                  ó   — y)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.
        Nr;   ©r#   rH   s     r$   rG   zCardData._to_dict¾   s   € ð 	r&   NÚoriginal_orderr    c                 ó8  — |rj|t        t        | j                  j                  «       «      t        |«      z
  «      z   D �ci c]   }|| j                  v r|| j                  |   “Œ" c}| _        t	        | j                  «       d|¬«      j                  «       S c c}w )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)ÚlistÚsetr)   Úkeysr   rJ   Ústrip)r#   rP   rM   Úks       r$   Úto_yamlzCardData.to_yamlÆ   sˆ   € ñ ð (¬$¬s°4·=±=×3EÑ3EÓ3GÓ/HÌ3È~ÓK^Ñ/^Ó*_Ñ_öàØ˜Ÿ™Ñ%ð �4—=‘= Ñ#Ñ#òˆDŒMô
 ˜Ÿ™›°5ÀZÔP×VÑVÓXÐXùòs   Á %Bc                 ó,   — t        | j                  «      S r@   )Úreprr)   r"   s    r$   Ú__repr__zCardData.__repr__Ø   s   € Ü�D—M‘MÓ"Ð"r&   c                 ó"   — | j                  «       S r@   )rV   r"   s    r$   Ú__str__zCardData.__str__Û   s   € Ø�|‰|‹~Ðr&   r,   Údefaultc                 óD   — | j                   j                  |«      }|€|S |S ©z#Get value for a given metadata key.)r)   Úget)r#   r,   r\   rI   s       r$   r_   zCardData.getÞ   s%   € à—‘×!Ñ! #Ó&ˆØ˜-ˆwÐ2¨UÐ2r&   c                 ó:   — | j                   j                  ||«      S )z#Pop value for a given metadata key.)r)   Úpop)r#   r,   r\   s      r$   ra   zCardData.popã   s   € à�}‰}× Ñ   gÓ.Ð.r&   c                 ó    — | j                   |   S r^   ©r)   ©r#   r,   s     r$   Ú__getitem__zCardData.__getitem__ç   s   € à�}‰}˜SÑ!Ð!r&   rI   c                 ó"   — || j                   |<   y)z#Set value for a given metadata key.Nrc   )r#   r,   rI   s      r$   Ú__setitem__zCardData.__setitem__ë   s   € à"ˆ�‰�cÒr&   c                 ó   — || j                   v S )z%Check if a given metadata key is set.rc   rd   s     r$   Ú__contains__zCardData.__contains__ï   s   € à�d—m‘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@   )r2   r3   r4   r5   r8   rC   rJ   rG   r   r   r6   rV   rY   r[   r   r_   ra   re   rg   ri   Úintrl   r;   r&   r$   r=   r=   ¤   sÈ   „ ññ%¨tó %ò
UòñY°xÀÀSÁ	Ñ7Jð YÐVYó Yò$#òñ3�sð 3 Sð 3°Có 3ñ
/�sð / Sð /°Có /ð"˜sð " só "ð#˜sð #¨3ð #°4ó #ð$ ð $¨ó $ð"˜ô "r&   r=   Ú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        «      –— Œ y ­wr@   )Ú
isinstancer   )Ú.0Úrs     r$   ú	<genexpr>z)_validate_eval_results.<locals>.<genexpr>   s   è ø€ Ò4eÐST´ZÀÄ:×5NÑ4eùs   ‚zM`eval_results` should be of type `EvalResult` or a list of `EvalResult`, got ú.z7Passing `eval_results` requires `model_name` to be set.)rr   r   rQ   Úallr0   Útype)rn   ro   s     r$   Ú_validate_eval_resultsry   ø   st   € ð ÐØˆ	Ü�,¤
Ô+Ø$�~ˆÜ�l¤DÔ)´Ñ4eÐXdÔ4eÔ1eÜØ[Ô\`ÐamÓ\nÐ[oÐopÐqó
ð 	
ð ÐÜÐRÓ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ee   f      deeeee   f      deee      deeeee   f      d	ee   d
ee   dee   dee   deee      dee   dee   deee      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Údatasetsrn   ÚlanguageÚlibrary_nameÚlicenseÚlicense_nameÚlicense_linkÚmetricsro   Úpipeline_tagÚtagsr>   r|   r}   rn   r~   r   r€   r�   r‚   rƒ   ro   r„   r…   r>   c                óÈ  •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        t        |«      | _        |j                  dd «      }|r	 t        |«      \  }
}|
| _	        || _        t+        ‰| �X  di |¤Ž | j                  r'	 t/        | j                  | j                  «      | _        y y # t        t         f$ r>}|rt"        j%                  d«       nt'        d|j(                  › d|› d�«      ‚Y d }~Œ‹d }~ww xY w# t0        $ r5}|rt"        j%                  d|› d�«       nt'        d|› �«      |‚Y d }~y d }~ww xY w)	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.r;   )r|   r}   rn   r~   r   r€   r�   r‚   rƒ   ro   r„   Ú_to_unique_listr…   ra   Úmodel_index_to_eval_resultsÚKeyErrorÚ	TypeErrorÚloggerÚwarningr0   Ú	__class__ÚsuperrC   ry   Ú	Exception)r#   r|   r}   rn   r~   r   r€   r�   r‚   rƒ   ro   r„   r…   r>   rB   Úmodel_indexÚerrorÚer�   s                     €r$   rC   zModelCardData.__init__I  s}  ø€ ð$ %ˆŒØ ˆŒØ(ˆÔØ ˆŒØ(ˆÔØˆŒØ(ˆÔØ(ˆÔØˆŒØ$ˆŒØ(ˆÔÜ# DÓ)ˆŒ	à—j‘j °Ó5ˆÙðÜ+FÀ{Ó+SÑ(�
˜LØ",�”Ø$0�Ô!ô 	‰ÑÑ"˜6Ò"à×ÒðUÜ$:¸4×;LÑ;LÈdÏoÉoÓ$^�Õ!ð øô œiÐ(ò Ù)Ü—N‘NÐ#aÕbä$ØNÈuÏÉÐN_Ð_`ÐafÐ`gð hSð Sóð ô cûðûô ò UÙ)Ü—N‘NÐ%FÀqÀcÐIrÐ#sÕtä$Ð'HÈÈÐ%LÓMÐSTÐTô uûðUús0   Á4C Â,%D# ÃD Ã"4DÄD Ä#	E!Ä,+EÅE!c                 óp   — | j                   �*t        | j                  | j                   «      |d<   |d= |d= yy)z[Format the internal data dict. In this case, we convert eval results to a valid model indexNr‡   rn   ro   )rn   Úeval_results_to_model_indexro   rL   s     r$   rG   zModelCardData._to_dictƒ  s>   € à×ÑÐ(Ü'BÀ4Ç?Á?ÐTX×TeÑTeÓ'fˆI�mÑ$Ø˜.Ð)¨9°\Ñ+Bð )r&   )r2   r3   r4   r5   r   r
   r6   r   r   r8   rC   rG   Ú__classcell__©r�   s   @r$   r{   r{   	  s8  ø„ ñ=ðD 7;Ø48Ø37Ø48Ø&*Ø!%Ø&*Ø&*Ø'+Ø$(Ø&*Ø$(Ø',ò8Uð ˜U 3¨¨S©	 >Ñ2Ñ3ð8Uð ˜5  d¨3¡i Ñ0Ñ1ð	8Uð
 ˜t JÑ/Ñ0ð8Uð ˜5  d¨3¡i Ñ0Ñ1ð8Uð ˜s‘mð8Uð ˜#‘ð8Uð ˜s‘mð8Uð ˜s‘mð8Uð ˜$˜s™)Ñ$ð8Uð ˜S‘Mð8Uð ˜s‘mð8Uð �t˜C‘yÑ!ð8Uð !%õ8UötCr&   r{   c                   óf  ‡ — 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)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                ó  •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        |xs |j                  dd «      | _        t        ‰| �<  di |¤Ž y )Nútrain-eval-indexr;   )r›   rœ   r~   r€   r�   rž   rŸ   r    r¡   r¢   r£   r¥   ra   r¤   r�   rC   )r#   r~   r€   r›   rœ   r�   rž   rŸ   r    r¡   r¢   r£   r¤   r¥   r>   rB   r�   s                   €r$   rC   zDatasetCardData.__init__²  sŽ   ø€ ð& %9ˆÔ!Ø!2ˆÔØ ˆŒØˆŒØ.ˆÔØ.ˆÔØ.ˆÔØ.ˆÔØ ˆŒØ!2ˆÔØ&ˆÔØ(ˆÔð !1Ò X°F·J±JÐ?QÐSWÓ4XˆÔÜ‰ÑÑ"˜6Ó"r&   c                 ó,   — |j                  d«      |d<   y )Nr¤   r§   )ra   rL   s     r$   rG   zDatasetCardData._to_dictÖ  s   € Ø(1¯©Ð6HÓ(Iˆ	Ð$Ò%r&   )r2   r3   r4   r5   r   r
   r6   r   r   r8   rC   rG   r—   r˜   s   @r$   rš   rš   Š  s„  ø„ ñ%ðT 59Ø37Ø@DØ=AØ;?Ø;?Ø/3Ø;?Ø48Ø+/Ø%)Ø+/Ø8<Ø',ò!"#ð ˜5  d¨3¡i Ñ0Ñ1ð"#ð ˜%  T¨#¡Y Ñ/Ñ0ð	"#ð
 ' u¨S°$°s±)¨^Ñ'<Ñ=ð"#ð $ E¨#¨t°C©y¨.Ñ$9Ñ:ð"#ð " %¨¨T°#©Y¨Ñ"7Ñ8ð"#ð " %¨¨T°#©Y¨Ñ"7Ñ8ð"#ð " $ s¡)Ñ,ð"#ð " %¨¨T°#©Y¨Ñ"7Ñ8ð"#ð ˜5  d¨3¡i Ñ0Ñ1ð"#ð $ C™=ð"#ð ˜c‘]ð"#ð # 4™.ð"#ð ˜u S¨$¨s©) ^Ñ4Ñ5ð"#ð  !%õ!"#öH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_portr€   Úduplicated_fromÚmodelsr}   r…   r>   r«   r¬   r­   r®   r¯   r°   r€   r±   r²   r}   r…   r>   c                óÐ   •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        t        |«      | _        t        ‰| �4  di |¤Ž y )Nr;   )r«   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>   rB   r�   s                 €r$   rC   zSpaceCardData.__init__  sj   ø€ ð" ˆŒ
ØˆŒØ&ˆÔØ,ˆÔØ ˆŒØ ˆŒØˆŒØ.ˆÔØˆŒØ ˆŒÜ# DÓ)ˆŒ	Ü‰ÑÑ"˜6Ó"r&   )r2   r3   r4   r5   r   r6   rm   r   r8   rC   r—   r˜   s   @r$   rª   rª   Ú  sì   ø„ ñ/ðh  $Ø!Ø%)Ø(,Ø"&Ø"&Ø!%Ø)-Ø&*Ø(,Ø$(Ø',ò#ð ˜‰}ð#ð �c‰]ð	#ð
 ˜c‘]ð#ð ! ™ð#ð ˜3‘-ð#ð ˜3‘-ð#ð ˜#‘ð#ð " #™ð#ð ˜˜c™Ñ#ð#ð ˜4 ™9Ñ%ð#ð �t˜C‘yÑ!ð#ð !%÷#ñ #r&   rª   r’   c           	      ó.  — g }| D �]Š  }|d   }|d   }|D �]w  }|d   d   }|d   j                  d«      }|d   d   }|d   d   }	|d   j                  d«      }
|d   j                  d«      }|d   j                  d«      }|d   j                  d	«      }|j                  d
i «      j                  d«      }|j                  d
i «      j                  d«      }|d   D ]®  }|d   }|d   }|j                  d«      }|j                  d	«      }|j                  d«      }|j                  d«      }|j                  d«      }t        d i d|“d|“d|	“d|“d|“d|“d|
“d|“d|“d|“d|“d|“d|“d|“d|“d|“d|“Ž}|j                  |«       Œ° �Œz �Œ� |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Útaskrx   ÚdatasetÚconfigÚsplitÚrevisionÚargsÚsourceÚurlrƒ   rI   r   ÚverifyTokenr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   )r_   r   Úappend)r’   rn   Úelemrµ   r¶   Úresultr   r   r   r   r   r   r   r   r   r   Úmetricr   r   r   r   r   r   r   Úeval_results                            r$   rŠ   rŠ   +  s?  € ðp €LØó +1ˆØ�F‰|ˆØ�y‘/ˆØó (	1ˆFØ˜v™ vÑ.ˆIØ˜v™×*Ñ*¨6Ó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ˆLØ Ÿ*™* X¨rÓ2×6Ñ6°vÓ>ˆKØŸ™ H¨bÓ1×5Ñ5°eÓ<ˆJà  Ñ+ò 1�Ø$ V™n�Ø% g™�Ø$Ÿj™j¨Ó0�Ø$Ÿj™j¨Ó0�Ø &§
¡
¨8Ó 4�Ø!Ÿ:™: jÓ1�Ø%Ÿz™z¨-Ó8�ä(ò Ù'ðá!-ðñ ".ðñ !,ð	ñ
 ".ðñ (ðñ $2ðñ #0ðñ &6ðñ ".ðñ !,ðñ !,ðñ #0ðñ &ðñ ".ðñ  !,ð!ñ"  *ð#�ð& ×#Ñ# KÕ0ò91ò(	1ð+1ðX �ÐÐr&   c                 óØ   — t        | t        t        t        f«      r t	        | «      d„ | D «       «      S t        | t
        «      r& t	        | «      d„ | j                  «       D «       «      S | S )zk
    Recursively remove `None` values from a dict. Borrowed from: https://stackoverflow.com/a/20558778
    c              3   ó8   K  — | ]  }|€Œt        |«      –— Œ y ­wr@   ©Ú_remove_none)rs   Úxs     r$   ru   z_remove_none.<locals>.<genexpr>˜  s   è ø€ ÒG¨Q¸¹œ aŸÑGùs   ‚Šc              3   óZ   K  — | ]#  \  }}|€Œ	|€Œt        |«      t        |«      f–— Œ% y ­wr@   rÇ   )rs   rU   Úvs      r$   ru   z_remove_none.<locals>.<genexpr>š  s-   è ø€ ÒwÁÀÀ1ÐWXÑWdÐijÑivœ, q›/¬<¸«?Ô;Ñwùs   ‚
+�+�+)rr   rQ   r:   rR   rx   Údictr*   )Úobjs    r$   rÈ   rÈ   “  sX   € ô �#œœe¤SÐ)Ô*ØŒt�C‹yÑG°#ÔGÓGÐGÜ	�CœÔ	ØŒt�C‹yÑwÈÏ	É	ËÔwÓwÐwàˆ
r&   c                 óà  — t        t        «      }|D ]   }||j                     j                  |«       Œ" g }|j	                  «       D �]  }|d   }|j
                  |j                  dœ|j                  |j                  |j                  |j                  |j                  |j                  dœ|D �cg c]R  }|j                  |j                  |j                  |j                   |j"                  |j$                  |j&                  dœ‘ŒT c}dœ}|j(                  �.d|j(                  i}	|j*                  �|j*                  |	d<   |	|d<   |j                  |«       �Œ | |d	œg}
t-        |
«      S c c}w )
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   )rx   rµ   )rµ   rx   r¹   rº   r»   r¼   )rx   rI   rµ   r¹   r¼   r   r¿   )r·   r¸   rƒ   r¾   rµ   r½   )rµ   r¶   )r   rQ   r%   rÀ   Úvaluesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rÈ   )ro   rn   Útask_and_ds_types_maprÄ   Úmodel_index_datar¶   Úsample_resultrÂ   Údatar½   r’   s              r$   r–   r–   Ÿ  s–  € ôJ :EÄTÓ9JÐØ#ò QˆØ˜k×;Ñ;Ñ<×CÑCÀKÕPðQð ÐØ(×/Ñ/Ó1ó $&ˆà ™
ˆð &×/Ñ/Ø%×/Ñ/ñð
 &×2Ñ2Ø%×2Ñ2Ø'×6Ñ6Ø&×4Ñ4Ø)×:Ñ:Ø%×2Ñ2ñð$ &öð ð #×.Ñ.Ø#×0Ñ0Ø"×.Ñ.Ø$×2Ñ2Ø"×.Ñ.Ø &§¡Ø#)×#6Ñ#6óòñ
ˆð4 ×#Ñ#Ð/à�}×/Ñ/ðˆFð ×(Ñ(Ð4Ø!.×!:Ñ!:��v‘Ø#ˆD�‰NØ×Ñ Ö%ðI$&ðT Ø'ñ	
ð€Kô ˜Ó$Ð$ùò=s   Â0AE+
r…   c                 óL   — | €| S g }| D ]  }||vsŒ|j                  |«       Œ |S r@   )rÀ   )r…   Úunique_tagsÚtags      r$   r‰   r‰   û  s>   € Ø€|ØˆØ€KØò $ˆØ�kÒ!Ø×Ñ˜sÕ#ð$ð Ðr&   )rE   Úcollectionsr   Údataclassesr   Útypingr   r   r   r   r	   r
   Úhuggingface_hub.utilsr   r   Ú
get_loggerr2   r�   r   r=   r6   ry   r{   rš   rª   rŠ   rÈ   r–   r‰   r;   r&   r$   ú<module>rÜ      sk  ðÛ Ý #Ý !ß :× :ç 4ð 
ˆ×	Ñ	˜HÓ	%€ð ÷Tbð Tbó ðTbðn ÷P"ð P"ó ðP"ðfØ˜5 ¨T°*Ñ-=Ð!=Ñ>Ñ?ðà˜‘ðð 
ˆ*Ñóô"~C�Hô ~CôBMJ�hô MJô`N#�Hô N#ðbe¨T°$°s¸C°x±.Ñ-Að eÀeÈCÐQUÐV`ÑQaÐLaÑFbó eòP	ðY%¨Cð Y%¸tÀJÑ?Oð Y%ÐTXÐY]Ð^aÐcfÐ^fÑYgÑThó Y%ðx˜( 4¨¡9Ñ-ð °(¸4À¹9Ñ2Eô r&   