code: def make_segment(file_id, tempo, notes, threshold, sil=["P", "B"]):
      segments = []
      segment = SegInfo()
      # add missing lyric
      if "29" in file_id:
          dur = (notes[-1].et - notes[-1].st) / 2
          notes.append(
              NOTE(
                  "ん", notes[-1].midi, notes[-1].st + dur, notes[-1].et
              )
          )
          notes[-1].et -= dur
      for i in range(len(notes)):
          note = notes[i]
          # add pause (split)
          if len(segment.segs) and (
              (
                  "18" in file_id
                  and note.lyric == "ど"
                  and notes[i - 1].lyric == "す"
              )
              or (
                  "28" in file_id
                  and i > 0
                  and notes[i - 1].lyric == "しょ"
              )
              or (
                  "42" in file_id
                  and note.lyric == "し"
                  and notes[i - 1].lyric == "い"
              )
              or (
                  "21" in file_id
                  and (note.lyric == "ぜっ" or note.lyric == "きっ")
              )
          ):
              segments.extend(segment.split(threshold=threshold))
              segment = SegInfo()
  
          # Divide songs by 'P' (pause) or 'B' (breath)
          if note.lyric in sil:
              # remove rest note
              if (
                  "42" in file_id
                  and i > 0
                  and notes[i - 1].lyric == "ぐっ"
              ) or (
                  "21" in file_id
                  and notes[i + 1].lyric == "し"
                  and notes[i + 1].lyric == "た"
              ):
                  notes[i + 1].st = note.st
                  continue
              if len(segment.segs) > 0:
                  segments.extend(segment.split(threshold=threshold))
                  segment = SegInfo()
              continue
          segment.add(note.st, note.et, note.lyric, note.midi)
      if len(segment.segs) > 0:
          segments.extend(segment.split(threshold=threshold))
  
      segments_w_id = {}
      id = 0
      for seg in segments:
          if len(seg) == 0:
              continue
          segments_w_id[pack_zero(file_id, id)] = tempo, seg
          id += 1
      return segments_w_id
  
imports: import argparse
  import math
  import os
  import sys
  import music21
  import numpy
  from typeguard import check_argument_types
  from espnet2.fileio.read_text import read_2columns_text
  from espnet2.fileio.score_scp import NOTE, SingingScoreWriter
label_desc: Use image node_id 4 for calling a global function with example usage: make_segment(file_id, tempo, notes, threshold, sil) and returns: segments_w_id