Ë
    ²²j]  ã                  óT   — d Z ddlmZ ddlZg d¢Z eh d£«      Zdddd	œZdd
„Zdd„Z	y)aš  Recover a model's Hub id from the name the results bucket uses.

A manifest filename cannot carry the ``/`` of a Hub id, so the eval scripts write
``model_id.replace("/", "-")`` (see :func:`normalizer.eval_utils`), and the bucket
directory is named the same way. That transform is lossy: once the separator is a
hyphen, nothing in ``abr-ai-niagara-19m-batch.en`` says whether the org is ``abr``
or ``abr-ai``. The tables below carry the information the filename dropped.

    >>> to_hub_id("microsoft-Phi-4-multimodal-instruct")
    'microsoft/Phi-4-multimodal-instruct'
    >>> to_hub_id("ibm-granite-granite-speech-3.3-8b")
    'ibm-granite/granite-speech-3.3-8b'
é    )ÚannotationsN)ÚHYPHENATED_ORGSÚBUCKET_ID_OVERRIDESÚ	to_hub_idÚ
to_hub_ids>   úabr-aiúzai-orgú
AutoArk-AIúibm-graniteúARTPARK-IIScúOpenMOSS-Teamúdistil-whisperúefficient-speechzfacebook/omniASR-CTC-7B-v2zfacebook/omniASR-LLM-7B-v2z(nvidia/stt_en_conformer_transducer_small)ÚomniASR_CTC_7B_v2ÚomniASR_LLM_7B_v2Ú!stt_en_conformer_transducer_smallc                óò   — | t         v r	t         |    S t        t        t        d¬«      D ].  }| j	                  |› d�«      sŒ|› d| t        |«      dz   d › �c S  | j                  d«      \  }}}|r|› d|› �S | S )a1  The Hub id ``bucket_id`` was written from, e.g. ``microsoft/Phi-4-multimodal-instruct``.

    Returns ``bucket_id`` unchanged when it carries no separator to restore and no
    override claims it, so an unrecognised name passes through rather than being
    mangled into a plausible-looking wrong id.
    T)ÚkeyÚreverseú-ú/é   N)r   Úsortedr   ÚlenÚ
startswithÚ	partition)Ú	bucket_idÚorgÚsepÚnames       ú/app/normalizer/model_ids.pyr   r   2   s–   € ð Ô'Ñ'Ü" 9Ñ-Ð-ô ”o¬3¸Ô=ò 8ˆØ×Ñ 3 % q 	Õ*Ø�U˜!˜I¤c¨#£h°¡l nÐ5Ð6Ð7Ò7ð8ð ×(Ñ(¨Ó-�N€CˆˆdÙ!ˆcˆU�!�D�6ˆ?Ð0 yÐ0ó    c                óŽ  ‡— | D �ci c]  }|t        |«      “Œ }}t        j                  |j                  «       «      }t	        d„ |j                  «       D «       «      }|r[|D ]E  Št	        ˆfd„|j                  «       D «       «      }t        ddj                  |«      › d‰› d�«       ŒG | D �ci c]  }||“Œ c}S |S c c}w c c}w )a«  Map each bucket model name in ``models`` to the Hub id to report it under.

    :func:`to_hub_id` applied one at a time cannot see that two bucket names
    landed on the same Hub id, which would silently merge two models' rows into
    one. Checked here instead: on a collision, report it and fall back to the
    bucket names for the whole set, since a recognisable wrong name beats a
    plausible-looking wrong number.
    c              3  ó2   K  — | ]  \  }}|d kD  sŒ|–— Œ y­w)r   N© )Ú.0ÚhubÚns      r!   ú	<genexpr>zto_hub_ids.<locals>.<genexpr>O   s   è ø€ ÒD™f˜c 1¸aÀ!»e”cÑDùs   ‚�c              3  ó4   •K  — | ]  \  }}|‰k(  sŒ|–— Œ y ­w)Nr%   )r&   ÚmÚhr'   s      €r!   r)   zto_hub_ids.<locals>.<genexpr>R   s   øè ø€ ÒC¡4 1 a¸!¸s»(œQÑCùs   ƒ‘z  warning: z and z both map to z; reporting bucket names)r   ÚcollectionsÚCounterÚvaluesr   ÚitemsÚprintÚjoin)ÚmodelsÚmodelÚoutÚ
collisionsÚclashingÚsourcesr'   s         @r!   r   r   D   sÃ   ø€ ð 17Ö
7 uˆ5”)˜EÓ"Ñ"Ð
7€CÐ
7Ü×$Ñ$ S§Z¡Z£\Ó2€JÜÑD¨
×(8Ñ(8Ó(:ÔDÓD€HÙØò 	cˆCÜÓC¨3¯9©9«;ÔCÓCˆGÜ�K §¡¨WÓ 5Ð6°mÀCÀ5ÐH`ÐaÕbð	cð +1Ö1 ��u‘Ò1Ð1Ø€Jùò 8ùò 2s   †B=Â.
C)r   ÚstrÚreturnr9   )r3   z	list[str]r:   zdict[str, str])
Ú__doc__Ú
__future__r   r-   Ú__all__Ú	frozensetr   r   r   r   r%   r"   r!   ú<module>r?      sE   ðñõ #ã â
O€ñ ò	ó€ð& 6Ø5Ø)SñÐ ó1ô$r"   