<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Gate Zoo
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https
Step1:  Cirq comes with many gates that are standard across quantum computing. This notebook serves as a reference sheet for these gates.
Single Qubit Gates
Gate Constants
Cirq defines constants which are gate instances for particular important single qubit gates.
Step2:  Traditional Pauli Rotation Gates
Cirq defines traditional single qubit rotations that are rotations in radiants abougt different Pauli directions.
Step3:  Pauli PowGates
If you think of the cirq.Z gate as phasing the state $|1\rangle$ by $-1$, then you might think that the square root of this gate phases the state $|1\rangle$ by $i=\sqrt{-1}$.  The XPowGate, YPowGate and ZPowGates all act in this manner, phasing the state corresponding to their $-1$ eigenvalue by a prescribed amount.  This ends up being the same as the Rx, Ry, and Rz up to a global phase.
Step4:  More Single Qubit Gate
Many quantum computing implementations use qubits whose energy eigenstate are the computational basis states. In these cases it is often useful to move cirq.ZPowGate's through other single qubit gates, "phasing" the other gates.  For these scenarios, the following phased gates are useful.
Step5:  Two Qubit Gates
Gate Constants
Cirq defines convenient constants for common two qubit gates.
Step6:  Parity Gates
If $P$ is a non-identity Pauli matrix, then it has eigenvalues $\pm 1$.  $P \otimes P$ similarly has eigenvalues $\pm 1$ which are the product of the eigenvalues of the single $P$ eigenvalues. In this sense, $P \otimes P$ has an eigenvalue which encodes the parity of the eigenvalues of the two qubits.  If you think of $P \otimes P$ as phasing its $-1$ eigenvectors by $-1$, then you could consider $(P \otimes P)^{\frac{1}{2}}$ as the gate that phases the $-1$ eigenvectors by $\sqrt{-1} =i$.  The Parity gates are exactly these gates for the three different non-identity Paulis.
Step7:  There are also constants that one can use to define the parity gates via exponentiating them.
Step8:  Fermionic Gates
If we think of $|1\rangle$ as an excitation, then the gates that preserve the number of excitations are the fermionic gates.  There are two implementations, with differing phase conventions.
Step9:  Two qubit PowGates
Just as cirq.XPowGate represents a powering of cirq.X, our two qubit gate constants also have corresponding "Pow" versions.
Step10:  Three Qubit Gates
Gate Constants
Cirq provides constants for common three qubit gates.
Step11:  Three Qubit Pow Gates
Corresponding to some of the above gate constants are the corresponding PowGates.
Step12:  N Qubit Gates
Do Nothing Gates
Sometimes you just want a gate to represent doing nothing.
Step13:  Measurement Gates
Measurement gates are gates that represent a measurement and can operate on any number of qubits.
Step14:  Matrix Gates
If one has a specific unitary matrix in mind, then one can construct it using matrix gates, or, if the unitary is diagonal, the diagonal gates.
Step15:  Pauli String Gates
Pauli strings are expressions like "XXZ" representing the Pauli operator X operating on the first two qubits, and Z on the last qubit, along with a numeric (or symbolic) coefficient. When the coefficient is a unit complex number, then this is a valid unitary gate.  Similarly one can construct gates which phases the $\pm 1$ eigenvalues of such a Pauli string.
Step16:  Algorithm Based Gates
It is useful to define composite gates which correspond to algorithmic primitives, i.e. one can think of the fourier transform as a single unitary gate.
Step17:  Classiscal Permutation Gates
Sometimes you want to represent shuffling of qubits.
<ASSISTANT_TASK:>
Python Code:
try:
    import cirq
except ImportError:
    print("installing cirq...")
    !pip install --quiet --pre cirq
    print("installed cirq.")
    
import IPython.display as ipd
import cirq
import inspect
def display_gates(*gates):
    for gate_name in gates:
        ipd.display(ipd.Markdown("---"))
        gate = getattr(cirq, gate_name)
        ipd.display(ipd.Markdown(f"#### cirq.{gate_name}"))
        ipd.display(ipd.Markdown(inspect.cleandoc(gate.__doc__ or "")))
    else:
        ipd.display(ipd.Markdown("---"))    
Explanation: Gate Zoo
<table class="tfo-notebook-buttons" align="left">
  <td>
    <a target="_blank" href="https://quantumai.google/cirq/gatezoo.ipynb"><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/gatezoo.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/gatezoo.ipynbb"><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/gatezoo.ipynb"><img src="https://quantumai.google/site-assets/images/buttons/download_icon_1x.png" />Download notebook</a>
  </td>
