codingutf8 2021 the huggingface inc team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache orglicenseslicense2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license autofeatureextractor class import importlib import json import os import warnings from collections import ordereddict from typing import dict optional union build the list of all feature extractors from configurationutils import pretrainedconfig from dynamicmoduleutils import getclassfromdynamicmodule resolvetrustremotecode from featureextractionutils import featureextractionmixin from utils import configname featureextractorname getfilefromrepo logging from autofactory import lazyautomapping from configurationauto import configmappingnames autoconfig modeltypetomodulename replacelistoptionindocstrings logger logging getloggername featureextractormappingnames ordereddict audiospectrogramtransformer astfeatureextractor beit beitfeatureextractor chineseclip chineseclipfeatureextractor clap clapfeatureextractor clip clipfeatureextractor clipseg vitfeatureextractor clvp clvpfeatureextractor conditionaldetr conditionaldetrfeatureextractor convnext convnextfeatureextractor cvt convnextfeatureextractor data2vecaudio wav2vec2featureextractor data2vecvision beitfeatureextractor deformabledetr deformabledetrfeatureextractor deit deitfeatureextractor detr detrfeatureextractor dinat vitfeatureextractor donutswin donutfeatureextractor dpt dptfeatureextractor encodec encodecfeatureextractor flava flavafeatureextractor glpn glpnfeatureextractor groupvit clipfeatureextractor hubert wav2vec2featureextractor imagegpt imagegptfeatureextractor layoutlmv2 layoutlmv2featureextractor layoutlmv3 layoutlmv3featureextractor levit levitfeatureextractor maskformer maskformerfeatureextractor mctct mctctfeatureextractor mobilenetv1 mobilenetv1featureextractor mobilenetv2 mobilenetv2featureextractor mobilevit mobilevitfeatureextractor nat vitfeatureextractor owlvit owlvitfeatureextractor perceiver perceiverfeatureextractor poolformer poolformerfeatureextractor pop2piano pop2pianofeatureextractor regnet convnextfeatureextractor resnet convnextfeatureextractor seamlessm4t seamlessm4tfeatureextractor segformer segformerfeatureextractor sew wav2vec2featureextractor sewd wav2vec2featureextractor speechtotext speech2textfeatureextractor speecht5 speecht5featureextractor swiftformer vitfeatureextractor swin vitfeatureextractor swinv2 vitfeatureextractor tabletransformer detrfeatureextractor timesformer videomaefeatureextractor tvlt tvltfeatureextractor unispeech wav2vec2featureextractor unispeechsat wav2vec2featureextractor univnet univnetfeatureextractor van convnextfeatureextractor videomae videomaefeatureextractor vilt viltfeatureextractor vit vitfeatureextractor vitmae vitfeatureextractor vitmsn vitfeatureextractor wav2vec2 wav2vec2featureextractor wav2vec2conformer wav2vec2featureextractor wavlm wav2vec2featureextractor whisper whisperfeatureextractor xclip clipfeatureextractor yolos yolosfeatureextractor featureextractormapping lazyautomappingconfigmappingnames featureextractormappingnames def featureextractorclassfromnameclassname str for modulename extractors in featureextractormappingnames items if classname in extractors modulename modeltypetomodulenamemodulename module importlib importmodulef modulename transformers models try return getattrmodule classname except attributeerror continue for extractor in featureextractormapping extracontent items if getattrextractor name none classname return extractor we did not fine the class but maybe it s because a dep is missing in that case the class will be in the main init and we return the proper dummy to get an appropriate error message mainmodule importlib importmoduletransformers if hasattrmainmodule classname return getattrmainmodule classname return none def getfeatureextractorconfig pretrainedmodelnameorpath unionstr os pathlike cachedir optionalunionstr os pathlike none forcedownload bool false resumedownload bool false proxies optionaldictstr str none token optionalunionbool str none revision optionalstr none localfilesonly bool false kwargs download configuration from huggingface co and cache this model does not have a tokenizer config so the result will be an empty dict save a pretrained tokenizer locally and you can reload its config def initself raise environmenterror autofeatureextractor is designed to be instantiated using the autofeatureextractor frompretrainedpretrainedmodelnameorpath method classmethod replacelistoptionindocstringsfeatureextractormappingnames def frompretrainedcls pretrainedmodelnameorpath kwargs r 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 modeltype property of the config object either passed as an argument or loaded from pretrainedmodelnameorpath if possible or when it s missing by falling back to using pattern matching on pretrainedmodelnameorpath list options params pretrainedmodelnameorpath str or os pathlike this can be either a string the model id of a pretrained featureextractor hosted inside a model repo on huggingface co valid model ids can be located at the rootlevel like bertbaseuncased or namespaced under a user or organization name like dbmdzbertbasegermancased a path to a directory containing a feature extractor file saved using the featureextractionutils featureextractionmixin savepretrained method e g mymodeldirectory a path or url to a saved feature extractor json file e g mymodeldirectorypreprocessorconfig json cachedir 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 forcedownload bool optional defaults to false whether or not to force to redownload the feature extractor files and override the cached versions if they exist resumedownload bool optional defaults to false whether or not to delete incompletely received file attempts to resume the download if such a file exists proxies dictstr 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 ization for remote files if true will use the token generated when running huggingfacecli 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 gitbased system for storing models and other artifacts on huggingface co so revision can be any identifier allowed by git returnunusedkwargs bool optional defaults to false if false then this function returns just the final feature extractor object if true then this functions returns a tuplefeatureextractor unusedkwargs where unusedkwargs is a dictionary consisting of the keyvalue pairs whose keys are not feature extractor attributes i e the part of kwargs which has not been used to update featureextractor and is otherwise ignored trustremotecode 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 dictstr any optional the values in kwargs of any keys which are feature extractor attributes will be used to override the loaded values behavior concerning keyvalue pairs whose keys are not feature extractor attributes is controlled by the returnunusedkwargs keyword parameter tip passing tokentrue 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 featureextractor autofeatureextractor frompretrainedfacebookwav2vec2base960h if feature extractor files are in a directory e g feature extractor was saved using savepretrained testsavedmodel featureextractor autofeatureextractor frompretrained testsavedmodel useauthtoken kwargs popuseauthtoken none if useauthtoken is not none warnings warn the useauthtoken argument is deprecated and will be removed in v5 of transformers please use token instead futurewarning if kwargs gettoken none is not none raise valueerror token and useauthtoken are both specified please set only the argument token kwargstoken useauthtoken config kwargs popconfig none trustremotecode kwargs poptrustremotecode none kwargsfromauto true configdict featureextractionmixin getfeatureextractordictpretrainedmodelnameorpath kwargs featureextractorclass configdict getfeatureextractortype none featureextractorautomap none if autofeatureextractor in configdict getautomap featureextractorautomap configdictautomapautofeatureextractor if we don t find the feature extractor class in the feature extractor config let s try the model config if featureextractorclass is none and featureextractorautomap is none if not isinstanceconfig pretrainedconfig config autoconfig frompretrainedpretrainedmodelnameorpath kwargs it could be in config featureextractortype featureextractorclass getattrconfig featureextractortype none if hasattrconfig automap and autofeatureextractor in config automap featureextractorautomap config automapautofeatureextractor if featureextractorclass is not none featureextractorclass featureextractorclassfromnamefeatureextractorclass hasremotecode featureextractorautomap is not none haslocalcode featureextractorclass is not none or typeconfig in featureextractormapping trustremotecode resolvetrustremotecode trustremotecode pretrainedmodelnameorpath haslocalcode hasremotecode if hasremotecode and trustremotecode featureextractorclass getclassfromdynamicmodule featureextractorautomap pretrainedmodelnameorpath kwargs kwargs popcoderevision none if os path isdirpretrainedmodelnameorpath featureextractorclass registerforautoclass return featureextractorclass fromdictconfigdict kwargs elif featureextractorclass is not none return featureextractorclass fromdictconfigdict kwargs last try we use the featureextractormapping elif typeconfig in featureextractormapping featureextractorclass featureextractormappingtypeconfig return featureextractorclass fromdictconfigdict kwargs raise valueerror funrecognized feature extractor in pretrainedmodelnameorpath should have a ffeatureextractortype key in its featureextractorname of configname or one of the following fmodeltype keys in its configname joinc for c in featureextractormappingnames keys staticmethod def registerconfigclass featureextractorclass existokfalse featureextractormapping registerconfigclass featureextractorclass existokexistok coding utf 8 2021 the huggingface inc team licensed under the apache license version 2 0 the license you may not use this file except in compliance with the license you may obtain a copy of the license at http www apache org licenses license 2 0 unless required by applicable law or agreed to in writing software distributed under the license is distributed on an as is basis without warranties or conditions of any kind either express or implied see the license for the specific language governing permissions and limitations under the license autofeatureextractor class build the list of all feature extractors we did not fine the class but maybe it s because a dep is missing in that case the class will be in the main init and we return the proper dummy to get an appropriate error message loads the tokenizer configuration from a pretrained model tokenizer 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 valid model ids can be located at the root level like bert base uncased or namespaced under a user or organization name like dbmdz bert base german cased a path to a directory containing a configuration file saved using the pretrainedtokenizer 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 resume_download bool optional defaults to false whether or not to delete incompletely received file attempts to resume the download if such a file exists 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 ization for remote files if true will use the token generated when running huggingface cli 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 tokenizer 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 tokenizer examples python download configuration from huggingface co and cache tokenizer_config get_tokenizer_config bert base uncased this model does not have a tokenizer config so the result will be an empty dict tokenizer_config get_tokenizer_config xlm roberta base save a pretrained tokenizer locally and you can reload its config from transformers import autotokenizer tokenizer autotokenizer from_pretrained bert base cased tokenizer save_pretrained tokenizer test tokenizer_config get_tokenizer_config tokenizer test 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 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 valid model ids can be located at the root level like bert base uncased or namespaced under a user or organization name like dbmdz bert base german cased 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 or url 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 resume_download bool optional defaults to false whether or not to delete incompletely received file attempts to resume the download if such a file exists 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 ization for remote files if true will use the token generated when running huggingface cli 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 if we don t find the feature extractor class in the feature extractor config let s try the model config it could be in config feature_extractor_type last try we use the feature_extractor_mapping 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
import importlib
import json
import os
import warnings
from collections import OrderedDict
from typing import Dict, Optional, Union


