(self, all_sliced_lists)
Dedupe lists of events, chords, and keys, then optionally sample.
Dedupe lists of events, chords, and keys, then optionally sample.
Dedupe lists of events chords and keys then optionally sample .
def _dedupe_and_sample(self, all_sliced_lists):
    """Dedupe lists of events, chords, and keys, then optionally sample."""
    # This function expects the following lists (when chords & keys are present;
    # when absent those lists will simply be missing):
    #
    # all_sliced_lists = [
    #   [
    #     [event_00, event_01, ..., event_0a],
    #     [event_10, event_11, ..., event_1b],
    #     [event_20, event_21, ..., event_2c]
    #   ],
    #   [
    #     [chord_00, chord_01, ..., chord_0a],
    #     [chord_10, chord_11, ..., chord_1b],
    #     [chord_20, chord_21, ..., chord_2c]
    #   ],
    #   [
    #     [key_00, key_01, ..., key_0a],
    #     [key_10, key_11, ..., key_1b],
    #     [key_20, key_21, ..., key_2c]
    #   ]
    # ]

    sliced_multievent_lists = [zip(*lists) for lists in zip(*all_sliced_lists)]

    # Now we have:
    #
    # sliced_multievent_lists = [
    #   [(event_00, chord_00, key_00), ..., (event_0a, chord_0a, key_0a)],
    #   [(event_10, chord_10, key_10), ..., (event_1b, chord_1b, key_1b)],
    #   [(event_20, chord_20, key_20), ..., (event_2c, chord_2c, key_2c)]
    # ]

    # TODO(adarob): Consider handling the fact that different event lists can
    # be mapped to identical tensors by the encoder_decoder (e.g., Drums).

    if self._dedupe_event_lists:
      multievent_tuples = list(
          set(tuple(l) for l in sliced_multievent_lists))
    else:
      multievent_tuples = [tuple(l) for l in sliced_multievent_lists]
    multievent_tuples = maybe_sample_items(
        multievent_tuples,
        self.max_tensors_per_notesequence,
        self.is_training)

    # Now multievent_tuples is structured like sliced_multievent_lists
    # above, with duplicates optionally removed and sampled.

    if multievent_tuples:
      # Return lists structured like input all_sliced_lists.
      return list(zip(*[zip(*t) for t in multievent_tuples if t]))
    else:
      return []
def _dedupe_and_sample ( self , all_sliced_lists ) : # This function expects the following lists (when chords & keys are present; # when absent those lists will simply be missing): # # all_sliced_lists = [ #   [ #     [event_00, event_01, ..., event_0a], #     [event_10, event_11, ..., event_1b], #     [event_20, event_21, ..., event_2c] #   ], #   [ #     [chord_00, chord_01, ..., chord_0a], #     [chord_10, chord_11, ..., chord_1b], #     [chord_20, chord_21, ..., chord_2c] #   ], #   [ #     [key_00, key_01, ..., key_0a], #     [key_10, key_11, ..., key_1b], #     [key_20, key_21, ..., key_2c] #   ] # ] sliced_multievent_lists = [ zip ( * lists ) for lists in zip ( * all_sliced_lists ) ] # Now we have: # # sliced_multievent_lists = [ #   [(event_00, chord_00, key_00), ..., (event_0a, chord_0a, key_0a)], #   [(event_10, chord_10, key_10), ..., (event_1b, chord_1b, key_1b)], #   [(event_20, chord_20, key_20), ..., (event_2c, chord_2c, key_2c)] # ] # TODO(adarob): Consider handling the fact that different event lists can # be mapped to identical tensors by the encoder_decoder (e.g., Drums). if self . _dedupe_event_lists : multievent_tuples = list ( set ( tuple ( l ) for l in sliced_multievent_lists ) ) else : multievent_tuples = [ tuple ( l ) for l in sliced_multievent_lists ] multievent_tuples = maybe_sample_items ( multievent_tuples , self . max_tensors_per_notesequence , self . is_training ) # Now multievent_tuples is structured like sliced_multievent_lists # above, with duplicates optionally removed and sampled. if multievent_tuples : # Return lists structured like input all_sliced_lists. return list ( zip ( * [ zip ( * t ) for t in multievent_tuples if t ] ) ) else : return [ ]