code: def evaluate(expected_version, ds_file, pred_file):
      with open(ds_file) as dataset_file:
          dataset_json = json.load(dataset_file)
          if dataset_json["version"] != expected_version:
              print(
                  "Evaluation expects v-"
                  + expected_version
                  + ", but got dataset with v-"
                  + dataset_json["version"],
                  file=sys.stderr,
              )
          dataset = dataset_json["data"]
      with open(pred_file) as prediction_file:
          predictions = json.load(prediction_file)
  
      f1 = exact_match = total = 0
      for article in dataset:
          for paragraph in article["paragraphs"]:
              for qa in paragraph["qas"]:
                  total += 1
                  if qa["id"] not in predictions:
                      message = (
                          "Unanswered question "
                          + qa["id"]
                          + " will receive score 0."
                      )
                      print(message, file=sys.stderr)
                      continue
                  ground_truths = list(
                      map(lambda x: x["text"], qa["answers"])
                  )
                  prediction = predictions[qa["id"]]
                  exact_match += metric_max_over_ground_truths(
                      exact_match_score, prediction, ground_truths
                  )
                  f1 += metric_max_over_ground_truths(
                      f1_score, prediction, ground_truths
                  )
  
      exact_match = 100.0 * exact_match / total
      f1 = 100.0 * f1 / total
  
      return {"exact_match": exact_match, "f1": f1}
  
file_path: deepspeedexamples/training/BingBertSquad/evaluate.py
imports: from __future__ import print_function
  from collections import Counter
  import string
  import re
  import argparse
  import json
  import sys
label_desc: Use image node_id 5 for calling a global function with example usage: evaluate(expected_version, ds_file, pred_file) and returns: dict