from ...configuration_utils import PretrainedConfig
from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code
from ...feature_extraction_utils import FeatureExtractionMixin
from ...utils import CONFIG_NAME, FEATURE_EXTRACTOR_NAME, get_file_from_repo, logging
from .auto_factory import _LazyAutoMapping
from .configuration_auto import (
    CONFIG_MAPPING_NAMES,
    AutoConfig,
    model_type_to_module_name,
    replace_list_option_in_docstrings,
)


logger = logging.get_logger(__name__)

FEATURE_EXTRACTOR_MAPPING_NAMES = OrderedDict(
    [
        ("audio-spectrogram-transformer", "ASTFeatureExtractor"),
        ("beit", "BeitFeatureExtractor"),
        ("chinese_clip", "ChineseCLIPFeatureExtractor"),
        ("clap", "ClapFeatureExtractor"),
        ("clip", "CLIPFeatureExtractor"),
        ("clipseg", "ViTFeatureExtractor"),
        ("clvp", "ClvpFeatureExtractor"),
        ("conditional_detr", "ConditionalDetrFeatureExtractor"),
        ("convnext", "ConvNextFeatureExtractor"),
        ("cvt", "ConvNextFeatureExtractor"),
        ("data2vec-audio", "Wav2Vec2FeatureExtractor"),
        ("data2vec-vision", "BeitFeatureExtractor"),
        ("deformable_detr", "DeformableDetrFeatureExtractor"),
        ("deit", "DeiTFeatureExtractor"),
        ("detr", "DetrFeatureExtractor"),
        ("dinat", "ViTFeatureExtractor"),
        ("donut-swin", "DonutFeatureExtractor"),
        ("dpt", "DPTFeatureExtractor"),
        ("encodec", "EncodecFeatureExtractor"),
        ("flava", "FlavaFeatureExtractor"),
        ("glpn", "GLPNFeatureExtractor"),
        ("groupvit", "CLIPFeatureExtractor"),
        ("hubert", "Wav2Vec2FeatureExtractor"),
        ("imagegpt", "ImageGPTFeatureExtractor"),
        ("layoutlmv2", "LayoutLMv2FeatureExtractor"),
        ("layoutlmv3", "LayoutLMv3FeatureExtractor"),
        ("levit", "LevitFeatureExtractor"),
        ("maskformer", "MaskFormerFeatureExtractor"),
        ("mctct", "MCTCTFeatureExtractor"),
        ("mobilenet_v1", "MobileNetV1FeatureExtractor"),
        ("mobilenet_v2", "MobileNetV2FeatureExtractor"),
        ("mobilevit", "MobileViTFeatureExtractor"),
        ("nat", "ViTFeatureExtractor"),
        ("owlvit", "OwlViTFeatureExtractor"),
        ("perceiver", "PerceiverFeatureExtractor"),
        ("poolformer", "PoolFormerFeatureExtractor"),
        ("pop2piano", "Pop2PianoFeatureExtractor"),
        ("regnet", "ConvNextFeatureExtractor"),
        ("resnet", "ConvNextFeatureExtractor"),
        ("seamless_m4t", "SeamlessM4TFeatureExtractor"),
        ("segformer", "SegformerFeatureExtractor"),
        ("sew", "Wav2Vec2FeatureExtractor"),
        ("sew-d", "Wav2Vec2FeatureExtractor"),
        ("speech_to_text", "Speech2TextFeatureExtractor"),
        ("speecht5", "SpeechT5FeatureExtractor"),
        ("swiftformer", "ViTFeatureExtractor"),
        ("swin", "ViTFeatureExtractor"),
        ("swinv2", "ViTFeatureExtractor"),
        ("table-transformer", "DetrFeatureExtractor"),
        ("timesformer", "VideoMAEFeatureExtractor"),
        ("tvlt", "TvltFeatureExtractor"),
        ("unispeech", "Wav2Vec2FeatureExtractor"),
        ("unispeech-sat", "Wav2Vec2FeatureExtractor"),
        ("univnet", "UnivNetFeatureExtractor"),
        ("van", "ConvNextFeatureExtractor"),
        ("videomae", "VideoMAEFeatureExtractor"),
        ("vilt", "ViltFeatureExtractor"),
        ("vit", "ViTFeatureExtractor"),
        ("vit_mae", "ViTFeatureExtractor"),
        ("vit_msn", "ViTFeatureExtractor"),
        ("wav2vec2", "Wav2Vec2FeatureExtractor"),
        ("wav2vec2-conformer", "Wav2Vec2FeatureExtractor"),
        ("wavlm", "Wav2Vec2FeatureExtractor"),
        ("whisper", "WhisperFeatureExtractor"),
        ("xclip", "CLIPFeatureExtractor"),
        ("yolos", "YolosFeatureExtractor"),
    ]
)

