from typing import List


def polygon2box(polygon: List[List[int]]):
    """
    Converts polygon to bounding box [x_min, y_min, x_max, y_max]

    Args:
        polygon: List of x, y pairs [[x0, y0], [x1, y1], .... [x0, y0]]
    """
    min_x, min_y, max_x, max_y = [None] * 4

    for item in polygon:
        x, y = item[0], item[1]
        if min_x is None or x < min_x:
            min_x = x
        if min_y is None or y < min_y:
            min_y = y
        if max_x is None or x > max_x:
            max_x = x
        if max_y is None or y > max_y:
            max_y = y

    bbox = [min_x, min_y, max_x, max_y]
    assert all([b is not None for b in bbox]), "Empty sequence"
    return bbox