code: def eval_f0_error(samples, distortion_fn):
      results = []
      for sample in tqdm.tqdm(samples):
          if sample is None:
              results.append(None)
              continue
          # assume single channel
          yref_f, _, _, yref_t = sample["ref"]
          ysyn_f, _, _, ysyn_t = sample["syn"]
  
          yref_f = np.array(yref_f)
          yref_t = np.array(yref_t)
          ysyn_f = np.array(ysyn_f)
          ysyn_t = np.array(ysyn_t)
  
          distortion = distortion_fn(yref_t, yref_f, ysyn_t, ysyn_f)
          results.append((distortion.item(), len(yref_f), len(ysyn_f)))
      return results
  
file_path: fairseq/examples/speech_synthesis/evaluation/eval_f0.py
imports: import numpy
  import os.path
  import torchaudio
  import tqdm
  from tabulate import tabulate
  from examples.speech_synthesis.utils import gross_pitch_error, voicing_decision_error, f0_frame_error
  from examples.speech_synthesis.evaluation.eval_sp import load_eval_spec
label_desc: Use image node_id 6 for calling a global function with example usage: eval_f0_error(samples, distortion_fn) and returns: results