Ë
    ÛÓ^jòH  ã                   óÀ  — d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZ d	d
lmZ d	dlmZ d	dlmZmZmZmZ  ej8                  e«      Z eg d¢«      Z ej@                  e«        eee«      Z!de"fd„Z#	 	 	 	 	 	 dde"ejH                  z  de"ejH                  z  dz  de%de&e"e"f   dz  de%e"z  dz  de"dz  de%fd„Z' G d„ d«      Z(ddgZ)y)zAutoFeatureExtractor class.é    N)ÚOrderedDicté   )ÚPreTrainedConfig)Úget_class_from_dynamic_moduleÚresolve_trust_remote_code)ÚFeatureExtractionMixin)ÚCONFIG_NAMEÚFEATURE_EXTRACTOR_NAMEÚPROCESSOR_NAMEÚcached_fileÚloggingÚsafe_load_json_fileé   )Ú_LazyAutoMapping)ÚFEATURE_EXTRACTOR_MAPPING_NAMES)ÚCONFIG_MAPPING_NAMESÚ
AutoConfigÚmodel_type_to_module_nameÚ!replace_list_option_in_docstrings)#)Úaudioflamingo3ÚWhisperFeatureExtractor)ÚcsmÚEncodecFeatureExtractor)zdata2vec-audioÚWav2Vec2FeatureExtractor)Úglmasrr   )Úgranite_speech_plusÚGraniteSpeechFeatureExtractor)Úhiggs_audio_v2_tokenizerÚDacFeatureExtractor)Úhubertr   )Úinkling_mm_modelÚInklingFeatureExtractor)Úlasr_ctcÚLasrFeatureExtractor)Úlasr_encoderr$   )Úmimir   )Ú	moonshiner   )Úmoshir   )Úmusicgenr   )Únemotron3_5_asrÚ$NemotronAsrStreamingFeatureExtractor)Únemotron_asr_streaming_encoderr+   )Úparakeet_ctcÚParakeetFeatureExtractor)Úparakeet_encoderr.   )Úparakeet_rnntr.   )Úparakeet_tdtr.   )Úpe_audio_videoÚPeAudioFeatureExtractor)Úqwen2_5_omnir   )Úqwen2_audior   )Úqwen3_omni_moer   )Úseamless_m4t_v2ÚSeamlessM4TFeatureExtractor)Úsewr   )zsew-dr   )Ú	unispeechr   )zunispeech-satr   )Úvibevoice_asrÚ*VibeVoiceAcousticTokenizerFeatureExtractor)Úvoxtralr   )zwav2vec2-bertr   )zwav2vec2-conformerr   )Úwavlmr   )Úxcodecr   Ú
class_namec                 ó�  — t        j                  «       D ]<  \  }}| |v sŒt        |«      }t        j                  d|› �d«      }	 t        || «      c S  t        j                  j                  «       D ]  }t        |dd «      | k(  sŒ|c S  t        j                  d«      }t        || «      rt        || «      S y # t        $ r Y Œ¯w xY w)Nú.ztransformers.modelsÚ__name__Útransformers)r   Úitemsr   Ú	importlibÚimport_moduleÚgetattrÚAttributeErrorÚFEATURE_EXTRACTOR_MAPPINGÚ_extra_contentÚvaluesÚhasattr)r@   Úmodule_nameÚ
extractorsÚmoduleÚ	extractorÚmain_modules         ú{/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/auto/feature_extraction_auto.pyÚ!feature_extractor_class_from_namerT   Q   sÔ   € Ü#B×#HÑ#HÓ#Jò Ñˆ�ZØ˜Ò#Ü3°KÓ@ˆKä×,Ñ,¨q°°Ð->Ð@UÓVˆFðÜ˜v zÓ2Ò2ðô /×=Ñ=×DÑDÓFò ˆ	Ü�9˜j¨$Ó/°:Ó=ØÒðô ×)Ñ)¨.Ó9€KÜˆ{˜JÔ'Ü�{ JÓ/Ð/àøô "ò Ùðús   ÁB9Â9	CÃCÚpretrained_model_name_or_pathÚ	cache_dirÚforce_downloadÚproxiesÚtokenÚrevisionÚlocal_files_onlyc                 óî   — t        | t        ||||||dd¬«
      }t        | t        ||||||dd¬«
      }	|	s|st        j	                  d«       i S i }
