def METHOD_NAME(cls, model_dir=None, **config):
    init_backbone = config.pop('init_backbone', False)
    # return the model with pretrained weights
    if init_backbone:
        model = AutoModel.from_pretrained(model_dir)
        return model
    # return the model only
    config, kwargs = AutoConfig.from_pretrained(
        model_dir,
        return_unused_kwargs=True,
        trust_remote_code=False,
        **config)
    model_mapping = AutoModel._model_mapping
    if type(config) in model_mapping.keys():
        model_class = _get_model_class(config, model_mapping)
        model = model_class(config)
        model.model_dir = model_dir
        return model
    raise ValueError(
        f'Unrecognized configuration class {config.__class__} for the AutoModel'
        f"Model type should be one of {', '.join(c.__name__ for c in model_mapping.keys())}."
    )