code: def squad(preds, labels):
      """
      This method calculates squad evaluation metrics a) overall, b) for questions with text answer and c) for questions with no answer
      """
      # TODO change check for no_answer questions from using (start,end)==(-1,-1) to is_impossible flag in QAInput. This needs to be done for labels though. Not for predictions.
      overall_results = squad_base(preds, labels)
  
      preds_answer = [
          pred
          for (pred, label) in zip(preds, labels)
          if (-1, -1) not in label
      ]
      labels_answer = [
          label for label in labels if (-1, -1) not in label
      ]
      answer_results = squad_base(preds_answer, labels_answer)
  
      preds_no_answer = [
          pred
          for (pred, label) in zip(preds, labels)
          if (-1, -1) in label
      ]
      labels_no_answer = [
          label for label in labels if (-1, -1) in label
      ]
      no_answer_results = squad_base(preds_no_answer, labels_no_answer)
  
      return {
          "EM": overall_results["EM"],
          "f1": overall_results["f1"],
          "top_n_accuracy": overall_results["top_n_accuracy"],
          "EM_text_answer": answer_results["EM"],
          "f1_text_answer": answer_results["f1"],
          "top_n_accuracy_text_answer": answer_results[
              "top_n_accuracy"
          ],
          "Total_text_answer": len(preds_answer),
          "EM_no_answer": no_answer_results["EM"],
          "f1_no_answer": no_answer_results["f1"],
          "top_n_accuracy_no_answer": no_answer_results[
              "top_n_accuracy"
          ],
          "Total_no_answer": len(preds_no_answer),
      }
  
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 16 for calling a global function with example usage: squad(preds, labels) and returns: dict