§
    ¹³ÙgE  ã                  óÌ   — d Z ddlmZ ddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZmZmZ ddlmZ ej        rdd	lmZ ej        ej        ej        ej        d
œZ	 	 	 	 ddd„ZdS )zThe twirling module.é    )ÚannotationsN)Útwirl_circuit)ÚQuantumCircuitÚ_copy_metadata)ÚGate)ÚCXGateÚECRGateÚCZGateÚ	iSwapGate)ÚQiskitError)ÚTarget)ÚcxÚecrÚczÚiswapÚcircuitr   Útwirling_gateú*None | str | Gate | list[str] | list[Gate]Úseedú
int | NoneÚ
num_twirlsÚtargetúTarget | NoneÚreturnú%QuantumCircuit | list[QuantumCircuit]c                ó"  — d}t          |t          ¦  «        r5t                               |d¦  «        }|€t	          d|› d�¦  «        ‚|g}�n3t          |t
          ¦  «        rÜg }g }|D ]Ì}t          |t          ¦  «        rFt                               |d¦  «        }|€t	          d|› d�¦  «        ‚|                     |¦  «         Œ]t          |dd¦  «        }|€|                     |¦  «         Œ†|t                               ¦   «         v r|                     |¦  «         Œ·|                     |¦  «         ŒÍ|sd}|sd}nB|�>t          |dd¦  «        }|€d}|g}n'|t                               ¦   «         v r|g}nd}|g}n|}|}	|	€d}	t          | j
        ||||	|¦  «        }
|�Cg }|
D ]<}t          j        |¦  «        }t          | |d¦  «         |                     |¦  «         Œ=|S t          j        |
d         ¦  «        }t          | |d¦  «         |S )aÊ	  Create copies of a given circuit with Pauli twirling applied around specified two qubit
    gates.

    If you're running this function with the intent to twirl a circuit to run on hardware this
    may not be the most efficient way to perform twirling. Especially if the hardware vendor
    has implemented the :mod:`.primitives` execution interface with :class:`.SamplerV2` and
    :class:`.EstimatorV2` this most likely is not the best way to apply twirling to your
    circuit and you'll want to refer to the implementation of :class:`.SamplerV2` and/or
    :class:`.EstimatorV2` for the specified hardware vendor.

    If the intent of this function is to be run after :func:`.transpile` or
    :meth:`.PassManager.run` the optional ``target`` argument can be used
    so that the inserted 1 qubit Pauli gates are synthesized to be
    compatible with the given :class:`.Target` so the output circuit(s) are
    still compatible.

    Args:
        circuit: The circuit to twirl
        twirling_gate: The gate to twirl, defaults to `None` which means twirl all default gates:
            :class:`.CXGate`, :class:`.CZGate`, :class:`.ECRGate`, and :class:`.iSwapGate`.
            If supplied it can either be a single gate or a list of gates either as either a gate
            object or its string name. Currently only the names `"cx"`, `"cz"`, `"ecr"`,  and
            `"iswap"` are supported. If a gate object is provided outside the default gates it must
            have a matrix defined from its :class:`~.Gate.to_matrix` method for the gate to potentially
            be twirled. If a valid twirling configuration can't be computed that particular gate will
            be silently ignored and not twirled.
        seed: An integer seed for the random number generator used internally by this function.
            If specified this must be between 0 and 18,446,744,073,709,551,615.
        num_twirls: The number of twirling circuits to build. This defaults to ``None`` and will return
            a single circuit. If it is an integer a list of circuits with `num_twirls` circuits
            will be returned.
        target: If specified an :class:`.Target` instance to use for running single qubit decomposition
            as part of the Pauli twirling to optimize and map the pauli gates added to the circuit
            to the specified target.

    Returns:
        A copy of the given circuit with Pauli twirling applied to each
        instance of the specified twirling gate.
    NzThe specified gate name z is not supportedÚ_standard_gateé   Úaliker   )Ú
isinstanceÚstrÚNAME_TO_CLASSÚgetr   ÚlistÚappendÚgetattrÚvaluesÚtwirl_rsÚ_datar   Ú_from_circuit_datar   )r   r   r   r   r   Úcustom_gatesÚgateÚtwirling_std_gateÚstd_gateÚ
out_twirlsÚnew_dataÚout_listÚcircÚnew_circÚout_circs                  úM/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/twirling.pyÚpauli_twirl_2q_gatesr6   $   sŽ  € ð\ €LÝ�-¥Ñ%Ô%ð (*Ý× Ò  °Ñ5Ô5ˆØˆ<ÝÐY¸ÐYÐYÐYÑZÔZÐZØ!˜FÐÑÝ	�M¥4Ñ	(Ô	(ð #*ØˆØÐØ!ð 	2ð 	2ˆDÝ˜$¥Ñ$Ô$ð 2Ý$×(Ò(¨¨tÑ4Ô4�Ø�<Ý%Ð&aÀÐ&aÐ&aÐ&aÑbÔbÐbØ!×(Ò(¨Ñ.Ô.Ð.Ð.å '¨Ð.>ÀÑ EÔ E�à Ð(Ø ×'Ò'¨Ñ-Ô-Ð-Ð-à$­×(<Ò(<Ñ(>Ô(>Ð>Ð>Ø)×0Ò0°Ñ?Ô?Ð?Ð?à$×+Ò+¨DÑ1Ô1Ð1Ð1Øð 	 ØˆLØ ð 	%Ø $ÐøØ	Ð	"Ý˜=Ð*:¸DÑAÔAˆØÐØ $ÐØ)˜?ˆLˆLà�=×/Ò/Ñ1Ô1Ð1Ð1Ø%- JÐ!Ð!à$(Ð!Ø -˜��à)ÐØ€JØÐØˆ
ÝØŒØØØØØñô €Hð ÐØˆØð 	&ð 	&ˆDÝ%Ô8¸Ñ>Ô>ˆHÝ˜7 H¨gÑ6Ô6Ð6Ø�OŠO˜HÑ%Ô%Ð%Ð%Øˆå!Ô4°X¸a´[ÑAÔAˆÝ�w ¨'Ñ2Ô2Ð2Øˆó    )NNNN)r   r   r   r   r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   ÚtypingÚqiskit._accelerate.twirlingr   r(   Úqiskit.circuit.quantumcircuitr   r   Úqiskit.circuit.gater   Ú%qiskit.circuit.library.standard_gatesr   r	   r
   r   Úqiskit.exceptionsr   ÚTYPE_CHECKINGÚqiskit.transpiler.targetr   r   r"   r6   © r7   r5   ú<module>rC      s  ðð Ð à "Ð "Ð "Ð "Ð "Ð "Ø €€€à AÐ AÐ AÐ AÐ AÐ AØ HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ $Ð $Ð $Ð $Ð $Ð $Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TÐ TØ )Ð )Ð )Ð )Ð )Ð )à	Ôð 0Ø/Ð/Ð/Ð/Ð/Ð/ð Ô
ØÔ!Ø
Ô
ØÔ%ð	ð €ð AEØØ!Ø ðmð mð mð mð mð mð mr7   