def _get_neighbors(size, point):
    """Get indices of point's neighbors in square matrix of size `size`.

    Unless point (i, j) is on the boundary of the size x size square, this will
    be a list of 4 elements.

    Args:
        size: Int.
        point: Tuple of ints (i, j). Must satisfy 0 <= i, j < size.

    Returns:
        neighbors: List of tuples. Length 2 (if point is a corner), 3 (if point
            is on an edge), or 4 (if point is in the interior).
    """
    i, j = point

    neighbors = [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]
    _valid_neighbor = lambda neighbor: all(0 <= x < size for x in neighbor)
    neighbors = list(filter(_valid_neighbor, neighbors))
    
    return neighbors