code: def evaluate(model, graph, device, data_iter, split="valid"):
      # predict for head and tail
      left_results = predict(
          model, graph, device, data_iter, split, mode="tail"
      )
      right_results = predict(
          model, graph, device, data_iter, split, mode="head"
      )
      results = {}
      count = float(left_results["count"])
  
      # combine the head and tail prediction results
      # Metrics: MRR, MR, and Hit@k
      results["left_mr"] = round(left_results["mr"] / count, 5)
      results["left_mrr"] = round(left_results["mrr"] / count, 5)
      results["right_mr"] = round(right_results["mr"] / count, 5)
      results["right_mrr"] = round(right_results["mrr"] / count, 5)
      results["mr"] = round(
          (left_results["mr"] + right_results["mr"]) / (2 * count), 5
      )
      results["mrr"] = round(
          (left_results["mrr"] + right_results["mrr"]) / (2 * count), 5
      )
      for k in [1, 3, 10]:
          results["left_hits@{}".format(k)] = round(
              left_results["hits@{}".format(k)] / count, 5
          )
          results["right_hits@{}".format(k)] = round(
              right_results["hits@{}".format(k)] / count, 5
          )
          results["hits@{}".format(k)] = round(
              (
                  left_results["hits@{}".format(k)]
                  + right_results["hits@{}".format(k)]
              )
              / (2 * count),
              5,
          )
      return results
  
file_path: dgl/examples/pytorch/compGCN/main.py
imports: import argparse
  from time import time
  import numpy
  import torch
  import torch.optim
  from data_loader import Data
  from models import CompGCN_ConvE
  from utils import in_out_norm
label_desc: Use image node_id 2 for calling a global function with example usage: evaluate(model, graph, device, data_iter, split) and returns: results