|�t        |«      }d|v r|d   }
|	�|
€t        |	«      }
|
S )a  
    Loads the feature extractor configuration from a pretrained model feature extractor configuration.

    Args:
        pretrained_model_name_or_path (`str` or `os.PathLike`):
            This can be either:

            - a string, the *model id* of a pretrained model configuration hosted inside a model repo on
              huggingface.co.
            - a path to a *directory* containing a configuration file saved using the
              [`~FeatureExtractionMixin.save_pretrained`] method, e.g., `./my_model_directory/`.

        cache_dir (`str` or `os.PathLike`, *optional*):
            Path to a directory in which a downloaded pretrained model configuration should be cached if the standard
            cache should not be used.
        force_download (`bool`, *optional*, defaults to `False`):
            Whether or not to force to (re-)download the configuration files and override the cached versions if they
            exist.
        proxies (`dict[str, str]`, *optional*):
            A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
            'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
        token (`str` or *bool*, *optional*):
            The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
            when running `hf auth login` (stored in `~/.huggingface`).
        revision (`str`, *optional*, defaults to `"main"`):
            The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
            git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
            identifier allowed by git.
        local_files_only (`bool`, *optional*, defaults to `False`):
            If `True`, will only try to load the feature extractor configuration from local files.

    <Tip>

    Passing `token=True` is required when you want to use a private model.

    </Tip>

    Returns:
        `Dict`: The configuration of the feature extractor.

    Examples:

    ```python
    # Download configuration from huggingface.co and cache.
    feature_extractor_config = get_feature_extractor_config("facebook/wav2vec2-base-960h")
    # This model does not have a feature extractor config so the result will be an empty dict.
    feature_extractor_config = get_feature_extractor_config("FacebookAI/xlm-roberta-base")

    # Save a pretrained feature extractor locally and you can reload its config
    from transformers import AutoFeatureExtractor

    feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")
    feature_extractor.save_pretrained("feature-extractor-test")
    feature_extractor_config = get_feature_extractor_config("feature-extractor-test")
    ```F)	ÚfilenamerV   rW   rX   rY   rZ   r[   Ú _raise_exceptions_for_gated_repoÚ%_raise_exceptions_for_missing_entriesz:Could not locate the feature extractor configuration file.Úfeature_extractor)r   r   r
   ÚloggerÚinfor   )rU   rV   rW   rX   rY   rZ   r[   ÚkwargsÚresolved_processor_fileÚresolved_feature_extractor_fileÚfeature_extractor_dictÚprocessor_dicts               rS   Úget_feature_extractor_configrh   i   s¾   € ôD *Ø%ÜØØ%ØØØØ)Ø).Ø.3ôÐô '2Ø%Ü'ØØ%ØØØØ)Ø).Ø.3ô'Ð#ñ +Ñ3JÜ�‰ÐPÔQØˆ	ð
  ÐØÐ*Ü,Ð-DÓEˆØ .Ñ0Ø%3Ð4GÑ%HÐ"à&Ð2Ð7MÐ7UÜ!4Ð5TÓ!UÐØ!Ð!ó    c                   óN   — e Zd ZdZd„ Ze ee«      d„ «       «       Ze	dd„«       Z
y)ÚAutoFeatureExtractora+  
    This is a generic feature extractor class that will be instantiated as one of the feature extractor classes of the
    library when created with the [`AutoFeatureExtractor.from_pretrained`] class method.

    This class cannot be instantiated directly using `__init__()` (throws an error).
    c                 ó   — t        d«      ‚)Nz‹AutoFeatureExtractor is designed to be instantiated using the `AutoFeatureExtractor.from_pretrained(pretrained_model_name_or_path)` method.)ÚOSError)Úselfs    rS   Ú__init__zAutoFeatureExtractor.__init__ß   s   € Üðfó
ð 	
ri   c                 ó`  — |j                  dd«      }|j                  dd«      }d|d<   t        j                  |fi |¤Ž\  }}|j                  dd«      }d}d|j                  di «      v r|d   d   }|€`|€^t	        |t
        «      st        j                  |fd|i|¤Ž}t        |dd«      }t        |d«      rd|j                  v r|j                  d   }|�t        |«      }|du}	|duxs t        |«      t        v }
