from typing import List


def blocks_to_squares(blocks: List[List[int]]) -> List[List[List[int]]]:
    """Returns a list of list of blocks of four squares at a time. E.g.

    .. code-block:: python

        blocks = [
            [A, B, 1, 1],
            [C, D, 0, 1],
        ]

        # would return the list below containing a list of rows, with each
        # row being a list of squares

        [ [ [A, B, C, D], [1, 1, 0, 1] ] ]

    In the returned squares, the square coords go:

      * top-left
      * top-right
      * bottom-left
      * bottom-right

    :param blocks: List of blocks to transform into squares
    """
    max_row = len(blocks)
    max_col = len(blocks[0])

    def get_pos(row, col):
        if row >= len(blocks):
            return None
        if col >= len(blocks[0]):
            return None
        val = blocks[row][col]
        if val == 1:
            return None
        return val

    square_rows = []
    for row in range(0, len(blocks), 2):
        curr_square_row = []
        for col in range(0, len(blocks[0]), 2):
            tl = get_pos(row, col)
            tr = get_pos(row, col+1)
            bl = get_pos(row+1, col)
            br = get_pos(row+1, col+1)
            curr_square_row.append([tl, tr, bl, br])
        square_rows.append(curr_square_row)

    return square_rows