<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def weighted_accuracy(comparisons, weights):
 """Compute the weighted accuracy of a list of chord comparisons. Examples -------- Parameters comparisons : np.ndarray List of chord comparison scores, in [0, 1] or -1 weights : np.ndarray Weights (not necessarily normalized) for each comparison. This can be a list of interval durations Returns ------- score : float Weighted accuracy """

    N = len(comparisons)
    # There should be as many weights as comparisons
    if weights.shape[0] != N:
        raise ValueError('weights and comparisons should be of the same'
                         ' length. len(weights) = {} but len(comparisons)'
                         ' = {}'.format(weights.shape[0], N))
    if (weights < 0).any():
        raise ValueError('Weights should all be positive.')
    if np.sum(weights) == 0:
        warnings.warn('No nonzero weights, returning 0')
        return 0
    # Find all comparison scores which are valid
    valid_idx = (comparisons >= 0)
    # If no comparable chords were provided, warn and return 0
    if valid_idx.sum() == 0:
        warnings.warn("No reference chords were comparable "
                      "to estimated chords, returning 0.")
        return 0
    # Remove any uncomparable labels
    comparisons = comparisons[valid_idx]
    weights = weights[valid_idx]
    # Normalize the weights
    total_weight = float(np.sum(weights))
    normalized_weights = np.asarray(weights, dtype=float)/total_weight
    # Score is the sum of all weighted comparisons
    return np.sum(comparisons*normalized_weights)