|
xr0 |xs t        t        |«         j                  j                  d	«       }|	r*d
|v r|j!                  d
«      d   }nd}t#        |||
|	|«      }|	rF|rD|sBt%        ||fi |¤Ž}|j                  dd«      }|j'                  «         |j                  |fi |¤ŽS |� |j                  |fi |¤ŽS t        |«      t        v r%t        t        |«         } |j                  |fi |¤ŽS t)        d|› dt*        › dt,        › dt,        › ddj/                  d„ t0        D «       «      › �
«      ‚)aÂ  
        Instantiate one of the feature extractor classes of the library from a pretrained model vocabulary.

        The feature extractor class to instantiate is selected based on the `model_type` property of the config object
        (either passed as an argument or loaded from `pretrained_model_name_or_path` if possible), or when it's
        missing, by falling back to using pattern matching on `pretrained_model_name_or_path`:

        List options

        Params:
            pretrained_model_name_or_path (`str` or `os.PathLike`):
                This can be either:

                - a string, the *model id* of a pretrained feature_extractor hosted inside a model repo on
                  huggingface.co.
                - a path to a *directory* containing a feature extractor file saved using the
                  [`~feature_extraction_utils.FeatureExtractionMixin.save_pretrained`] method, e.g.,
                  `./my_model_directory/`.
                - a path to a saved feature extractor JSON *file*, e.g.,
                  `./my_model_directory/preprocessor_config.json`.
            cache_dir (`str` or `os.PathLike`, *optional*):
                Path to a directory in which a downloaded pretrained model feature extractor should be cached if the
                standard cache should not be used.
            force_download (`bool`, *optional*, defaults to `False`):
                Whether or not to force to (re-)download the feature extractor files and override the cached versions
                if they exist.
            proxies (`dict[str, str]`, *optional*):
                A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request.
            token (`str` or *bool*, *optional*):
                The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
                when running `hf auth login` (stored in `~/.huggingface`).
            revision (`str`, *optional*, defaults to `"main"`):
                The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
                git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any
                identifier allowed by git.
            return_unused_kwargs (`bool`, *optional*, defaults to `False`):
                If `False`, then this function returns just the final feature extractor object. If `True`, then this
                functions returns a `Tuple(feature_extractor, unused_kwargs)` where *unused_kwargs* is a dictionary
                consisting of the key/value pairs whose keys are not feature extractor attributes: i.e., the part of
                `kwargs` which has not been used to update `feature_extractor` and is otherwise ignored.
            trust_remote_code (`bool`, *optional*, defaults to `False`):
                Whether or not to allow for custom models defined on the Hub in their own modeling files. This option
                should only be set to `True` for repositories you trust and in which you have read the code, as it will
                execute code present on the Hub on your local machine.
            kwargs (`dict[str, Any]`, *optional*):
                The values in kwargs of any keys which are feature extractor attributes will be used to override the
                loaded values. Behavior concerning key/value pairs whose keys are *not* feature extractor attributes is
                controlled by the `return_unused_kwargs` keyword parameter.

        <Tip>

        Passing `token=True` is required when you want to use a private model.

        </Tip>

        Examples:

        ```python
        >>> from transformers import AutoFeatureExtractor

        >>> # Download feature extractor from huggingface.co and cache.
        >>> feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")

        >>> # If feature extractor files are in a directory (e.g. feature extractor was saved using *save_pretrained('./test/saved_model/')*)
        >>> # feature_extractor = AutoFeatureExtractor.from_pretrained("./test/saved_model/")
        ```ÚconfigNÚtrust_remote_codeTÚ
