Like this one:

def merge_segments(segments):
    if not all(isinstance(seg, list) and len(seg) == 2 for seg in segments):
        raise ValueError("segments should be a list of lists with 2 elements each")
    merged_segments = []
    segments.sort()
    current_start, current_end = segments[0]
    for start, end in segments[1:]:
        if start <= current_end:
            current_end = max(current_end, end)
        else:
            merged_segments.append([current_start, current_end])
            current_start, current_end = start, end
    merged_segments.append([current_start, current_end])
    return merged_segments

You can use this function as:
 print (merge_segment([[0, 10], [8, 20], [25, 30]]))

note that if you do not send a list of lists with 2 elements will rise an Error.
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence