Given a set of 2D coordinates representing GPS waypoints, write an algorithm to find the nearest lane segment in a vectorized map.
Implement nearest_lane_segments(waypoints, lane_segments). Each waypoint is [x, y], each lane segment is [[x1, y1], [x2, y2]], and the result must contain the zero-based index of the closest segment for every waypoint. Use squared Euclidean distance, handle zero-length segments, and return the lowest segment index when distances tie.
def nearest_lane_segments(waypoints, lane_segments):