code: def acc_and_f1(preds, labels):
      acc = simple_accuracy(preds, labels)
      f1 = f1_score(y_true=labels, y_pred=preds)
      return {
          "acc": acc["acc"],
          "f1": f1,
          "acc_and_f1": (acc["acc"] + f1) / 2,
      }
  
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 4 for calling a global function with example usage: acc_and_f1(preds, labels) and returns: dict