@cache
def match_intervals(intervals_from, intervals_to):

    if len(intervals_from) == 0 or len(intervals_to) == 0:
        raise ParameterError('Attempting to match empty interval list')

    # Verify that the input intervals has correct shape and size
    valid_intervals(intervals_from)
    valid_intervals(intervals_to)

    # The overlap score of a beat with a segment is defined as
    #   max(0, min(beat_end, segment_end) - max(beat_start, segment_start))
    output = np.empty(len(intervals_from), dtype=np.int)

    n_rows = int(MAX_MEM_BLOCK / (len(intervals_to) * intervals_to.itemsize))
    n_rows = max(1, n_rows)

    for bl_s in range(0, len(intervals_from), n_rows):
        bl_t = min(bl_s + n_rows, len(intervals_from))
        tmp_from = intervals_from[bl_s:bl_t]

        starts = np.maximum.outer(tmp_from[:, 0], intervals_to[:, 0])
        ends = np.minimum.outer(tmp_from[:, 1], intervals_to[:, 1])
        score = np.maximum(0, ends - starts)

        output[bl_s:bl_t] = np.argmax(score, axis=-1)

    return output
Verifies UCSM driver works correcly with VNIC Templates.
dataset/ETHPy150Open bmcfee/librosa/librosa/util/utils.py/match_intervals--crossover with--dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/tests/unit/ml2/drivers/cisco/ucsm/test_cisco_ucsm_driver.py/TestCiscoUcsmMechDriver.test_update_port_postcommit_vnic_template