fixed permute function, but still a one-off in quantum_diag_measure function