code: def get_partitions(
      input_midi: str, threshold=2.0
  ) -> List[Tuple[float, float]]:
      """
      Get partition points [(start, end)] that detach at rests longer than the
      specified threshold.
      Note: silence truncated when longer than 0.4s.
      """
      midi_data = pretty_midi.PrettyMIDI(input_midi)
      bpm = midi_data.estimate_tempo()
      second_per_beat = 60 / bpm
      thresh_in_second = threshold * second_per_beat
  
      if len(midi_data.instruments) != 1:
          print(
              f"Unexpected for kising. Multi-track found: {input_midi}!"
          )
          exit(1)
  
      partitions = []  # [(start, end)]
      instrument = midi_data.instruments[0]  # i.e., just a track
      notes = instrument.notes
      seg_start = max(notes[0].start - 0.2, 0.0)
      prev_note_end = notes[0].end
  
      for note in notes[1:]:
          if note.start - prev_note_end >= thresh_in_second:
              partitions.append(
                  (
                      seg_start,
                      min(
                          (prev_note_end + note.start) / 2,
                          prev_note_end + 0.2,
                      ),
                  )
              )
              seg_start = max(
                  note.start - 0.2, (prev_note_end + note.start) / 2
              )
          prev_note_end = note.end
  
      # Note: the end of the last partition can be larger than the
      # corresponding audio length. But does not matter
      partitions.append((seg_start, notes[-1].end + 0.2))
  
      return partitions
  
imports: import argparse
  import glob
  import logging
  import os
  import re
  import shutil
  import subprocess
  import wave
  from typing import List, TextIO, Tuple
  import miditoolkit
  import numpy
  from local.pinyin_dict import PINYIN_DICT
  from tqdm import tqdm
  from espnet2.fileio.score_scp import SingingScoreWriter
label_desc: Use image node_id 4 for calling a global function with example usage: get_partitions(input_midi, threshold) and returns: partitions