Flatten a Matrix in Python using NumPy