code: def main(cfg: DictConfig, restore: bool):
      """
      Builds new index if one hasn't been built yet.
  
      Args:
          cfg: Config file specifying index parameters
          restore: Whether to restore model weights trained
                   by the user. Otherwise will load weights
                   used before self alignment pretraining.
      """
  
      logging.info("Loading entity linking encoder model")
      model = load_model(cfg.model, restore)
  
      if not os.path.isfile(cfg.index.index_save_name) or (
          cfg.apply_pca
          and not os.path.isfile(cfg.index.pca.pca_save_name)
      ):
          logging.info("Building index")
          build_index(cfg.index, model)
      else:
          logging.info(
              "Index and pca model (if required) already exists. Skipping build index step."
          )
  
      if not os.path.isfile(cfg.index.idx_to_id):
          logging.info("Mapping entity index postions to ids")
          map_idx_to_ids(cfg.index)
      else:
          logging.info(
              "Map from concept index to id already exists. Skipping mapping step."
          )
  
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 5 for calling a global function with example usage: main(cfg, restore) without return types