code: def get_idx(path):
      """Maps entities and relations to unique ids.
  
      Args:
        path: path to directory with raw dataset files (tab-separated
          tain/valid/test triples).
  
      Returns:
        ent2idx: Dictionary mapping raw entities to unique ids.
        rel2idx: Dictionary mapping raw relations to unique ids.
      """
      entities, relations = set(), set()
      for split in ["train", "valid", "test"]:
          with open(os.path.join(path, split), "r") as lines:
              for line in lines:
                  lhs, rel, rhs = line.strip().split("\t")
                  entities.add(lhs)
                  entities.add(rhs)
                  relations.add(rel)
      ent2idx = {x: i for (i, x) in enumerate(sorted(entities))}
      rel2idx = {x: i for (i, x) in enumerate(sorted(relations))}
      return ent2idx, rel2idx
  
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 1 for calling a global function with example usage: get_idx(path) and returns: ent2idx,  rel2idx