code: def avg_both(mrs, mrrs, hits):
      """Aggregate metrics for left- and right-hand-side predictions.
  
      Args:
        mrs: Dictionary with mean ranks for lhs and rhs.
        mrrs: Dictionary with mean reciprocical ranks for lhs and rhs.
        hits: Dictionary with hits at 1, 3, 10 for lhs and rhs.
  
      Returns:
        Dictionary with averaged metrics.
      """
      mr = (mrs["lhs"] + mrs["rhs"]) / 2.0
      mrr = (mrrs["lhs"] + mrrs["rhs"]) / 2.0
      h = []
      for k in [1, 3, 10]:
          h += [(hits["lhs"][k] + hits["rhs"][k]) / 2.0]
      return {"MR": mr, "MRR": mrr, "hits@[1,3,10]": h}
  
file_path: neural-structured-learning/research/kg_hyp_emb/utils/train.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl import flags
  from kg_hyp_emb.config import CONFIG
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: avg_both(mrs, mrrs, hits) and returns: dict