code: def pearson_and_spearman(preds, labels):
      pearson_corr = pearsonr(preds, labels)[0]
      spearman_corr = spearmanr(preds, labels)[0]
      return {
          "pearson": pearson_corr,
          "spearmanr": spearman_corr,
          "corr": (pearson_corr + spearman_corr) / 2,
      }
  
imports: import math
  from dataclasses import dataclass, field
  from itertools import chain
  import numpy
  import torch
  import torch.nn.functional
  from sklearn.metrics import f1_score
  from sklearn.metrics import matthews_corrcoef
  from scipy.stats import pearsonr, spearmanr
  from fairseq.logging import metrics
  from fairseq.criterions import FairseqCriterion, register_criterion
  from fairseq.dataclass import FairseqDataclass
  from fairseq.logging.meters import safe_round
label_desc: Use image node_id 3 for calling a global function with example usage: pearson_and_spearman(preds, labels) and returns: dict