def _sparse_argmax_nnz_row(csr_mat):
 n_rows = csr_mat.shape[0]
 idx = np.empty(n_rows, dtype=np.int)
 for k in range(n_rows):
  row = csr_mat[k].tocoo()
  idx[k] = row.col[np.argmax(row.data)]
 return idx

def _sparse_argmax_nnz_row ( csr_mat ) : n_rows = csr_mat . shape [ 0 ] idx = np . empty ( n_rows , dtype = np . int ) for k in range ( n_rows ) : row = csr_mat [ k ] . tocoo ( ) idx [ k ] = row . col [ np . argmax ( row . data ) ] return idx
return index of the maximum non-zero index in each row .