code: def get_f0(audio, rate=16000):
      try:
          import amfm_decompy.basic_tools as basic
          import amfm_decompy.pYAAPT as pYAAPT
          from librosa.util import normalize
      except ImportError:
          raise "Please install amfm_decompy (`pip install AMFM-decompy`) and librosa (`pip install librosa`)."
  
      assert audio.ndim == 1
      frame_length = 20.0  # ms
      to_pad = int(frame_length / 1000 * rate) // 2
  
      audio = normalize(audio) * 0.95
      audio = np.pad(
          audio, (to_pad, to_pad), "constant", constant_values=0
      )
      audio = basic.SignalObj(audio, rate)
      pitch = pYAAPT.yaapt(
          audio,
          frame_length=frame_length,
          frame_space=F0_FRAME_SPACE * 1000,
          nccf_thresh1=0.25,
          tda_frame_length=25.0,
      )
      f0 = pitch.samp_values
      return f0
  
imports: import json
  import logging
  import os
  import random
  from pathlib import Path
  import numpy
  import torch
  import torch.utils.data
  from .None import data_utils
  from fairseq.data.fairseq_dataset import FairseqDataset
label_desc: Use image node_id 1 for calling a global function with example usage: get_f0(audio, rate) and returns: f0