<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Copyright 2020 The Cirq Developers
Step1:  AQT Cirq Tutorial
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https
Step2:  AQT supports Cirq as a third party software development kit and offers access to various quantum computing devices and simulators in the backend. Login to the AQT Gateway Portal to get a list of available devices.
After the Cirq installation has finished successfully, you are ready to use different backends by the use of a token and the corresponding backend URL like in the following getting started tutorial.
Use your AQT credentials
Step3:  Where MY_TOKEN is your access token for a specific AQT device. You need to subscribe to an AQT backend at the AQT Gateway Portal and retreive the access token. Then you can access the AQT device by
Step4:  Sample a quantum circuit
You can then use that device in Cirq. For example, preparing the Bell state
$$ |\psi\rangle=\frac{1}{\sqrt{2}}(|00\rangle-\mathrm{i}|11\rangle) $$
by writing
Step5:  This circuit can then be sampled on the real-hardware backend as well as on a simulator.
Step6:  Where BACKEND_URL is the API URL of the AQT backend as specified in your subscription.
Note
Step7:  whereas for a simulation with noise model use
<ASSISTANT_TASK:>
Python Code:
#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Explanation: Copyright 2020 The Cirq Developers
End of explanation
try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet cirq
    print("installed cirq.")
Explanation: AQT Cirq Tutorial
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https://quantumai.google/cirq/tutorials/aqt/getting_started"><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/aqt/getting_started.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/aqt/getting_started.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/aqt/getting_started.ipynb"><img src="https://quantumai.google/site-assets/images/buttons/download_icon_1x.png" />Download notebook</a>
  </td>
</table>
End of explanation
import cirq
from cirq.aqt.aqt_device import get_aqt_device
from cirq.aqt.aqt_sampler import AQTSampler
access_token = 'MY_TOKEN'
Explanation: AQT supports Cirq as a third party software development kit and offers access to various quantum computing devices and simulators in the backend. Login to the AQT Gateway Portal to get a list of available devices.
After the Cirq installation has finished successfully, you are ready to use different backends by the use of a token and the corresponding backend URL like in the following getting started tutorial.
Use your AQT credentials
End of explanation
device, qubits = get_aqt_device(2)
print(device)
Explanation: Where MY_TOKEN is your access token for a specific AQT device. You need to subscribe to an AQT backend at the AQT Gateway Portal and retreive the access token. Then you can access the AQT device by:
End of explanation
circuit = cirq.Circuit(device=device)
circuit.append([cirq.XX(qubits[0], qubits[1])**0.5])
device.validate_circuit(circuit)
print(circuit, qubits)
Explanation: Sample a quantum circuit
You can then use that device in Cirq. For example, preparing the Bell state
$$ |\psi\rangle=\frac{1}{\sqrt{2}}(|00\rangle-\mathrm{i}|11\rangle) $$
by writing
End of explanation
url = 'BACKEND_URL'
aqt_sampler = AQTSampler(url, access_token=access_token)
aqt_sweep = aqt_sampler.run(circuit, repetitions=100)
print(aqt_sweep)
Explanation: This circuit can then be sampled on the real-hardware backend as well as on a simulator.
End of explanation
url = 'https://gateway.aqt.eu/marmot/sim/'
Explanation: Where BACKEND_URL is the API URL of the AQT backend as specified in your subscription.
Note: At the moment, the run() method of the AQTSampler implicitly performs measurements on all qubits at the end of the circuit, so explicit measurement operations aren't required. In fact, using explicit measurements will cause the the AQTSampler to fail. More fine-grained measuement operations will be added to the AQT API in the future.
AQT Simulators
The AQT simulators are capable of running ideal simulations (without a noise model) and real simulations (with a noise model) of a quantum circuit. Using a simulator with noise model allows you to estimate the performance of running a circuit on the real hardware. Switching between the two simulation types is done by using the respective BACKEND_URL in above example.
For running a simulation without noise model use
End of explanation
url = 'https://gateway.aqt.eu/marmot/sim/noise-model-1'
Explanation: whereas for a simulation with noise model use
End of explanation
<END_TASK>