<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detection(reference_tempi, reference_weight, estimated_tempi, tol=0.08):
 """Compute the tempo detection accuracy metric. Parameters reference_tempi : np.ndarray, shape=(2,) Two non-negative reference tempi reference_weight : float > 0 The relative strength of ``reference_tempi[0]`` vs ``reference_tempi[1]``. estimated_tempi : np.ndarray, shape=(2,) Two non-negative estimated tempi. tol : float in [0, 1]: The maximum allowable deviation from a reference tempo to count as a hit. ``|est_t - ref_t| <= tol * ref_t`` (Default value = 0.08) Returns ------- p_score : float in [0, 1] Weighted average of recalls: ``reference_weight * hits[0] + (1 - reference_weight) * hits[1]`` one_correct : bool True if at least one reference tempo was correctly estimated both_correct : bool True if both reference tempi were correctly estimated Raises ------ ValueError If the input tempi are ill-formed If the reference weight is not in the range [0, 1] If ``tol < 0`` or ``tol > 1``. """


    validate(reference_tempi, reference_weight, estimated_tempi)

    if tol < 0 or tol > 1:
        raise ValueError('invalid tolerance {}: must lie in the range '
                         '[0, 1]'.format(tol))
    if tol == 0.:
        warnings.warn('A tolerance of 0.0 may not '
                      'lead to the results you expect.')

    hits = [False, False]

    for i, ref_t in enumerate(reference_tempi):
        if ref_t > 0:
            # Compute the relative error for this reference tempo
            f_ref_t = float(ref_t)
            relative_error = np.min(np.abs(ref_t - estimated_tempi) / f_ref_t)

            # Count the hits
            hits[i] = relative_error <= tol

    p_score = reference_weight * hits[0] + (1.0-reference_weight) * hits[1]

    one_correct = bool(np.max(hits))
    both_correct = bool(np.min(hits))

    return p_score, one_correct, both_correct