</table>
Setup
Note: this notebook relies on unreleased Cirq features. If you want to try these features, make sure you install cirq via pip install cirq --pre
End of explanation
display_gates("X", "Y", "Z", "H", "S", "T")
Explanation: Cirq comes with many gates that are standard across quantum computing. This notebook serves as a reference sheet for these gates.
Single Qubit Gates
Gate Constants
Cirq defines constants which are gate instances for particular important single qubit gates.
End of explanation
display_gates("Rx", "Ry", "Rz")
Explanation: Traditional Pauli Rotation Gates
Cirq defines traditional single qubit rotations that are rotations in radiants abougt different Pauli directions.
End of explanation
display_gates("XPowGate", "YPowGate", "ZPowGate")
Explanation: Pauli PowGates
If you think of the cirq.Z gate as phasing the state $|1\rangle$ by $-1$, then you might think that the square root of this gate phases the state $|1\rangle$ by $i=\sqrt{-1}$.  The XPowGate, YPowGate and ZPowGates all act in this manner, phasing the state corresponding to their $-1$ eigenvalue by a prescribed amount.  This ends up being the same as the Rx, Ry, and Rz up to a global phase.
End of explanation
display_gates("PhasedXPowGate", "PhasedXZGate", "HPowGate")
Explanation: More Single Qubit Gate
Many quantum computing implementations use qubits whose energy eigenstate are the computational basis states. In these cases it is often useful to move cirq.ZPowGate's through other single qubit gates, "phasing" the other gates.  For these scenarios, the following phased gates are useful.
End of explanation
display_gates("CX", "CZ", "SWAP", "ISWAP", "SQRT_ISWAP", "SQRT_ISWAP_INV")
Explanation: Two Qubit Gates
Gate Constants
Cirq defines convenient constants for common two qubit gates.
End of explanation
display_gates("XXPowGate", "YYPowGate", "ZZPowGate")
Explanation: Parity Gates
If $P$ is a non-identity Pauli matrix, then it has eigenvalues $\pm 1$.  $P \otimes P$ similarly has eigenvalues $\pm 1$ which are the product of the eigenvalues of the single $P$ eigenvalues. In this sense, $P \otimes P$ has an eigenvalue which encodes the parity of the eigenvalues of the two qubits.  If you think of $P \otimes P$ as phasing its $-1$ eigenvectors by $-1$, then you could consider $(P \otimes P)^{\frac{1}{2}}$ as the gate that phases the $-1$ eigenvectors by $\sqrt{-1} =i$.  The Parity gates are exactly these gates for the three different non-identity Paulis.
End of explanation
display_gates("XX", "YY", "ZZ")
Explanation: There are also constants that one can use to define the parity gates via exponentiating them.
End of explanation
display_gates("FSimGate", "PhasedFSimGate")
Explanation: Fermionic Gates
If we think of $|1\rangle$ as an excitation, then the gates that preserve the number of excitations are the fermionic gates.  There are two implementations, with differing phase conventions.
End of explanation
display_gates("SwapPowGate", "ISwapPowGate", "CZPowGate", "CXPowGate", "PhasedISwapPowGate")
Explanation: Two qubit PowGates
Just as cirq.XPowGate represents a powering of cirq.X, our two qubit gate constants also have corresponding "Pow" versions.
End of explanation
display_gates("CCX", "CCZ", "CSWAP")
Explanation: Three Qubit Gates
Gate Constants
Cirq provides constants for common three qubit gates.
End of explanation
display_gates("CCXPowGate", "CCZPowGate")
Explanation: Three Qubit Pow Gates
Corresponding to some of the above gate constants are the corresponding PowGates.
End of explanation
display_gates("IdentityGate", "WaitGate")
Explanation: N Qubit Gates
Do Nothing Gates
Sometimes you just want a gate to represent doing nothing.
End of explanation
display_gates("MeasurementGate")
Explanation: Measurement Gates
Measurement gates are gates that represent a measurement and can operate on any number of qubits.
End of explanation
display_gates("MatrixGate", "DiagonalGate", "TwoQubitDiagonalGate", "ThreeQubitDiagonalGate")
Explanation: Matrix Gates
If one has a specific unitary matrix in mind, then one can construct it using matrix gates, or, if the unitary is diagonal, the diagonal gates.
End of explanation
display_gates("DensePauliString", "MutableDensePauliString", "PauliStringPhasorGate")
Explanation: Pauli String Gates
Pauli strings are expressions like "XXZ" representing the Pauli operator X operating on the first two qubits, and Z on the last qubit, along with a numeric (or symbolic) coefficient. When the coefficient is a unit complex number, then this is a valid unitary gate.  Similarly one can construct gates which phases the $\pm 1$ eigenvalues of such a Pauli string.
End of explanation
display_gates("BooleanHamiltonianGate", "QuantumFourierTransformGate", "PhaseGradientGate")
Explanation: Algorithm Based Gates
It is useful to define composite gates which correspond to algorithmic primitives, i.e. one can think of the fourier transform as a single unitary gate.
End of explanation
display_gates("QubitPermutationGate")
Explanation: Classiscal Permutation Gates
Sometimes you want to represent shuffling of qubits.
End of explanation
<END_TASK>