docstr: Loads a model by name
  
  Args:
      model_name: unique name of the model
      aliases: dictionary that maps aliases to model_name
      device: device to use model on. Defaults to "cuda" if available
  
  Returns:
      Initialised model object
  
  Example::
  
      import backprop
  
      model = backprop.models.AutoModel.from_pretrained("t5_small")
docstr_tok: ["Loads","a","model","by","name","Args",":","model_name",":","unique","name","of","the","model","aliases",":","dictionary","that","maps","aliases","to","model_name","device",":","device","to","use","model","on",".","Defaults","to","``","cuda","''","if","available","Returns",":","Initialised","model","object","Example",":",":","import","backprop","model","=","backprop.models.AutoModel.from_pretrained","(","``","t5_small","''",")"]
code: def from_pretrained(
      model_name: str, aliases: Dict = None, device: str = None
  ):
      """
      Loads a model by name
  
      Args:
          model_name: unique name of the model
          aliases: dictionary that maps aliases to model_name
          device: device to use model on. Defaults to "cuda" if available
  
      Returns:
          Initialised model object
  
      Example::
  
          import backprop
  
          model = backprop.models.AutoModel.from_pretrained("t5_small")
      """
      if device == None:
          device = "cuda" if torch.cuda.is_available() else "cpu"
  
      model = None
  
      models = AutoModel.list_models(return_dict=True)
      model_config = models.get(model_name)
  
      # Try to find by alias
      if model_config == None and aliases:
          name_from_alias = aliases.get(model_name)
  
          if name_from_alias:
              model_config = models.get(name_from_alias)
              if model_config:
                  model_name = name_from_alias
  
      # Try to load from local saved model
      if model_config == None:
          try:
              model = load(model_name)
              model.to(device)
          except ValueError:
              raise ValueError(f"Model '{model_name}' not found")
  
      if model == None:
          model_class = model_config["class"]
          init_kwargs = model_config["init_kwargs"]
  
          model = model_config["class"](
              **init_kwargs,
              description=model_config["description"],
              tasks=model_config["tasks"],
              name=model_name,
              details=model_config.get("details"),
              device=device,
          )
  
      return model
  
imports: from typing import Dict
  from backprop.models import HFNLIModel, STModel, HFSeq2SeqTGModel, T5QASummaryEmotion, T5, HFCausalLMTGModel, HFSeqTCModel, EfficientNet, CLIP
  from backprop import load
  import torch
label_desc: Use image node_id 1 for calling the AutoModel obj's underlying member method code with example usage: obj.from_pretrained(model_name, aliases, device) and returns: model