code: def load_model(cfg: DictConfig, restore: bool):
      """
      Loads encoder model.
  
      Args:
          cfg: Config file specifying model parameters
          restore: Whether to restore model weights trained
                   by the user. Otherwise will load weights
                   used before self alignment pretraining.
      """
  
      if restore:
          model = EntityLinkingModel.restore_from(cfg.nemo_path)
      else:
          cfg.train_ds = None
          cfg.validation_ds = None
          cfg.test_ds = None
          model = EntityLinkingModel(cfg)
  
      model = model.to(device)
  
      return model
  
file_path: NeMo/examples/nlp/entity_linking/build_index.py
imports: import os
  import pickle
  import random
  from argparse import ArgumentParser
  import h5py
  import numpy
  import torch
  from omegaconf import DictConfig, OmegaConf
  from sklearn.decomposition import PCA
  from tqdm import tqdm
  from nemo.collections.nlp.models import EntityLinkingModel
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: load_model(cfg, restore) and returns: model