code: def qualified_note_rate(pianoroll, threshold=2):
      
      _validate_pianoroll(pianoroll)
      if np.issubdtype(pianoroll.dtype, np.bool_):
          pianoroll = pianoroll.astype(np.uint8)
      padded = np.pad(pianoroll, ((1, 1), (0, 0)), 'constant')
      diff = np.diff(padded, axis=0).reshape(-1)
      onsets = (diff > 0).nonzero()[0]
      offsets = (diff < 0).nonzero()[0]
      n_qualified_notes = np.count_nonzero(offsets - onsets >= threshold)
      return n_qualified_notes / len(onsets)
docs: Return the ratio of the number of the qualified notes (notes longer than
      `threshold` (in time step)) to the total number of notes in a pianoroll.