code: def get_model(cfg):
      """
      Builds and returns a model according to the config object passed.
  
      Args:
          cfg: A YACS config object.
      """
      config_params = get_config(cfg)
      train_params = config_params["train_params"]
      train_params_local = deepcopy(train_params)
      data_params = config_params["data_params"]
      data_params_local = deepcopy(data_params)
      cnn_params = config_params["cnn_params"]
      cnn_params_local = deepcopy(cnn_params)
      transformer_params = config_params["transformer_params"]
      transformer_params_local = deepcopy(transformer_params)
  
      cnn = SimpleCNNBuilder(**cnn_params_local)
  
      if cfg.TRANSFORMER.USE_TRANSFORMER:
          context_cnn = CNNTransformer(cnn, **transformer_params_local)
      else:
          context_cnn = ContextCNNGeneric(
              cnn,
              transformer_params_local["cnn_output_shape"],
              contextualizer=lambda x: x,
              output_type=transformer_params_local["output_type"],
          )
  
      classifier = ClassNet(
          data_params_local["num_classes"],
          transformer_params_local["cnn_output_shape"],
      )
      model = CNNTransformerTrainer(
          feature_extractor=context_cnn,
          task_classifier=classifier,
          **train_params_local,
      )
  
      return model
  
file_path: pykale/examples/cifar_cnntransformer/model.py
imports: from copy import deepcopy
  import torch
  import torch.nn
  from kale.embed.attention_cnn import CNNTransformer, ContextCNNGeneric
  from kale.embed.image_cnn import SimpleCNNBuilder
  from kale.pipeline.base_nn_trainer import CNNTransformerTrainer
  from kale.predict.class_domain_nets import ClassNet
label_desc: Use image node_id 2 for calling a global function with example usage: get_model(cfg) and returns: model