Permute the order of the qubits

def permute(self, qubits: Qubits) -> 'QubitVector':
        """Permute the order of the qubits"""

        if qubits == self.qubits:
            return self

        N = self.qubit_nb
        assert len(qubits) == N

        # Will raise a value error if qubits don't match
        indices = [self.qubits.index(q) for q in qubits]  # type: ignore
        perm: List[int] = []
        for rr in range(0, self.rank):
            perm += [rr * N + idx for idx in indices]
        tensor = bk.transpose(self.tensor, perm)

        return QubitVector(tensor, qubits)