code: def get_filters(examples, n_relations):
      """Create filtering lists for evaluation.
  
      Args:
        examples: Numpy array of size n_examples x 3 contatining KG triples.
        n_relations: Int indicating the total number of relations in the KG.
  
      Returns:
        lhs_final: Dictionary mapping queries (entity, relation) to filtered
                   entities for left-hand-side prediction.
        rhs_final: Dictionary mapping queries (entity, relation) to filtered
                   entities for right-hand-side prediction.
      """
      lhs_filters = collections.defaultdict(set)
      rhs_filters = collections.defaultdict(set)
      for lhs, rel, rhs in examples:
          rhs_filters[(lhs, rel)].add(rhs)
          lhs_filters[(rhs, rel + n_relations)].add(lhs)
      lhs_final = {}
      rhs_final = {}
      for k, v in lhs_filters.items():
          lhs_final[k] = sorted(list(v))
      for k, v in rhs_filters.items():
          rhs_final[k] = sorted(list(v))
      return lhs_final, rhs_final
  
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 3 for calling a global function with example usage: get_filters(examples, n_relations) and returns: lhs_final,  rhs_final