FEATURE_EXTRACTOR_MAPPING = _LazyAutoMapping(CONFIG_MAPPING_NAMES, FEATURE_EXTRACTOR_MAPPING_NAMES)


def feature_extractor_class_from_name(class_name: str):
    for module_name, extractors in FEATURE_EXTRACTOR_MAPPING_NAMES.items():
        if class_name in extractors:
            module_name = model_type_to_module_name(module_name)

            module = importlib.import_module(f".{module_name}", "transformers.models")
            try:
                return getattr(module, class_name)
            except AttributeError:
                continue

    for _, extractor in FEATURE_EXTRACTOR_MAPPING._extra_content.items():
        if getattr(extractor, "__name__", None) == class_name:
            return extractor

    
    
    main_module = importlib.import_module("transformers")
    if hasattr(main_module, class_name):
        return getattr(main_module, class_name)

    return None


def get_feature_extractor_config(
    pretrained_model_name_or_path: Union[str, os.PathLike],
    cache_dir: Optional[Union[str, os.PathLike]] = None,
    force_download: bool = False,
    resume_download: bool = False,
    proxies: Optional[Dict[str, str]] = None,
    token: Optional[Union[bool, str]] = None,
    revision: Optional[str] = None,
    local_files_only: bool = False,
    **kwargs,
):
    
    use_auth_token = kwargs.pop("use_auth_token", None)
    if use_auth_token is not None:
        warnings.warn(
            "The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
            FutureWarning,
        )
        if token is not None:
            raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
        token = use_auth_token

    resolved_config_file = get_file_from_repo(
        pretrained_model_name_or_path,
        FEATURE_EXTRACTOR_NAME,
        cache_dir=cache_dir,
        force_download=force_download,
        resume_download=resume_download,
        proxies=proxies,
        token=token,
        revision=revision,
        local_files_only=local_files_only,
    )
    if resolved_config_file is None:
        logger.info(
            "Could not locate the feature extractor configuration file, will try to use the model config instead."
        )
        return {}

    with open(resolved_config_file, encoding="utf-8") as reader:
        return json.load(reader)


