import importlib def load_transformers(name: str, model_pretrain: str): model_module = importlib.import_module(f"models.{name}") model_class = getattr(model_module, name) model_instance = model_class(model_pretrain=model_pretrain) return model_instance