code: def load_midi(midi_path, min_pitch=36, max_pitch=84):
      """Load midi as a notesequence."""
      midi_path = util.expand_path(midi_path)
      ns = note_seq.midi_file_to_sequence_proto(midi_path)
      pitches = np.array([n.pitch for n in ns.notes])
      velocities = np.array([n.velocity for n in ns.notes])
      start_times = np.array([n.start_time for n in ns.notes])
      end_times = np.array([n.end_time for n in ns.notes])
      valid = np.logical_and(pitches >= min_pitch, pitches <= max_pitch)
      notes = {
          "pitches": pitches[valid],
          "velocities": velocities[valid],
          "start_times": start_times[valid],
          "end_times": end_times[valid],
      }
      return ns, notes
  
file_path: magenta/magenta/models/gansynth/lib/generate_util.py
imports: from magenta.models.gansynth.lib import util
  import note_seq
  import numpy
  from scipy.io import wavfile
label_desc: Use image node_id 2 for calling a global function with example usage: load_midi(midi_path, min_pitch, max_pitch) and returns: ns,  notes