def sparse_to_tuple(sparse_mx):
    if (not sp.isspmatrix_coo(sparse_mx)):
        sparse_mx = sparse_mx.tocoo()
    coords = np.vstack((sparse_mx.row, sparse_mx.col)).transpose()
    values = sparse_mx.data
    shape = sparse_mx.shape
    return (coords, values, shape)
def sparse_to_tuple(sparse_mx):
    if (not sp.isspmatrix_coo(sparse_mx)):
        sparse_mx = sparse_mx.tocoo()
    coords = np.vstack((sparse_mx.row, sparse_mx.col)).transpose()
    values = sparse_mx.data
    shape = sparse_mx.shape
    return (coords, values, shape)