_from_autoÚfeature_extractor_typerk   Úauto_mapztransformers.z--r   Úcode_revisionz"Unrecognized feature extractor in z4. Should have a `feature_extractor_type` key in its z of z3, or one of the following `model_type` keys in its z: z, c              3   ó    K  — | ]  }|–— Œ y ­w)N© )Ú.0Úcs     rS   ú	<genexpr>z7AutoFeatureExtractor.from_pretrained.<locals>.<genexpr>b  s   è ø€ Ò@lÀqÄÑ@lùs   ‚)Úpopr   Úget_feature_extractor_dictÚgetÚ
isinstancer   r   Úfrom_pretrainedrH   rM   ru   rT   ÚtyperJ   Ú
__module__Ú
startswithÚsplitr   r   Úregister_for_auto_classÚ
ValueErrorr
   r	   Újoinr   )ÚclsrU   rc   rq   rr   Úconfig_dictÚ_Úfeature_extractor_classÚfeature_extractor_auto_mapÚhas_remote_codeÚhas_local_codeÚexplicit_local_codeÚupstream_repos                rS   r€   z$AutoFeatureExtractor.from_pretrainedå   s¨  € ðL —‘˜H dÓ+ˆØ"ŸJ™JÐ':¸DÓAÐØ#ˆˆ|Ñä/×JÑJÐKhÑsÐlrÑs‰ˆ�QØ"-§/¡/Ð2JÈDÓ"QÐØ%)Ð"Ø! [§_¡_°ZÀÓ%DÑDØ)4°ZÑ)@ÐAWÑ)XÐ&ð #Ð*Ð/IÐ/QÜ˜fÔ&6Ô7Ü#×3Ñ3Ø1ñØEVðØZ`ñ�ô '.¨fÐ6NÐPTÓ&UÐ#Ü�v˜zÔ*Ð/EÈÏÉÑ/XØ-3¯_©_Ð=SÑ-TÐ*à"Ð.Ü&GÐH_Ó&`Ð#à4¸DÐ@ˆØ0¸Ð<ÒiÄÀVÃÔPiÐ@iˆØ,ò 1Ø#ÒNÔ'@ÄÀfÃÑ'Nß
‰*—Z‘Z Ó0ð21Ðñ ØÐ1Ñ1Ø :× @Ñ @ÀÓ FÀqÑ I‘à $�Ü 9Ø!Ð#@À.ÐRaÐcpó!Ðñ Ñ0Ñ9LÜ&CØ*Ð,Iñ'ØMSñ'Ð#ð —
‘
˜?¨DÓ1ˆAØ#×;Ñ;Ô=Ø:Ð*×:Ñ:Ð;XÑcÐ\bÑcÐcØ$Ð0Ø:Ð*×:Ñ:Ð;XÑcÐ\bÑcÐcä�&‹\Ô6Ñ6Ü&?ÄÀVÃÑ&MÐ#Ø:Ð*×:Ñ:Ð;XÑcÐ\bÑcÐcäØ0Ð1NÐ0Oð P3Ü3IÐ2JÈ$Ì{Èmð \(Ü(3 }°B°t·y±yÑ@lÔLkÔ@lÓ7lÐ6mðoó
ð 	
ri   c                 ó4   — t         j                  | ||¬«       y)a0  
        Register a new feature extractor for this class.

        Args:
            config_class ([`PreTrainedConfig`]):
                The configuration corresponding to the model to register.
            feature_extractor_class ([`FeatureExtractorMixin`]): The feature extractor to register.
        )Úexist_okN)rJ   Úregister)Úconfig_classr‹   r’   s      rS   r“   zAutoFeatureExtractor.registere  s   € ô 	"×*Ñ*¨<Ð9PÐ[cÐ*Õdri   N)F)rC   r‚   Ú__qualname__Ú__doc__ro   Úclassmethodr   r   r€   Ústaticmethodr“   rx   ri   rS   rk   rk   ×   sH   „ ñò
ð Ù&Ð'FÓGñ|
ó Hó ð|
ð| ò	eó ñ	eri   rk   rJ   )NFNNNF)*r–   rF   ÚosÚcollectionsr   Úconfiguration_utilsr   Údynamic_module_utilsr   r   Úfeature_extraction_utilsr   Úutilsr	   r
   r   r   r   r   Úauto_factoryr   Úauto_mappingsr   Úconfiguration_autor   r   r   r   Ú
get_loggerrC   ra   Ú'MISSING_FEATURE_EXTRACTOR_MAPPING_NAMESÚupdaterJ   ÚstrrT   ÚPathLikeÚboolÚdictrh   rk   Ú__all__rx   ri   rS   ú<module>rª      s9  ðñ "ã Û 	Ý #õ 4ß \Ý >ß s× sÝ *Ý :÷ó ð 
ˆ×	Ñ	˜HÓ	%€á*5ò$ó&+Ð 'ðP 'Ð × &Ñ &Ð'NÔ OÙ,Ð-AÐCbÓcÐ ð°#ó ð4 +/Ø Ø%)Ø#ØØ"ñk"Ø#&¨¯©Ñ#4ðk"à�R—[‘[Ñ  4Ñ'ðk"ð ðk"ð �#�s�(‰^˜dÑ"ð	k"ð
 �#‰:˜Ñðk"ð �D‰jðk"ð ók"÷\Xeñ Xeðv 'Ð(>Ð
?�ri   