code: def validate(reference_patterns, estimated_patterns):
      if _n_onset_midi(reference_patterns) == 0:
          warnings.warn('Reference patterns are empty.')
      if _n_onset_midi(estimated_patterns) == 0:
          warnings.warn('Estimated patterns are empty.')
      for patterns in [reference_patterns, estimated_patterns]:
          for pattern in patterns:
              if len(pattern) <= 0:
                  raise ValueError("Each pattern must contain at least one "
                                   "occurrence.")
              for occurrence in pattern:
                  for onset_midi in occurrence:
                      if len(onset_midi) != 2:
                          raise ValueError("The (onset, midi) tuple must "
                                           "contain exactly 2 elements.")