original_docstring: 
      Return a list of square quantum volume circuits 
  
      (Mostly from QV circuit generator from qiskit 0.20.0, newer versions
      only use fixed number of SU(4) gates)
  
      Args:
          nqubits:        number of qubits
          ntrials:        number of random iterations
          depth:          number of SU(4) rounds (defaults to QV depth=N)
          perm_seed:      random seed for permuting qubits
          gate_seed:      random seed for gates
  
      Returns:
          qv_circs: list of lists of circuits for the qv sequences
          (separate list for each trial)
          qv_circs_nomeas: same as above with no measurements for the ideal
          simulation
          
      
docstring: Return a list of square quantum volume circuits
  (Mostly from QV circuit generator from qiskit 0.20.0, newer versions
  only use fixed number of SU(4) gates)
docstring_tokens: Return a list of square quantum volume circuits ( Mostly from QV circuit generator from qiskit 0 . 20 . 0 newer versions only use fixed number of SU ( 4 ) gates )
code: def qv_circuits(nqubits: int,
                  ntrials: int = 1,
                  depth: Optional[int] = None,
                  perm_seed: Optional[int] = None,
                  gate_seed: Optional[int] = None) -> list:
      """
      Return a list of square quantum volume circuits 
  
      (Mostly from QV circuit generator from qiskit 0.20.0, newer versions
      only use fixed number of SU(4) gates)
  
      Args:
          nqubits:        number of qubits
          ntrials:        number of random iterations
          depth:          number of SU(4) rounds (defaults to QV depth=N)
          perm_seed:      random seed for permuting qubits
          gate_seed:      random seed for gates
  
      Returns:
          qv_circs: list of lists of circuits for the qv sequences
          (separate list for each trial)
          qv_circs_nomeas: same as above with no measurements for the ideal
          simulation
          
      """
      if depth is None:
          depth = nqubits
          
      qubit_list = list(range(nqubits))
      
      perm_rng = np.random.default_rng(perm_seed)
      gate_rng = np.random.default_rng(gate_seed)
  
      circuits = []
      circuits_nomeas = []
  
      # go through for each trial
      for trial in range(ntrials):
  
          qr = QuantumRegister(nqubits, 'qr')
          qr2 = QuantumRegister(nqubits, 'qr')
          cr = ClassicalRegister(nqubits, 'cr')
  
          qc = QuantumCircuit(qr, cr)
          qc2 = QuantumCircuit(qr2, cr)
  
          qc.name = f'qv_depth_{nqubits}_trial_{trial}'
          qc2.name = qc.name
  
          # First gate has no permutations
          perm = list(range(nqubits))
          
          # build the circuit
          for _ in range(depth):
              # For each pair p in Pj, generate Haar random SU(4)
              for k in range(nqubits // 2):
                  U = random_unitary(4, gate_rng).to_instruction()
                  pair = int(perm[2*k]), int(perm[2*k+1])
                  qc.compose(U, [qr[qubit_list[pair[0]]],
                                qr[qubit_list[pair[1]]]],
                                inplace=True)
                  qc2.compose(U, [qr2[pair[0]],
                                 qr2[pair[1]]],
                                 inplace=True)
                                 
              # Generate uniformly random permutation Pj of [0...n-1]
              perm = perm_rng.permutation(nqubits)
  
          # append an id to all the qubits in the ideal circuits
          # to prevent a truncation error in the statevector
          # simulators
          qc2.u1(0, qr2)
  
          circuits_nomeas.append(qc2)
  
          # add measurement
          for qind, qubit in enumerate(qubit_list):
              qc.measure(qr[qubit], cr[qind])
  
          circuits.append(qc)
  
      return circuits, circuits_nomeas
code_tokens: def qv_circuits ( nqubits : int , ntrials : int = 1 , depth : Optional [ int ] = None , perm_seed : Optional [ int ] = None , gate_seed : Optional [ int ] = None ) -> list : if depth is None : depth = nqubits qubit_list = list ( range ( nqubits ) ) perm_rng = np . random . default_rng ( perm_seed ) gate_rng = np . random . default_rng ( gate_seed ) circuits = [ ] circuits_nomeas = [ ] for trial in range ( ntrials ) : qr = QuantumRegister ( nqubits , 'qr' ) qr2 = QuantumRegister ( nqubits , 'qr' ) cr = ClassicalRegister ( nqubits , 'cr' ) qc = QuantumCircuit ( qr , cr ) qc2 = QuantumCircuit ( qr2 , cr ) qc . name = f'qv_depth_{nqubits}_trial_{trial}' qc2 . name = qc . name perm = list ( range ( nqubits ) ) for _ in range ( depth ) : for k in range ( nqubits // 2 ) : U = random_unitary ( 4 , gate_rng ) . to_instruction ( ) pair = int ( perm [ 2 * k ] ) , int ( perm [ 2 * k + 1 ] ) qc . compose ( U , [ qr [ qubit_list [ pair [ 0 ] ] ] , qr [ qubit_list [ pair [ 1 ] ] ] ] , inplace = True ) qc2 . compose ( U , [ qr2 [ pair [ 0 ] ] , qr2 [ pair [ 1 ] ] ] , inplace = True ) perm = perm_rng . permutation ( nqubits ) qc2 . u1 ( 0 , qr2 ) circuits_nomeas . append ( qc2 ) for qind , qubit in enumerate ( qubit_list ) : qc . measure ( qr [ qubit ] , cr [ qind ] ) circuits . append ( qc ) return circuits , circuits_nomeas
short_docstring: Return a list of square quantum volume circuits
  (Mostly from QV circuit generator from qiskit 0.20.0, newer versions
  only use fixed number of SU(4) gates)
short_docstring_tokens: Return a list of square quantum volume circuits ( Mostly from QV circuit generator from qiskit 0 . 20 . 0 newer versions only use fixed number of SU ( 4 ) gates )
comment: """
      Return a list of square quantum volume circuits 
  
      (Mostly from QV circuit generator from qiskit 0.20.0, newer versions
      only use fixed number of SU(4) gates)
  
      Args:
          nqubits:        number of qubits
          ntrials:        number of random iterations
          depth:          number of SU(4) rounds (defaults to QV depth=N)
          perm_seed:      random seed for permuting qubits
          gate_seed:      random seed for gates
  
      Returns:
          qv_circs: list of lists of circuits for the qv sequences
          (separate list for each trial)
          qv_circs_nomeas: same as above with no measurements for the ideal
          simulation
          
      """$SEP$# go through for each trial$SEP$# First gate has no permutations$SEP$# build the circuit$SEP$# For each pair p in Pj, generate Haar random SU(4)$SEP$# Generate uniformly random permutation Pj of [0...n-1]$SEP$# append an id to all the qubits in the ideal circuits$SEP$# to prevent a truncation error in the statevector$SEP$# simulators$SEP$# add measurement