code: def to_np_array(dataset_file, ent2idx, rel2idx):
      """Map raw dataset file to numpy array with unique ids.
  
      Args:
        dataset_file: Path to file contatining raw triples in a split.
        ent2idx: Dictionary mapping raw entities to unique ids.
        rel2idx: Dictionary mapping raw relations to unique ids.
  
      Returns:
        Numpy array of size n_examples x 3 mapping the raw dataset file to ids.
      """
      examples = []
      with open(dataset_file, "r") as lines:
          for line in lines:
              lhs, rel, rhs = line.strip().split("\t")
              try:
                  examples.append(
                      [ent2idx[lhs], rel2idx[rel], ent2idx[rhs]]
                  )
              except ValueError:
                  continue
      return np.array(examples).astype("int64")
  
file_path: neural-structured-learning/research/kg_hyp_emb/datasets/process.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import pickle
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: to_np_array(dataset_file, ent2idx, rel2idx) and returns: np