Returns the Quantum Fourier Transform circuit

def qft_circuit(qubits: Qubits) -> Circuit:
    """Returns the Quantum Fourier Transform circuit"""
    # Kudos: Adapted from Rigetti Grove, grove/qft/fourier.py

    N = len(qubits)
    circ = Circuit()
    for n0 in range(N):
        q0 = qubits[n0]
        circ += H(q0)
        for n1 in range(n0+1, N):
            q1 = qubits[n1]
            angle = pi / 2 ** (n1-n0)
            circ += CPHASE(angle, q1, q0)
    circ.extend(reversal_circuit(qubits))
    return circ