class AutoFeatureExtractor:
    r

    def __init__(self):
        raise EnvironmentError(
            "AutoFeatureExtractor is designed to be instantiated "
            "using the `AutoFeatureExtractor.from_pretrained(pretrained_model_name_or_path)` method."
        )

    @classmethod
    @replace_list_option_in_docstrings(FEATURE_EXTRACTOR_MAPPING_NAMES)
    def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
        r
        use_auth_token = kwargs.pop("use_auth_token", None)
        if use_auth_token is not None:
            warnings.warn(
                "The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers. Please use `token` instead.",
                FutureWarning,
            )
            if kwargs.get("token", None) is not None:
                raise ValueError(
                    "`token` and `use_auth_token` are both specified. Please set only the argument `token`."
                )
            kwargs["token"] = use_auth_token

        config = kwargs.pop("config", None)
        trust_remote_code = kwargs.pop("trust_remote_code", None)
        kwargs["_from_auto"] = True

        config_dict, _ = FeatureExtractionMixin.get_feature_extractor_dict(pretrained_model_name_or_path, **kwargs)
        feature_extractor_class = config_dict.get("feature_extractor_type", None)
        feature_extractor_auto_map = None
        if "AutoFeatureExtractor" in config_dict.get("auto_map", {}):
            feature_extractor_auto_map = config_dict["auto_map"]["AutoFeatureExtractor"]

        
        if feature_extractor_class is None and feature_extractor_auto_map is None:
            if not isinstance(config, PretrainedConfig):
                config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
            
            feature_extractor_class = getattr(config, "feature_extractor_type", None)
            if hasattr(config, "auto_map") and "AutoFeatureExtractor" in config.auto_map:
                feature_extractor_auto_map = config.auto_map["AutoFeatureExtractor"]

        if feature_extractor_class is not None:
            feature_extractor_class = feature_extractor_class_from_name(feature_extractor_class)

        has_remote_code = feature_extractor_auto_map is not None
        has_local_code = feature_extractor_class is not None or type(config) in FEATURE_EXTRACTOR_MAPPING
        trust_remote_code = resolve_trust_remote_code(
            trust_remote_code, pretrained_model_name_or_path, has_local_code, has_remote_code
        )

        if has_remote_code and trust_remote_code:
            feature_extractor_class = get_class_from_dynamic_module(
                feature_extractor_auto_map, pretrained_model_name_or_path, **kwargs
            )
            _ = kwargs.pop("code_revision", None)
            if os.path.isdir(pretrained_model_name_or_path):
                feature_extractor_class.register_for_auto_class()
            return feature_extractor_class.from_dict(config_dict, **kwargs)
        elif feature_extractor_class is not None:
            return feature_extractor_class.from_dict(config_dict, **kwargs)
        
        elif type(config) in FEATURE_EXTRACTOR_MAPPING:
            feature_extractor_class = FEATURE_EXTRACTOR_MAPPING[type(config)]
            return feature_extractor_class.from_dict(config_dict, **kwargs)

        raise ValueError(
            f"Unrecognized feature extractor in {pretrained_model_name_or_path}. Should have a "
            f"`feature_extractor_type` key in its {FEATURE_EXTRACTOR_NAME} of {CONFIG_NAME}, or one of the following "
            f"`model_type` keys in its {CONFIG_NAME}: {', '.join(c for c in FEATURE_EXTRACTOR_MAPPING_NAMES.keys())}"
        )

    @staticmethod
    def register(config_class, feature_extractor_class, exist_ok=False):
        
        FEATURE_EXTRACTOR_MAPPING.register(config_class, feature_extractor_class, exist_ok=exist_ok)