<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Getting started with IonQ and Cirq on Azure Quantum
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https
Step1:  Connecting to the Azure Quantum service
To connect to the Azure Quantum service, find the resource ID and location of your Workspace from the Azure Quantum portal here
Step2:  List all IonQ targets
You can now list all the targets that you have access to, including the current queue time and availability. To only return the IonQ provider's targets, you can specify the optional provider_id input argument
Step3:  To read more about the Simulator and QPU specifications such as number of qubits, connectivity, system time scales and fidelities, you can check out the IonQ Provider Reference.
Run a simple circuit
Let's create a simple Cirq circuit to run. This circuit uses the square root of X gate, native to the IonQ hardware system.
Step4:  You can now run the program via the Azure Quantum service and get the result. The following cell will submit a job that runs the circuit with 100 repetitions, wait until the job is completed and return the results.
Step5:  This returns a cirq.Result object.
Step6:  Run on IonQ QPU
Note
Step7:  Again, this returns a cirq.Result object.
Step8:  Asynchronous model using Jobs
For long-running circuits, it can be useful to run them asynchronously. The service.create_job method returns a Job, which you can use to get the results after the job has run successfully.
Step9:  To check on the job status, use job.status()
Step10:  To wait for the job to be done and get the results, use the blocking call job.results()
Step11:  This returns a SimulatorResult object that contains the state probabilities to represent the output. For instance, in the example above, you measure either "00" or "11". To get the probabilities for each bit string, use the .probabilities() method. This returns a dictionary where the keys are the classical register values
Step12:  To convert this to a cirq.Result object, use result.to_cirq_result()
<ASSISTANT_TASK:>
Python Code:
!pip install azure-quantum[cirq] --quiet
Explanation: Getting started with IonQ and Cirq on Azure Quantum
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https://quantumai.google/cirq/tutorials/azure-quantum/getting_started_ionq"><img src="https://quantumai.google/site-assets/images/buttons/quantumai_logo_1x.png" />View on QuantumAI</a>
  </td>
  <td>
    <a target="_blank" href="https://colab.research.google.com/github/quantumlib/Cirq/blob/master/docs/tutorials/azure-quantum/getting_started_ionq.ipynb"><img src="https://quantumai.google/site-assets/images/buttons/colab_logo_1x.png" />Run in Google Colab</a>
  </td>
  <td>
    <a target="_blank" href="https://github.com/quantumlib/Cirq/blob/master/docs/tutorials/azure-quantum/getting_started_ionq.ipynb"><img src="https://quantumai.google/site-assets/images/buttons/github_logo_1x.png" />View source on GitHub</a>
  </td>
  <td>
    <a href="https://storage.googleapis.com/tensorflow_docs/Cirq/docs/tutorials/azure-quantum/getting_started_ionq.ipynb"><img src="https://quantumai.google/site-assets/images/buttons/download_icon_1x.png" />Download notebook</a>
  </td>
</table>
This notebooks shows how to send a basic quantum circuit to an IonQ target via Azure Quantum.
Prerequisites
To work in Azure Quantum, you need an Azure subscription. If you don't have an Azure subscription, create a free account.
Create an Azure Quantum workspace and enable IonQ. For more information, see Create an Azure Quantum workspace.
First, install azure-quantum with the Cirq dependencies:
End of explanation
from azure.quantum.cirq import AzureQuantumService
service = AzureQuantumService(
    resource_id="",
    location="",
    default_target="ionq.simulator"
)
Explanation: Connecting to the Azure Quantum service
To connect to the Azure Quantum service, find the resource ID and location of your Workspace from the Azure Quantum portal here: https://portal.azure.com. Navigate to your Azure Quantum workspace and copy the values from the header.
<img src="azure-quantum-resource-id.png">
Paste the values into the AzureQuantumService constructor below to create a service that connects to your Azure Quantum Workspace. Optionally, specify a default target:
End of explanation
service.targets(provider_id="ionq")
Explanation: List all IonQ targets
You can now list all the targets that you have access to, including the current queue time and availability. To only return the IonQ provider's targets, you can specify the optional provider_id input argument:
End of explanation
import cirq
q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit(
    cirq.X(q0)**0.5,             # Square root of X
    cirq.CX(q0, q1),              # CNOT
    cirq.measure(q0, q1, key='b') # Measure both qubits
)
circuit
Explanation: To read more about the Simulator and QPU specifications such as number of qubits, connectivity, system time scales and fidelities, you can check out the IonQ Provider Reference.
Run a simple circuit
Let's create a simple Cirq circuit to run. This circuit uses the square root of X gate, native to the IonQ hardware system.
End of explanation
result = service.run(program=circuit, repetitions=100)
Explanation: You can now run the program via the Azure Quantum service and get the result. The following cell will submit a job that runs the circuit with 100 repetitions, wait until the job is completed and return the results.
End of explanation
print(result)
Explanation: This returns a cirq.Result object.
End of explanation
result = service.run(
    program=circuit,
    repetitions=100,
    target="ionq.qpu",
    timeout_seconds=500 # Set timeout to 500 seconds to accomodate current queue time on QPU
)
Explanation: Run on IonQ QPU
Note: The time required to run a circuit on the QPU may vary depending on current queue times.
The previous job ran on the default simulator you specified, "ionq.simulator". To run on the QPU, provide "ionq.qpu" as the target argument:
End of explanation
print(result)
Explanation: Again, this returns a cirq.Result object.
End of explanation
job = service.create_job(
    program=circuit,
    repetitions=100,
    target="ionq.simulator"
)
Explanation: Asynchronous model using Jobs
For long-running circuits, it can be useful to run them asynchronously. The service.create_job method returns a Job, which you can use to get the results after the job has run successfully.
End of explanation
job.status()
Explanation: To check on the job status, use job.status():
End of explanation
result = job.results()
print(result)
Explanation: To wait for the job to be done and get the results, use the blocking call job.results():
End of explanation
result.probabilities()
Explanation: This returns a SimulatorResult object that contains the state probabilities to represent the output. For instance, in the example above, you measure either "00" or "11". To get the probabilities for each bit string, use the .probabilities() method. This returns a dictionary where the keys are the classical register values:
End of explanation
result.to_cirq_result()
Explanation: To convert this to a cirq.Result object, use result.to_cirq_result():
End of explanation
<END_TASK>