code: def get_index_embeddings(
      cfg: DictConfig, dataloader: object, model: object
  ):
      """Use entity linking encoder to get embeddings for full index dataset"""
      embeddings = []
      concept_ids = []
  
      with torch.no_grad():
          for batch in tqdm(dataloader):
              (
                  input_ids,
                  token_type_ids,
                  input_mask,
                  batch_concept_ids,
              ) = batch
              input_ids = input_ids.to(device)
              token_type_ids = token_type_ids.to(device)
              input_mask = input_mask.to(device)
              batch_embeddings = model.forward(
                  input_ids=input_ids,
                  token_type_ids=token_type_ids,
                  attention_mask=input_mask,
              )
  
              embeddings.extend(batch_embeddings.detach().cpu().numpy())
              concept_ids.extend(batch_concept_ids.numpy())
  
      emb_file = h5py.File(cfg.embedding_save_name, "w")
      emb_file.create_dataset(cfg.index_ds.name, data=embeddings)
      emb_file.close()
  
      pkl.dump(concept_ids, open(cfg.concept_id_save_name, "wb"))
  
      return embeddings, concept_ids
  
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 3 for calling a global function with example usage: get_index_embeddings(cfg, dataloader, model) and returns: embeddings,  concept_ids