code: def swap_circuit_generator(register_a: List[int], register_b: List[int], ancilla: int) -> Program:
      
      if len(register_a) != len(register_b):
          raise RegisterSizeMismatch("registers involve different numbers of qubits")
  
      if not isinstance(register_a, list):
          raise TypeError("Register A needs to be list")
      if not isinstance(register_b, list):
          raise TypeError("Register B needs to be a list")
  
      if ancilla is None:
          ancilla = max(register_a + register_b) + 1
  
      swap_program = Program()
      swap_program += H(ancilla)
      for a, b in zip(register_a, register_b):
          swap_program += CSWAP(ancilla, a, b)
      swap_program += H(ancilla)
  
      return swap_program
docs: Generate the swap test circuit primitive.
  
      Registers A and B must be of equivalent size for swap to work.  This module uses the CSWAP gate
      in pyquil.
  
      :param register_a: qubit labels in the 'A' register
      :param register_b: qubit labels in the 'B' register
      :param ancilla: ancilla to measure and control the swap operation.