'Returns the melody event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An int in the range [0, self.num_classes).
events: The magenta.music.Melody events list of the current melody.
Returns:
A magenta.music.Melody event value.'

def class_index_to_event(self, class_index, events):

    for (i, lookback_distance) in reversed(list(enumerate(self._lookback_distances))):
        if (class_index == ((self._note_range + 2) + i)):
            if (len(events) < lookback_distance):
                return MELODY_NO_EVENT
            return events[(- lookback_distance)]
    if (class_index == (self._note_range + 1)):
        return MELODY_NOTE_OFF
    if (class_index == self._note_range):
        return MELODY_NO_EVENT
    return (self._min_note + class_index)
