def METHOD_NAME(cls, config: PretrainedConfig, *args, **kwargs) -> 'FiDModelForDownstreamTasks':
    """
    Dynamically creates a model class from a PreTrainedConfig and then uses the config
    with `args` or `kwargs` to instantiate and return a model.
    """
    model_class = cls.model_class_from_config(config)
    model = model_class.from_pretrained(*args, config=config, **kwargs)
    encoder_model = model.get_encoder()
    model.set_encoder(EncoderWrapper(encoder_model))
    return model