code: def validate_structure(reference_intervals, reference_labels,
                         estimated_intervals, estimated_labels):
      
      for (intervals, labels) in [(reference_intervals, reference_labels),
                                  (estimated_intervals, estimated_labels)]:
  
          util.validate_intervals(intervals)
          if intervals.shape[0] != len(labels):
              raise ValueError('Number of intervals does not match number '
                               'of labels')
  
          # Check only when intervals are non-empty
          if intervals.size > 0:
              # Make sure intervals start at 0
              if not np.allclose(intervals.min(), 0.0):
                  raise ValueError('Segment intervals do not start at 0')
  
      if reference_intervals.size == 0:
          warnings.warn("Reference intervals are empty.")
      if estimated_intervals.size == 0:
          warnings.warn("Estimated intervals are empty.")
      # Check only when intervals are non-empty
      if reference_intervals.size > 0 and estimated_intervals.size > 0:
          if not np.allclose(reference_intervals.max(),
                             estimated_intervals.max()):
              raise ValueError('End times do not match')
docs: Checks that the input annotations to a structure estimation metric (i.e.
      one that takes in both segment boundaries and their labels) look like valid
      segment times and labels, and throws helpful errors if not.
  
      Parameters
      ----------
      reference_intervals : np.ndarray, shape=(n, 2)
          reference segment intervals, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.
  
      reference_labels : list, shape=(n,)
          reference segment labels, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.
  
      estimated_intervals : np.ndarray, shape=(m, 2)
          estimated segment intervals, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.
  
      estimated_labels : list, shape=(m,)
          estimated segment labels, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.