Count the number of islands in a matrix (all eight adjacent sides of a coordinate).
Implement count_islands(matrix), where matrix is a rectangular list of lists containing 0 for water and 1 for land. Return the number of islands, where land cells are connected horizontally, vertically, or diagonally; an empty matrix returns 0. For example, [[1, 0], [0, 1]] returns 1, while [[1, 0], [0, 1], [1, 0]] returns 1 because all land cells connect diagonally or vertically.
def count_islands(matrix):