def choose_base_frame(frames):
    """
    Returns the index of the frame that should be used to align the embeddings.
    This is the frame with the maximum minimum overlap in IDs present between
    all of the frames.
    """
    max_overlap = 0
    best_frame = 0
    
    for i, frame in enumerate(frames):
        min_overlap = min(len(set(frame.get_ids()) & set(other_frame.get_ids())) for other_frame in frames)
        if min_overlap >= max_overlap:
            max_overlap = min_overlap
            best_frame = i
        
    return best_frame