+
    U\i"                     .   ^ RI t ^ RIHt ^ RIHt ^ RIHtHtHtH	t	H
t
Ht ^ RIHtHt ]P                  ! ]4      t] ! R R4      4       t] ! R R	4      4       tR
 R lt ! R R]4      t ! R R]4      t ! R R]4      tR R ltR tR R ltR R ltR# )    N)defaultdict)	dataclass)AnyDictListOptionalTupleUnion)logging	yaml_dumpc                      a  ] tR t^t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRt]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R	 ltR
tV tR# )
EvalResultuC  
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".
Nc                    < V ^8  d   QhRS[ /#    return)tuple)format__classdict__s   "u/Users/agent/.cache/uv/archive-v0/6ZL4-8mCcRNgGE9wi6M6J/lib/python3.14/site-packages/huggingface_hub/repocard_data.py__annotate__EvalResult.__annotate__   s     
 
5 
    c                t    V P                   V P                  V P                  V P                  V P                  3# )z9Returns a tuple that uniquely identifies this evaluation.)	task_typedataset_typedataset_configdataset_splitdataset_revisionselfs   &r   unique_identifierEvalResult.unique_identifier   s9     NN!!
 	
r   c                $   < V ^8  d   QhRRRS[ /# )r   otherr   r   bool)r   r   s   "r   r   r      s      < D r   c                    V P                   P                  4        F3  w  r#VR8X  d   K  VR8w  g   K  \        W4      \        W4      8w  g   K2   R# 	  R# )z`
Return True if `self` and `other` describe exactly the same metric but with a
different value.
metric_valueverify_tokenFT)__dict__itemsgetattr)r!   r%   key_s   &&  r   is_equal_except_value EvalResult.is_equal_except_value   sK    
 mm))+FCn$ n$);wu?R)R , r   c                   < V ^8  d   QhRR/# )r   r   N )r   r   s   "r   r   r      s     b bt br   c                X    V P                   e   V P                  f   \        R4      hR # R # )NzAIf `source_name` is provided, `source_url` must also be provided.)source_name
source_url
ValueErrorr    s   &r   __post_init__EvalResult.__post_init__   s,    'DOO,C`aa -D'r   c                  < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R	&   S[S[S[ S[3,          ,          ;R
&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[S[ S[3,          ,          ;R&   S[S[,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   # )r   r   r   dataset_namemetric_typer)   	task_namer   r   r   dataset_argsmetric_namemetric_configmetric_argsverifiedr*   r5   r6   )strr   r   r   r'   )r   r   s   "r   r   r      sE    j Nk r s z { B C J K V }#W b SM(c j C='k r sm*s z 4S>*1{ B #%C L C='M T $sCx.)0U Z tn#[ ` 3-&a h #%i p $q r   r3   )__name__
__module____qualname____firstlineno____doc__r=   r   r   r   r>   r?   r@   rA   rB   r*   r5   r6   propertyr"   r0   r8   __annotate_func____static_attributes____classdictcell__r   s   @r   r   r      s     -R  $I %)N $(M '+ .2L "&K
 $(M -1K  $H #'L "&K !%J
 
 b bg  r   r   c                      a  ] tR t^t o RtRV 3R lR lltR tR tRV 3R lR lltR	 t	R
 t
RV 3R lR lltRV 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )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.
c                    < V ^8  d   QhRS[ /# )r   ignore_metadata_errorsr&   )r   r   s   "r   r   CardData.__annotate__   s     % %t %r   c                <    V P                   P                  V4       R # N)r+   update)r!   rQ   kwargss   &&,r   __init__CardData.__init__   s    V$r   c                    \         P                  ! V P                  4      pV P                  V4       VP	                  4        UUu/ uF  w  r#Vf   K  W#bK  	  upp# u uppi )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_dictr,   )r!   	data_dictr.   values   &   r   to_dictCardData.to_dict   sK     MM$--0	i -6__->T->zs%

->TTTs   AAc                    R# )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.
Nr3   r!   r]   s   &&r   r\   CardData._to_dict   s     	r   Nc                F   < V ^8  d   QhRS[ S[S[,          ,          RS[/# )r   original_orderr   r   r   rC   )r   r   s   "r   r   rR      s)     Y YxS	7J YVY Yr   c                f   V'       d|   V\        \        V P                  P                  4       4      \        V4      ,
          4      ,            Uu/ uF(  pW0P                  9   g   K  W0P                  V,          bK*  	  upV n        \	        V P                  4       RVR7      P                  4       # u upi )zDumps 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   r_   strip)r!   ri   re   ks   &&& r   to_yamlCardData.to_yaml   s      ($s4==3E3E3G/H3~K^/^*___A% $==##_DM
 5ZPVVXXs   B.%B.c                ,    \        V P                  4      # rT   )reprr+   r    s   &r   __repr__CardData.__repr__   s    DMM""r   c                "    V P                  4       # rT   )ro   r    s   &r   __str__CardData.__str__   s    ||~r   c                ,   < V ^8  d   QhRS[ RS[RS[/# r   r.   defaultr   rC   r   )r   r   s   "r   r   rR      s"     3 3s 3S 3C 3r   c                H    V P                   P                  V4      pVf   V# T# z#Get value for a given metadata key.)r+   get)r!   r.   rz   r^   s   &&& r   r~   CardData.get   s%    !!#&-w2U2r   c                ,   < V ^8  d   QhRS[ RS[RS[/# ry   r{   )r   r   s   "r   r   rR      s"     / /s /S /C /r   c                8    V P                   P                  W4      # )z#Pop value for a given metadata key.)r+   pop)r!   r.   rz   s   &&&r   r   CardData.pop   s    }}  ..r   c                &   < V ^8  d   QhRS[ RS[/# r   r.   r   r{   )r   r   s   "r   r   rR      s     " "s "s "r   c                (    V P                   V,          # r}   r+   r!   r.   s   &&r   __getitem__CardData.__getitem__   s    }}S!!r   c                *   < V ^8  d   QhRS[ RS[RR/# )r   r.   r^   r   Nr{   )r   r   s   "r   r   rR      s"     # #s #3 #4 #r   c                "    W P                   V&   R# )z#Set value for a given metadata key.Nr   )r!   r.   r^   s   &&&r   __setitem__CardData.__setitem__   s    "cr   c                &   < V ^8  d   QhRS[ RS[/# r   )rC   r'   )r   r   s   "r   r   rR      s     $ $ $ $r   c                    WP                   9   # )z%Check if a given metadata key is set.r   r   s   &&r   __contains__CardData.__contains__   s    mm##r   c                    < V ^8  d   QhRS[ /# r   )int)r   r   s   "r   r   rR      s     " " "r   c                ,    \        V P                  4      # )z'Return the number of metadata keys set.)lenr+   r    s   &r   __len__CardData.__len__   s    4==!!r   r   )F)NNrT   )rD   rE   rF   rG   rH   rW   r_   r\   ro   rs   rv   r~   r   r   r   r   r   rK   rL   rM   s   @r   rO   rO      sq     % %
UY Y$#3 3
/ /" "# #$ $" "r   rO   c                    V ^8  d   QhR\         \        \        \        \        ,          3,          ,          R\         \        ,          R\        \        ,          /# )r   eval_results
model_namer   )r   r
   r   r   rC   )r   s   "r   r   r      sC      5T*-=!=>? 
*r   c                 2   V f   . # \        V \        4      '       d   V .p \        V \        4      '       d;   \        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       g   \	        R\        V 4       R24      hVf   \	        R4      hV # )Nc              3   B   "   T F  p\        V\        4      x  K  	  R # 5irT   )
isinstancer   ).0rs   & r   	<genexpr>)_validate_eval_results.<locals>.<genexpr>   s     4eXdSTZ:5N5NXds   FTzM`eval_results` should be of type `EvalResult` or a list of `EvalResult`, got .z7Passing `eval_results` requires `model_name` to be set.)r   r   rj   allr7   type)r   r   s   &&r   _validate_eval_resultsr      s     	,
++$~lD))4eXd4e4eXd4e1e1e[\`am\n[oopq
 	
 RSSr   c                      a a ] tR tRt oRt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/V3R lV 3R llltR tRtVtV ;t	# )ModelCardDatai	  ai  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']}

    ```

base_modelNdatasetsr   languagelibrary_namelicenselicense_namelicense_linkmetricsr   pipeline_tagtagsrQ   Fc                  < V ^8  d   QhRS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          R	S[ S[S[,          ,          R
S[ S[,          RS[ S[,          RS[ S[S[,          ,          RS[/# )r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   )r   r
   rC   r   r   r'   )r   r   s   "r   r   ModelCardData.__annotate__I  s    8U 8U U3S	>238U 5d3i01	8U
 tJ/08U 5d3i018U sm8U #8U sm8U sm8U $s)$8U SM8U sm8U tCy!8U !%8Ur   c                 < Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        Wn        Wn	        Wn
        \        V4      V n        VP                  R R4      pV'       d    \        V4      w  rWn	        W0n        \*        SV `X  ! R/ VB  V P                  '       d)    \/        V P                  V P                  4      V n        R# R#   \        \         3 dD   pT'       d   \"        P%                  R4        Rp?L\'        RTP(                   RT R24      hRp?ii ; i  \0         d<   pT'       d    \"        P%                  RT R24        Rp?R# \'        RT 24      ThRp?ii ; i)	model-indexNz<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.r3   )r   r   r   r   r   r   r   r   r   r   r   _to_unique_listr   r   model_index_to_eval_resultsKeyError	TypeErrorloggerwarningr7   	__class__superrW   r   	Exception)r!   r   r   r   r   r   r   r   r   r   r   r   r   rQ   rV   model_indexerrorer   s   &$$$$$$$$$$$$$,   r   rW   ModelCardData.__init__I  s^   $ % ( ((($(#D)	jj5+F{+S(
",$0! 	"6"U$:4;L;Ldoo$^!  i( )NN#abb$NuN__`af`g hS S 	  U)NN%FqcIr#stt$'H%LMSTT	Us<   /C +%D+ D(%D#D##D(+E16!E,E,,E1c                x    V P                   e,   \        V P                  V P                   4      VR&   VR VR R# R# )z[Format the internal data dict. In this case, we convert eval results to a valid model indexNr   r   r   )r   eval_results_to_model_indexr   rb   s   &&r   r\   ModelCardData._to_dict  s>    ('B4??TXTeTe'fIm$.)9\+B )r   )r   r   r   r   r   r   r   r   r   r   r   r   
rD   rE   rF   rG   rH   rW   r\   rK   rL   __classcell__r   r   s   @@r   r   r   	  s     =~8U 7;8U 59	8U
 488U 598U '+8U "&8U '+8U '+8U (,8U %)8U '+8U %)8U (-8U 8UtC Cr   r   c                      a a ] tR tRt oRt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/V3R lV 3R llltR tRtVtV ;t	# )DatasetCardDatai  aG	  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.
r   Nr   annotations_creatorslanguage_creatorsmultilingualitysize_categoriessource_datasetstask_categoriestask_idspaperswithcode_idpretty_nametrain_eval_indexconfig_namesrQ   Fc                  < V ^8  d   QhRS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[S[S[,          3,          ,          RS[ S[S[,          ,          RS[ S[S[S[S[,          3,          ,          R	S[ S[S[S[S[,          3,          ,          R
S[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[S[,          3,          ,          RS[/# )r   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   )r   r
   rC   r   r   r'   )r   r   s   "r   r   DatasetCardData.__annotate__  sP    "# "# 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"#  !%!"#r   c                  < W0n         W@n        Wn        W n        WPn        W`n        Wpn        Wn        Wn        Wn	        Wn
        Wn        T;'       g    VP                  R R4      V n        \        SV `<  ! R/ VB  R# )train-eval-indexNr3   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rW   )r!   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   rV   r   s   &$$$$$$$$$$$$$$,r   rW   DatasetCardData.__init__  sy    & %9!!2 .... !2&( !1 X XFJJ?QSW4X"6"r   c                .    VP                  R 4      VR&   R# )r   r   N)r   rb   s   &&r   r\   DatasetCardData._to_dict  s    (16H(I	$%r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @@r   r   r     s     %N"# 59"# 48	"#
 AE"# >B"# <@"# <@"# 04"# <@"# 59"# ,0"# &*"# ,0"# 9="#  (-!"# "#HJ Jr   r   c                   v   a a ] tR tRt oRtRRRRRRRRRRR	RR
RRRRRRRRRRR/V3R lV 3R llltRtVtV ;t# )SpaceCardDatai  a8	  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'}
    ```
titleNsdksdk_versionpython_versionapp_fileapp_portr   duplicated_frommodelsr   r   rQ   Fc                B  < V ^8  d   QhRS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          R	S[ S[S[,          ,          R
S[ S[S[,          ,          RS[ S[S[,          ,          RS[/# )r   r   r   r   r   r   r   r   r   r   r   r   rQ   )r   rC   r   r   r'   )r   r   s   "r   r   SpaceCardData.__annotate__  s     # # }# c]	#
 c]# !# 3-# 3-# ## "## c## 49%# tCy!# !%#r   c                  < Wn         W n        W0n        W@n        WPn        W`n        Wpn        Wn        Wn        Wn	        \        V4      V n        \        SV `4  ! R/ VB  R # )Nr3   )r   r   r   r   r   r   r   r   r   r   r   r   r   rW   )r!   r   r   r   r   r   r   r   r   r   r   r   rQ   rV   r   s   &$$$$$$$$$$$$,r   rW   SpaceCardData.__init__  sV    " 
&,  . #D)	"6"r   )r   r   r   r   r   r   r   r   r   r   r   )	rD   rE   rF   rG   rH   rW   rK   rL   r   r   s   @@r   r   r     s     /b#  $# "	#
 &*# )-# #'# #'# "&# *.# '+# )-# %)# (-# # #r   r   c                    V ^8  d   QhR\         \        \        \        3,          ,          R\        \        \         \
        ,          3,          /# )r   r   r   )r   r   rC   r   r	   r   )r   s   "r   r   r   +  s<     e eT$sCx.-A eeCQUV`QaLaFb er   c           	        . pV  EF  pVR,          pVR,          pV EF  pVR,          R,          pVR,          P                  R4      pVR,          R,          pVR,          R,          p	VR,          P                  R4      p
VR,          P                  R4      pVR,          P                  R4      pVR,          P                  R	4      pVP                  R
/ 4      P                  R4      pVP                  R
/ 4      P                  R4      pVR,           F  pVR,          pVR,          pVP                  R4      pVP                  R	4      pVP                  R4      pVP                  R4      pVP                  R4      p\        R / RVbRVbRV	bRVbRVbRVbRV
bRVbRVbRVbRVbRVbRVbRVbRVbRVbRVb pVP                  V4       K  	  EK  	  EK  	  XV3# )!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taskr   datasetconfigsplitrevisionargssourceurlr   r^   rB   verifyTokenr   r   r;   r<   r)   r=   r   r   r   r>   r?   rA   r@   r*   r5   r6   r3   )r~   r   append)r   r   elemr   r   resultr   r=   r   r;   r   r   r   r>   r5   r6   metricr<   r)   r?   rA   r@   rB   r*   eval_results   &                        r   r   r   +  s3   p LF|y/Fvv.Iv**62I!),V4L!),V4L#I.228<N"9-11':M%i044Z@!),008L **Xr266v>KHb155e<J ++$Vn%g$jj0$jj0 &

8 4!::j1%zz-8( '!- ". !,	
 ". ( $2 #0 &6 ". !, !, #0 & ".  !,!"  *#& ##K09 ,  X r   c                    \        V \        \        \        34      '       d   \	        V 4      ! R V  4       4      # \        V \
        4      '       d'   \	        V 4      ! R V P                  4        4       4      # V # )zc
Recursively remove `None` values from a dict. Borrowed from: https://stackoverflow.com/a/20558778
c              3   B   "   T F  qf   K  \        V4      x  K  	  R # 5irT   _remove_none)r   xs   & r   r   _remove_none.<locals>.<genexpr>  s     G#Qa#s   c              3   j   "   T F)  w  rVf   K  Vf   K  \        V4      \        V4      3x  K+  	  R # 5irT   r  )r   rn   vs   &  r   r   r    s+     wWX;ij;,q/<?;s   333)r   rj   r   rk   r   dictr,   )objs   &r   r  r    sZ     #eS)**CyG#GGG	C		Cyw		www
r   c          	          V ^8  d   QhR\         R\        \        ,          R\        \        \         \        3,          ,          /# )r   r   r   r   )rC   r   r   r   r   )r   s   "r   r   r     s>     Y% Y%C Y%tJ?O Y%TXY]^acf^fYgTh Y%r   c                   \        \        4      pV F$  pW#P                  ,          P                  V4       K&  	  . pVP	                  4        EF'  pV^ ,          pRRVP
                  RVP                  /RRVP                  RVP                  RVP                  RVP                  RVP                  RVP                  /R	V Uu. uFY  pRVP                  R
VP                  RVP                  RVP                   RVP"                  RVP$                  RVP&                  /NK[  	  up/pVP(                  e0   RVP(                  /p	VP*                  e   VP*                  V	R&   WR&   VP                  V4       EK*  	  RV RV/.p
\-        V
4      # u upi )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   r   r   r   r   r   r   r   r   r^   rB   r   r   r   r   )r   rj   r"   r   valuesr   r=   r;   r   r   r   r   r>   r<   r)   r?   r@   rA   rB   r*   r6   r5   r  )r   r   task_and_ds_types_mapr   model_index_datar   sample_resultr   datar   r   s   &&         r   r   r     s   J :ET9J#;;<CCKP $ (//1
//// 2222-6644M::22  & &F F..V00F..f22F..!6#6#6 &
4 ##/}//F ((4!.!:!:v#N%I 2T J'	
K $$=s   AF
c                    V ^8  d   QhR\         \        \        ,          ,          R\         \        \        ,          ,          /# )r   r   r   rf   )r   s   "r   r   r     s,      (49- (492E r   c                 Z    V f   V # . pV  F  pW!9  g   K  VP                  V4       K  	  V# rT   )r   )r   unique_tagstags   &  r   r   r     s7    |K!s#  r   )rZ   collectionsr   dataclassesr   typingr   r   r   r   r	   r
   huggingface_hub.utilsr   r   
get_loggerrD   r   r   rO   r   r   r   r   r   r  r   r   r3   r   r   <module>r     s     # ! : : 4 
		H	% Tb Tb Tbn P" P" P"f"~CH ~CBMJh MJ`N#H N#beP	Y%xr   