code: def load_midi(args, uid, song_name):
      # Note(Yuning): note duration from '.midi' for M4Singer cannot be used here.
      # We only extract tempo from '.midi'.
      midi_path = os.path.join(
          args.src_data, song_name, "{}.mid".format(uid.split("#")[-1])
      )
      midi_obj = miditoolkit.midi.parser.MidiFile(midi_path)
      tempos = midi_obj.tempo_changes
      tempos.sort(key=lambda x: (x.time, x.tempo))
      assert len(tempos) == 1
      tempo = int(tempos[0].tempo + 0.5)
      return tempo
  
file_path: espnet/egs2/m4singer/svs1/local/data_prep.py
imports: import argparse
  import json
  import os
  import random
  import shutil
  import librosa
  import miditoolkit
  import numpy
  from espnet2.fileio.score_scp import SingingScoreWriter
label_desc: Use image node_id 2 for calling a global function with example usage: load_midi(args, uid, song_name) and returns: tempo