code: def squad_EM(preds, labels):
      """
      Count how often the pair of predicted start and end index exactly matches one of the labels
      """
      n_docs = len(preds)
      n_correct = 0
      for pred, label in zip(preds, labels):
          qa_candidate = pred[0][0]
          pred_start = qa_candidate.offset_answer_start
          pred_end = qa_candidate.offset_answer_end
          curr_labels = label
          if (pred_start, pred_end) in curr_labels:
              n_correct += 1
      return n_correct / n_docs if n_docs else 0
  
imports: import logging
  import numpy
  import torch
  from functools import reduce
  from scipy.stats import pearsonr, spearmanr
  from seqeval.metrics import classification_report
  from seqeval.metrics import f1_score
  from sklearn.metrics import matthews_corrcoef, f1_score, mean_squared_error, r2_score, classification_report
  from farm.utils import flatten_list
label_desc: Use image node_id 9 for calling a global function with example usage: squad_EM(preds, labels) and returns: unknown