def find_max_time_overlap(hypseg, reflist):
    """Find reference segment which encompasses the maximum time of the hypothesis segment."""
    hbeg, hend = hypseg[0], hypseg[2]
    times = []
    for [rlbl, rseg] in reflist:
        b = max(hbeg, rseg[0])
        e = min(hend, rseg[2])
        times.append(e - b)
    return times.index(max(times))