code: def pyquil_to_tk(prog: Program) -> Circuit:
      
      reg_name = None
      qubits = prog.get_qubits()
      n_qubits = max(qubits) + 1
      tkc = Circuit(n_qubits)
      for i in prog.instructions:
          if isinstance(i, Gate):
              name = i.name
              try:
                  optype = _known_quil_gate[name]
              except KeyError as error:
                  raise NotImplementedError("Operation not supported by tket: " + str(i)) from error
              if len(i.params) == 0:
                  tkc.add_operation(optype, [q.index for q in i.qubits])
              else:
                  params = [p/PI for p in i.params]
                  op = tkc._get_op(optype,len(i.qubits),len(i.qubits),params)
                  tkc._add_operation(op, [q.index for q in i.qubits])
          elif isinstance(i, Measurement):
              if not i.classical_reg:
                  raise NotImplementedError("Program has no defined classical register for measurement on qubit: ", i.qubits[0])
              reg = i.classical_reg
              if reg_name and reg_name != reg.name:
                  raise NotImplementedError("Program has multiple classical registers: ", reg_name, reg.name)
              reg_name = reg.name
              op = tkc._get_op(OpType.Measure,1,1,str(reg.offset))
              tkc._add_operation(op, [i.qubit.index])
          elif isinstance(i, Declare):
              continue
          elif isinstance(i, Pragma):
              continue
          elif isinstance(i, Halt):
              return tkc
          else:
              raise NotImplementedError("Pyquil instruction is not a gate: " + str(i))
      return tkc
docs: Convert a :py:class:`pyquil.Program` to a :math:`\\mathrm{t|ket}\\rangle` :py:class:`Circuit` .
      Note that not all pyQuil operations are currently supported by pytket.
      
      :param prog: A circuit to be converted
  
      :return: The converted circuit