<EOL>if isinstance(data, (list, tuple, np.ndarray)):<EOL><INDENT>if isinstance(data, np.ndarray) or np.array(data).ndim == <NUM_LIT:2>:<EOL><INDENT>kraus = ([np.array(data, dtype=complex)], None)<EOL>shape = kraus[<NUM_LIT:0>][<NUM_LIT:0>].shape<EOL><DEDENT>elif isinstance(data, list) and len(data) > <NUM_LIT:0>:<EOL><INDENT>kraus = [np.array(data[<NUM_LIT:0>], dtype=complex)]<EOL>shape = kraus[<NUM_LIT:0>].shape<EOL>for i in data[<NUM_LIT:1>:]:<EOL><INDENT>op = np.array(i, dtype=complex)<EOL>if op.shape != shape:<EOL><INDENT>raise QiskitError(<EOL>"<STR_LIT>")<EOL><DEDENT>kraus.append(op)<EOL><DEDENT>kraus = (kraus, None)<EOL><DEDENT>elif isinstance(data,<EOL>tuple) and len(data) == <NUM_LIT:2> and len(data[<NUM_LIT:0>]) > <NUM_LIT:0>:<EOL><INDENT>kraus_left = [np.array(data[<NUM_LIT:0>][<NUM_LIT:0>], dtype=complex)]<EOL>shape = kraus_left[<NUM_LIT:0>].shape<EOL>for i in data[<NUM_LIT:0>][<NUM_LIT:1>:]:<EOL><INDENT>op = np.array(i, dtype=complex)<EOL>if op.shape != shape:<EOL><INDENT>raise QiskitError(<EOL>"<STR_LIT>")<EOL><DEDENT>kraus_left.append(op)<EOL><DEDENT>if data[<NUM_LIT:1>] is None:<EOL><INDENT>kraus = (kraus_left, None)<EOL><DEDENT>else:<EOL><INDENT>kraus_right = []<EOL>for i in data[<NUM_LIT:1>]:<EOL><INDENT>op = np.array(i, dtype=complex)<EOL>if op.shape != shape:<EOL><INDENT>raise QiskitError(<EOL>"<STR_LIT>")<EOL><DEDENT>kraus_right.append(op)<EOL><DEDENT>kraus = (kraus_left, kraus_right)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(data, (QuantumCircuit, Instruction)):<EOL><INDENT>data = SuperOp._instruction_to_superop(data)<EOL><DEDENT>else:<EOL><INDENT>data = self._init_transformer(data)<EOL><DEDENT>input_dim, output_dim = data.dim<EOL>kraus = _to_kraus(data.rep, data._data, input_dim, output_dim)<EOL>if input_dims is None:<EOL><INDENT>input_dims = data.input_dims()<EOL><DEDENT>if output_dims is None:<EOL><INDENT>output_dims = data.output_dims()<EOL><DEDENT><DEDENT>output_dim, input_dim = kraus[<NUM_LIT:0>][<NUM_LIT:0>].shape<EOL>input_dims = self._automatic_dims(input_dims, input_dim)<EOL>output_dims = self._automatic_dims(output_dims, output_dim)<EOL>if kraus[<NUM_LIT:1>] is None or np.allclose(kraus[<NUM_LIT:0>], kraus[<NUM_LIT:1>]):<EOL><INDENT>super().__init__('<STR_LIT>', (kraus[<NUM_LIT:0>], None), input_dims,<EOL>output_dims)<EOL><DEDENT>else:<EOL><INDENT>super().__init__('<STR_LIT>', kraus, input_dims, output_dims)<EOL><DEDENT>

Initialize a quantum channel Kraus operator.

        Args:
            data (QuantumCircuit or
                  Instruction or
                  BaseOperator or
                  matrix): data to initialize superoperator.
            input_dims (tuple): the input subsystem dimensions.
                                [Default: None]
            output_dims (tuple): the output subsystem dimensions.
                                 [Default: None]

        Raises:
            QiskitError: if input data cannot be initialized as a
            a list of Kraus matrices.

        Additional Information
        ----------------------
        If the input or output dimensions are None, they will be
        automatically determined from the input data. If the input data is
        a list of Numpy arrays of shape (2**N, 2**N) qubit systems will be used. If
        the input does not correspond to an N-qubit channel, it will assign a
        single subsystem with dimension specifed by the shape of the input.


if self._data[<NUM_LIT:1>] is None:<EOL><INDENT>return self._data[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return self._data<EOL><DEDENT>

Return list of Kraus matrices for channel.


def is_cptp(self, atol=None, rtol=None):

if self._data[<NUM_LIT:1>] is not None:<EOL><INDENT>return False<EOL><DEDENT>if atol is None:<EOL><INDENT>atol = self._atol<EOL><DEDENT>if rtol is None:<EOL><INDENT>rtol = self._rtol<EOL><DEDENT>accum = <NUM_LIT><EOL>for op in self._data[<NUM_LIT:0>]:<EOL><INDENT>accum += np.dot(np.transpose(np.conj(op)), op)<EOL><DEDENT>return is_identity_matrix(accum, rtol=rtol, atol=atol)<EOL>

Return True if completely-positive trace-preserving.


kraus_l, kraus_r = self._data<EOL>kraus_l = [k.conj() for k in kraus_l]<EOL>if kraus_r is not None:<EOL><INDENT>kraus_r = [k.conj() for k in kraus_r]<EOL><DEDENT>return Kraus((kraus_l, kraus_r), self.input_dims(), self.output_dims())<EOL>

Return the conjugate of the QuantumChannel.


kraus_l, kraus_r = self._data<EOL>kraus_l = [k.T for k in kraus_l]<EOL>if kraus_r is not None:<EOL><INDENT>kraus_r = [k.T for k in kraus_r]<EOL><DEDENT>return Kraus((kraus_l, kraus_r),<EOL>input_dims=self.output_dims(),<EOL>output_dims=self.input_dims())<EOL>

Return the transpose of the QuantumChannel.


def compose(self, other, qargs=None, front=False):

if qargs is not None:<EOL><INDENT>return Kraus(<EOL>SuperOp(self).compose(other, qargs=qargs, front=front))<EOL><DEDENT>if not isinstance(other, Kraus):<EOL><INDENT>other = Kraus(other)<EOL><DEDENT>if front and self._input_dim != other._output_dim:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>')<EOL><DEDENT>if not front and self._output_dim != other._input_dim:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>')<EOL><DEDENT>if front:<EOL><INDENT>ka_l, ka_r = self._data<EOL>kb_l, kb_r = other._data<EOL>input_dim = other._input_dim<EOL>output_dim = self._output_dim<EOL><DEDENT>else:<EOL><INDENT>ka_l, ka_r = other._data<EOL>kb_l, kb_r = self._data<EOL>input_dim = self._input_dim<EOL>output_dim = other._output_dim<EOL><DEDENT>kab_l = [np.dot(a, b) for a in ka_l for b in kb_l]<EOL>if ka_r is None and kb_r is None:<EOL><INDENT>kab_r = None<EOL><DEDENT>elif ka_r is None:<EOL><INDENT>kab_r = [np.dot(a, b) for a in ka_l for b in kb_r]<EOL><DEDENT>elif kb_r is None:<EOL><INDENT>kab_r = [np.dot(a, b) for a in ka_r for b in kb_l]<EOL><DEDENT>else:<EOL><INDENT>kab_r = [np.dot(a, b) for a in ka_r for b in kb_r]<EOL><DEDENT>return Kraus((kab_l, kab_r), input_dim, output_dim)<EOL>

Return the composition channel self∘other.

        Args:
            other (QuantumChannel): a quantum channel subclass.
            qargs (list): a list of subsystem positions to compose other on.
            front (bool): If False compose in standard order other(self(input))
                          otherwise compose in reverse order self(other(input))
                          [default: False]

        Returns:
            Kraus: The composition channel as a Kraus object.

        Raises:
            QiskitError: if other cannot be converted to a channel, or
            has incompatible dimensions.


if n > <NUM_LIT:0>:<EOL><INDENT>return super().power(n)<EOL><DEDENT>return Kraus(SuperOp(self).power(n))<EOL>

The matrix power of the channel.

        Args:
            n (int): compute the matrix power of the superoperator matrix.

        Returns:
            Kraus: the matrix power of the SuperOp converted to a Kraus channel.

        Raises:
            QiskitError: if the input and output dimensions of the
            QuantumChannel are not equal, or the power is not an integer.


return self._tensor_product(other, reverse=False)<EOL>

Return the tensor product channel self ⊗ other.

        Args:
            other (QuantumChannel): a quantum channel subclass.

        Returns:
            Kraus: the tensor product channel self ⊗ other as a Kraus
            object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


return self._tensor_product(other, reverse=True)<EOL>

Return the tensor product channel other ⊗ self.

        Args:
            other (QuantumChannel): a quantum channel subclass.

        Returns:
            Kraus: the tensor product channel other ⊗ self as a Kraus
            object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


<EOL>return Kraus(Choi(self).add(other))<EOL>

Return the QuantumChannel self + other.

        Args:
            other (QuantumChannel): a quantum channel subclass.

        Returns:
            Kraus: the linear addition self + other as a Kraus object.

        Raises:
            QiskitError: if other cannot be converted to a channel, or
            has incompatible dimensions.


<EOL>return Kraus(Choi(self).subtract(other))<EOL>

Return the QuantumChannel self - other.

        Args:
            other (QuantumChannel): a quantum channel subclass.

        Returns:
            Kraus: the linear subtraction self - other as Kraus object.

        Raises:
            QiskitError: if other cannot be converted to a channel, or
            has incompatible dimensions.


if not isinstance(other, Number):<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>if isinstance(other, complex) or other < <NUM_LIT:0>:<EOL><INDENT>return Kraus(Choi(self).multiply(other))<EOL><DEDENT>val = np.sqrt(other)<EOL>kraus_r = None<EOL>kraus_l = [val * k for k in self._data[<NUM_LIT:0>]]<EOL>if self._data[<NUM_LIT:1>] is not None:<EOL><INDENT>kraus_r = [val * k for k in self._data[<NUM_LIT:1>]]<EOL><DEDENT>return Kraus((kraus_l, kraus_r), self._input_dim, self._output_dim)<EOL>

Return the QuantumChannel self + other.

        Args:
            other (complex): a complex number.

        Returns:
            Kraus: the scalar multiplication other * self as a Kraus object.

        Raises:
            QiskitError: if other is not a valid scalar.


<EOL>if qargs is not None:<EOL><INDENT>return SuperOp(self)._evolve(state, qargs)<EOL><DEDENT>state = self._format_state(state)<EOL>if state.shape[<NUM_LIT:0>] != self._input_dim:<EOL><INDENT>raise QiskitError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>if state.ndim == <NUM_LIT:1> and self._data[<NUM_LIT:1>] is None and len(<EOL>self._data[<NUM_LIT:0>]) == <NUM_LIT:1>:<EOL><INDENT>return np.dot(self._data[<NUM_LIT:0>][<NUM_LIT:0>], state)<EOL><DEDENT>state = self._format_state(state, density_matrix=True)<EOL>kraus_l, kraus_r = self._data<EOL>if kraus_r is None:<EOL><INDENT>kraus_r = kraus_l<EOL><DEDENT>return np.einsum('<STR_LIT>', kraus_l, state,<EOL>np.conjugate(kraus_r))<EOL>

Evolve a quantum state by the QuantumChannel.

        Args:
            state (QuantumState): The input statevector or density matrix.
            qargs (list): a list of QuantumState subsystem positions to apply
                           the operator on.

        Returns:
            QuantumState: the output quantum state.

        Raises:
            QiskitError: if the operator dimension does not match the
            specified QuantumState subsystem dimensions.


def _tensor_product(self, other, reverse=False):

<EOL>if not isinstance(other, Kraus):<EOL><INDENT>other = Kraus(other)<EOL><DEDENT>ka_l, ka_r = self._data<EOL>kb_l, kb_r = other._data<EOL>if reverse:<EOL><INDENT>input_dims = self.input_dims() + other.input_dims()<EOL>output_dims = self.output_dims() + other.output_dims()<EOL>kab_l = [np.kron(b, a) for a in ka_l for b in kb_l]<EOL><DEDENT>else:<EOL><INDENT>input_dims = other.input_dims() + self.input_dims()<EOL>output_dims = other.output_dims() + self.output_dims()<EOL>kab_l = [np.kron(a, b) for a in ka_l for b in kb_l]<EOL><DEDENT>if ka_r is None and kb_r is None:<EOL><INDENT>kab_r = None<EOL><DEDENT>else:<EOL><INDENT>if ka_r is None:<EOL><INDENT>ka_r = ka_l<EOL><DEDENT>if kb_r is None:<EOL><INDENT>kb_r = kb_l<EOL><DEDENT>if reverse:<EOL><INDENT>kab_r = [np.kron(b, a) for a in ka_r for b in kb_r]<EOL><DEDENT>else:<EOL><INDENT>kab_r = [np.kron(a, b) for a in ka_r for b in kb_r]<EOL><DEDENT><DEDENT>data = (kab_l, kab_r)<EOL>return Kraus(data, input_dims, output_dims)<EOL>

Return the tensor product channel.

        Args:
            other (QuantumChannel): a quantum channel subclass.
            reverse (bool): If False return self ⊗ other, if True return
                            if True return (other ⊗ self) [Default: False
        Returns:
            Kraus: the tensor product channel as a Kraus object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


def __init__(self, data, input_dims=None, output_dims=None):

<EOL>if isinstance(data, (list, np.ndarray)):<EOL><INDENT>ptm = np.array(data, dtype=complex)<EOL>dout, din = ptm.shape<EOL>if input_dims:<EOL><INDENT>input_dim = np.product(input_dims)<EOL><DEDENT>else:<EOL><INDENT>input_dim = int(np.sqrt(din))<EOL><DEDENT>if output_dims:<EOL><INDENT>output_dim = np.product(input_dims)<EOL><DEDENT>else:<EOL><INDENT>output_dim = int(np.sqrt(dout))<EOL><DEDENT>if output_dim**<NUM_LIT:2> != dout or input_dim**<NUM_LIT:2> != din or input_dim != output_dim:<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(data, (QuantumCircuit, Instruction)):<EOL><INDENT>data = SuperOp._instruction_to_superop(data)<EOL><DEDENT>else:<EOL><INDENT>data = self._init_transformer(data)<EOL><DEDENT>input_dim, output_dim = data.dim<EOL>ptm = _to_ptm(data.rep, data._data, input_dim, output_dim)<EOL>if input_dims is None:<EOL><INDENT>input_dims = data.input_dims()<EOL><DEDENT>if output_dims is None:<EOL><INDENT>output_dims = data.output_dims()<EOL><DEDENT><DEDENT>n_qubits = int(np.log2(input_dim))<EOL>if <NUM_LIT:2>**n_qubits != input_dim:<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>input_dims = self._automatic_dims(input_dims, input_dim)<EOL>output_dims = self._automatic_dims(output_dims, output_dim)<EOL>super().__init__('<STR_LIT>', ptm, input_dims, output_dims)<EOL>

Initialize a PTM quantum channel operator.


return (self._output_dim, self._output_dim, self._input_dim,<EOL>self._input_dim)<EOL>


<EOL>return PTM(SuperOp(self).conjugate())<EOL>


<EOL>return PTM(SuperOp(self).transpose())<EOL>


if qargs is not None:<EOL><INDENT>return PTM(<EOL>SuperOp(self).compose(other, qargs=qargs, front=front))<EOL><DEDENT>if not isinstance(other, PTM):<EOL><INDENT>other = PTM(other)<EOL><DEDENT>if front and self._input_dim != other._output_dim:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>')<EOL><DEDENT>if not front and self._output_dim != other._input_dim:<EOL><INDENT>raise QiskitError(<EOL>'<STR_LIT>')<EOL><DEDENT>if front:<EOL><INDENT>input_dim = other._input_dim<EOL>output_dim = self._output_dim<EOL>return PTM(np.dot(self._data, other.data), input_dim, output_dim)<EOL><DEDENT>input_dim = self._input_dim<EOL>output_dim = other._output_dim<EOL>return PTM(np.dot(other.data, self._data), input_dim, output_dim)<EOL>

Return the composition channel self∘other.

        Args:
            other (QuantumChannel): a quantum channel.
            qargs (list): a list of subsystem positions to compose other on.
            front (bool): If False compose in standard order other(self(input))
                          otherwise compose in reverse order self(other(input))
                          [default: False]

        Returns:
            PTM: The composition channel as a PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel or
            has incompatible dimensions.


if n > <NUM_LIT:0>:<EOL><INDENT>return super().power(n)<EOL><DEDENT>return PTM(SuperOp(self).power(n))<EOL>

The matrix power of the channel.

        Args:
            n (int): compute the matrix power of the superoperator matrix.

        Returns:
            PTM: the matrix power of the SuperOp converted to a PTM channel.

        Raises:
            QiskitError: if the input and output dimensions of the
            QuantumChannel are not equal, or the power is not an integer.


Return the tensor product channel self ⊗ other.

        Args:
            other (QuantumChannel): a quantum channel.

        Returns:
            PTM: the tensor product channel self ⊗ other as a PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


Return the tensor product channel other ⊗ self.

        Args:
            other (QuantumChannel): a quantum channel.

        Returns:
            PTM: the tensor product channel other ⊗ self as a PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


if not isinstance(other, PTM):<EOL><INDENT>other = PTM(other)<EOL><DEDENT>if self.dim != other.dim:<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>return PTM(self._data + other.data, self._input_dims,<EOL>self._output_dims)<EOL>

Return the QuantumChannel self + other.

        Args:
            other (QuantumChannel): a quantum channel.

        Returns:
            PTM: the linear addition self + other as a PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel or
            has incompatible dimensions.


if not isinstance(other, PTM):<EOL><INDENT>other = PTM(other)<EOL><DEDENT>if self.dim != other.dim:<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>return PTM(self._data - other.data, self._input_dims,<EOL>self._output_dims)<EOL>

Return the QuantumChannel self - other.

        Args:
            other (QuantumChannel): a quantum channel.

        Returns:
            PTM: the linear subtraction self - other as PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel or
            has incompatible dimensions.


if not isinstance(other, Number):<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>return PTM(other * self._data, self._input_dims, self._output_dims)<EOL>

Return the QuantumChannel self + other.

        Args:
            other (complex): a complex number.

        Returns:
            PTM: the scalar multiplication other * self as a PTM object.

        Raises:
            QiskitError: if other is not a valid scalar.


return SuperOp(self)._evolve(state, qargs)<EOL>

Evolve a quantum state by the QuantumChannel.

        Args:
            state (QuantumState): The input statevector or density matrix.
            qargs (list): a list of QuantumState subsystem positions to apply
                           the operator on.

        Returns:
            DensityMatrix: the output quantum state as a density matrix.


if not isinstance(other, PTM):<EOL><INDENT>other = PTM(other)<EOL><DEDENT>if reverse:<EOL><INDENT>input_dims = self.input_dims() + other.input_dims()<EOL>output_dims = self.output_dims() + other.output_dims()<EOL>data = np.kron(other.data, self._data)<EOL><DEDENT>else:<EOL><INDENT>input_dims = other.input_dims() + self.input_dims()<EOL>output_dims = other.output_dims() + self.output_dims()<EOL>data = np.kron(self._data, other.data)<EOL><DEDENT>return PTM(data, input_dims, output_dims)<EOL>

Return the tensor product channel.

        Args:
            other (QuantumChannel): a quantum channel.
            reverse (bool): If False return self ⊗ other, if True return
                            if True return (other ⊗ self) [Default: False
        Returns:
            PTM: the tensor product channel as a PTM object.

        Raises:
            QiskitError: if other cannot be converted to a channel.


if qobj.experiments:<EOL><INDENT>circuits = []<EOL>for x in qobj.experiments:<EOL><INDENT>quantum_registers = [QuantumRegister(i[<NUM_LIT:1>], name=i[<NUM_LIT:0>])<EOL>for i in x.header.qreg_sizes]<EOL>classical_registers = [ClassicalRegister(i[<NUM_LIT:1>], name=i[<NUM_LIT:0>])<EOL>for i in x.header.creg_sizes]<EOL>circuit = QuantumCircuit(*quantum_registers,<EOL>*classical_registers,<EOL>name=x.header.name)<EOL>qreg_dict = {}<EOL>creg_dict = {}<EOL>for reg in quantum_registers:<EOL><INDENT>qreg_dict[reg.name] = reg<EOL><DEDENT>for reg in classical_registers:<EOL><INDENT>creg_dict[reg.name] = reg<EOL><DEDENT>for i in x.instructions:<EOL><INDENT>instr_method = getattr(circuit, i.name)<EOL>qubits = []<EOL>try:<EOL><INDENT>for qubit in i.qubits:<EOL><INDENT>qubit_label = x.header.qubit_labels[qubit]<EOL>qubits.append(<EOL>qreg_dict[qubit_label[<NUM_LIT:0>]][qubit_label[<NUM_LIT:1>]])<EOL><DEDENT><DEDENT>except Exception:  <EOL><INDENT>pass<EOL><DEDENT>clbits = []<EOL>try:<EOL><INDENT>for clbit in i.memory:<EOL><INDENT>clbit_label = x.header.clbit_labels[clbit]<EOL>clbits.append(<EOL>creg_dict[clbit_label[<NUM_LIT:0>]][clbit_label[<NUM_LIT:1>]])<EOL><DEDENT><DEDENT>except Exception:  <EOL><INDENT>pass<EOL><DEDENT>params = []<EOL>try:<EOL><INDENT>params = i.params<EOL><DEDENT>except Exception:  <EOL><INDENT>pass<EOL><DEDENT>if i.name in ['<STR_LIT>']:<EOL><INDENT>instr_method(<EOL>i.label,<EOL>snapshot_type=i.snapshot_type,<EOL>qubits=qubits,<EOL>params=params)<EOL><DEDENT>elif i.name == '<STR_LIT>':<EOL><INDENT>instr_method(params, qubits)<EOL><DEDENT>else:<EOL><INDENT>instr_method(*params, *qubits, *clbits)<EOL><DEDENT><DEDENT>circuits.append(circuit)<EOL><DEDENT>return circuits<EOL><DEDENT>return None<EOL>

Return a list of QuantumCircuit object(s) from a qobj

    Args:
        qobj (Qobj): The Qobj object to convert to QuantumCircuits
    Returns:
        list: A list of QuantumCircuit objects from the qobj


run_config = qobj.config.to_dict()<EOL>user_qobj_header = qobj.header.to_dict()<EOL>circuits = _experiments_to_circuits(qobj)<EOL>return circuits, run_config, user_qobj_header<EOL>

Dissasemble a qobj and return the circuits, run_config, and user header

    Args:
        qobj (Qobj): The input qobj object to dissasemble
    Returns:
        circuits (list): A list of quantum circuits
        run_config (dict): The dist of the run config
        user_qobj_header (dict): The dict of any user headers in the qobj


def assemble_circuits(circuits, qobj_id=None, qobj_header=None, run_config=None):

qobj_config = QasmQobjConfig()<EOL>if run_config:<EOL><INDENT>qobj_config = QasmQobjConfig(**run_config.to_dict())<EOL><DEDENT>experiments = []<EOL>max_n_qubits = <NUM_LIT:0><EOL>max_memory_slots = <NUM_LIT:0><EOL>for circuit in circuits:<EOL><INDENT>n_qubits = <NUM_LIT:0><EOL>memory_slots = <NUM_LIT:0><EOL>qubit_labels = []<EOL>clbit_labels = []<EOL>qreg_sizes = []<EOL>creg_sizes = []<EOL>for qreg in circuit.qregs:<EOL><INDENT>qreg_sizes.append([qreg.name, qreg.size])<EOL>for j in range(qreg.size):<EOL><INDENT>qubit_labels.append([qreg.name, j])<EOL><DEDENT>n_qubits += qreg.size<EOL><DEDENT>for creg in circuit.cregs:<EOL><INDENT>creg_sizes.append([creg.name, creg.size])<EOL>for j in range(creg.size):<EOL><INDENT>clbit_labels.append([creg.name, j])<EOL><DEDENT>memory_slots += creg.size<EOL><DEDENT>experimentheader = QobjExperimentHeader(qubit_labels=qubit_labels,<EOL>n_qubits=n_qubits,<EOL>qreg_sizes=qreg_sizes,<EOL>clbit_labels=clbit_labels,<EOL>memory_slots=memory_slots,<EOL>creg_sizes=creg_sizes,<EOL>name=circuit.name)<EOL>experimentconfig = QasmQobjExperimentConfig(n_qubits=n_qubits, memory_slots=memory_slots)<EOL>is_conditional_experiment = any(op.control for (op, qargs, cargs) in circuit.data)<EOL>max_conditional_idx = <NUM_LIT:0><EOL>instructions = []<EOL>for op_context in circuit.data:<EOL><INDENT>instruction = op_context[<NUM_LIT:0>].assemble()<EOL>qargs = op_context[<NUM_LIT:1>]<EOL>cargs = op_context[<NUM_LIT:2>]<EOL>if qargs:<EOL><INDENT>qubit_indices = [qubit_labels.index([qubit[<NUM_LIT:0>].name, qubit[<NUM_LIT:1>]])<EOL>for qubit in qargs]<EOL>instruction.qubits = qubit_indices<EOL><DEDENT>if cargs:<EOL><INDENT>clbit_indices = [clbit_labels.index([clbit[<NUM_LIT:0>].name, clbit[<NUM_LIT:1>]])<EOL>for clbit in cargs]<EOL>instruction.memory = clbit_indices<EOL>if instruction.name == "<STR_LIT>" and is_conditional_experiment:<EOL><INDENT>instruction.register = clbit_indices<EOL><DEDENT><DEDENT>if hasattr(instruction, '<STR_LIT>'):<EOL><INDENT>ctrl_reg, ctrl_val = instruction._control<EOL>mask = <NUM_LIT:0><EOL>val = <NUM_LIT:0><EOL>for clbit in clbit_labels:<EOL><INDENT>if clbit[<NUM_LIT:0>] == ctrl_reg.name:<EOL><INDENT>mask |= (<NUM_LIT:1> << clbit_labels.index(clbit))<EOL>val |= (((ctrl_val >> clbit[<NUM_LIT:1>]) & <NUM_LIT:1>) << clbit_labels.index(clbit))<EOL><DEDENT><DEDENT>conditional_reg_idx = memory_slots + max_conditional_idx<EOL>conversion_bfunc = QasmQobjInstruction(name='<STR_LIT>',<EOL>mask="<STR_LIT>" % mask,<EOL>relation='<STR_LIT>',<EOL>val="<STR_LIT>" % val,<EOL>register=conditional_reg_idx)<EOL>instructions.append(conversion_bfunc)<EOL>instruction.conditional = conditional_reg_idx<EOL>max_conditional_idx += <NUM_LIT:1><EOL>del instruction._control<EOL><DEDENT>instructions.append(instruction)<EOL><DEDENT>experiments.append(QasmQobjExperiment(instructions=instructions, header=experimentheader,<EOL>config=experimentconfig))<EOL>if n_qubits > max_n_qubits:<EOL><INDENT>max_n_qubits = n_qubits<EOL><DEDENT>if memory_slots > max_memory_slots:<EOL><INDENT>max_memory_slots = memory_slots<EOL><DEDENT><DEDENT>qobj_config.memory_slots = max_memory_slots<EOL>qobj_config.n_qubits = max_n_qubits<EOL>return QasmQobj(qobj_id=qobj_id,<EOL>config=qobj_config,<EOL>experiments=experiments,<EOL>header=qobj_header)<EOL>

Assembles a list of circuits into a qobj which can be run on the backend.

    Args:
        circuits (list[QuantumCircuits]): circuit(s) to assemble
        qobj_id (int): identifier for the generated qobj
        qobj_header (QobjHeader): header to pass to the results
        run_config (RunConfig): configuration of the runtime environment

    Returns:
        QasmQobj: the Qobj to be run on the backends


def assemble_schedules(schedules, qobj_id=None, qobj_header=None, run_config=None):

qobj_config = QasmQobjConfig()<EOL>if run_config:<EOL><INDENT>qobj_config = QasmQobjConfig(**run_config.to_dict())<EOL><DEDENT>instruction_converter = PulseQobjConverter<EOL>instruction_converter = instruction_converter(PulseQobjInstruction, **run_config.to_dict())<EOL>lo_converter = LoConfigConverter(PulseQobjExperimentConfig, run_config.qubit_lo_freq,<EOL>run_config.meas_lo_freq, **run_config.to_dict())<EOL>qobj_schedules = []<EOL>user_pulselib = set()<EOL>for idx, schedule in enumerate(schedules):<EOL><INDENT>qobj_instructions = []<EOL>for shift, instruction in schedule.instructions:<EOL><INDENT>qobj_instructions.append(instruction_converter(shift, instruction))<EOL>if isinstance(instruction, PulseInstruction):<EOL><INDENT>user_pulselib.add(instruction.command)<EOL><DEDENT><DEDENT>qobj_experiment_header = QobjExperimentHeader(<EOL>name=schedule.name or '<STR_LIT>' % idx<EOL>)<EOL>qobj_schedules.append({<EOL>'<STR_LIT>': qobj_experiment_header,<EOL>'<STR_LIT>': qobj_instructions<EOL>})<EOL><DEDENT>run_config.pulse_library = [QobjPulseLibrary(name=pulse.name, samples=pulse.samples)<EOL>for pulse in user_pulselib]<EOL>experiments = []<EOL>if len(run_config.schedule_los) == <NUM_LIT:1>:<EOL><INDENT>lo_dict = run_config.schedule_los.pop()<EOL>q_los = lo_converter.get_qubit_los(lo_dict)<EOL>if q_los:<EOL><INDENT>run_config.qubit_lo_freq = q_los<EOL><DEDENT>m_los = lo_converter.get_meas_los(lo_dict)<EOL>if m_los:<EOL><INDENT>run_config.meas_lo_freq = m_los<EOL><DEDENT><DEDENT>if run_config.schedule_los:<EOL><INDENT>if len(qobj_schedules) == <NUM_LIT:1>:<EOL><INDENT>for lo_dict in run_config.schedule_los:<EOL><INDENT>experiments.append(PulseQobjExperiment(<EOL>instructions=qobj_schedules[<NUM_LIT:0>]['<STR_LIT>'],<EOL>experimentheader=qobj_schedules[<NUM_LIT:0>]['<STR_LIT>'],<EOL>experimentconfig=lo_converter(lo_dict)<EOL>))<EOL><DEDENT><DEDENT>elif len(qobj_schedules) == len(run_config.schedule_los):<EOL><INDENT>for lo_dict, schedule in zip(run_config.schedule_los, qobj_schedules):<EOL><INDENT>experiments.append(PulseQobjExperiment(<EOL>instructions=schedule['<STR_LIT>'],<EOL>experimentheader=schedule['<STR_LIT>'],<EOL>experimentconfig=lo_converter(lo_dict)<EOL>))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise QiskitError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for schedule in qobj_schedules:<EOL><INDENT>experiments.append(PulseQobjExperiment(<EOL>instructions=schedule['<STR_LIT>'],<EOL>experimentheader=schedule['<STR_LIT>'],<EOL>))<EOL><DEDENT><DEDENT>qobj_config = PulseQobjConfig(**run_config.to_dict())<EOL>return PulseQobj(qobj_id=qobj_id,<EOL>config=qobj_config,<EOL>experiments=experiments,<EOL>header=qobj_header)<EOL>

Assembles a list of schedules into a qobj which can be run on the backend.
    Args:
        schedules (list[Schedule]): schedules to assemble
        qobj_id (int): identifier for the generated qobj
        qobj_header (QobjHeader): header to pass to the results
        run_config (RunConfig): configuration of the runtime environment
    Returns:
        PulseQobj: the Qobj to be run on the backends
    Raises:
        QiskitError: when invalid schedules or configs are provided


def assemble(experiments,<EOL>backend=None,<EOL>qobj_id=None, qobj_header=None,  <EOL>shots=<NUM_LIT>, memory=False, max_credits=None, seed_simulator=None,<EOL>default_qubit_los=None, default_meas_los=None,  <EOL>schedule_los=None, meas_level=<NUM_LIT:2>, meas_return='<STR_LIT>',<EOL>memory_slots=None, memory_slot_size=<NUM_LIT:100>, rep_time=None, parameter_binds=None,<EOL>config=None, seed=None,  <EOL>**run_config):

<EOL>if config:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>', DeprecationWarning)<EOL>run_config = run_config or config<EOL><DEDENT>if seed:<EOL><INDENT>warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>seed_simulator = seed_simulator or seed<EOL><DEDENT>experiments = experiments if isinstance(experiments, list) else [experiments]<EOL>qobj_id, qobj_header, run_config = _parse_run_args(backend, qobj_id, qobj_header,<EOL>shots, memory, max_credits, seed_simulator,<EOL>default_qubit_los, default_meas_los,<EOL>schedule_los, meas_level, meas_return,<EOL>memory_slots, memory_slot_size, rep_time,<EOL>parameter_binds, **run_config)<EOL>if all(isinstance(exp, QuantumCircuit) for exp in experiments):<EOL><INDENT>bound_experiments, run_config = _expand_parameters(circuits=experiments,<EOL>run_config=run_config)<EOL>return assemble_circuits(circuits=bound_experiments, qobj_id=qobj_id,<EOL>qobj_header=qobj_header, run_config=run_config)<EOL><DEDENT>elif all(isinstance(exp, Schedule) for exp in experiments):<EOL><INDENT>return assemble_schedules(schedules=experiments, qobj_id=qobj_id,<EOL>qobj_header=qobj_header, run_config=run_config)<EOL><DEDENT>else:<EOL><INDENT>raise QiskitError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>

Assemble a list of circuits or pulse schedules into a Qobj.

    This function serializes the payloads, which could be either circuits or schedules,
    to create Qobj "experiments". It further annotates the experiment payload with
    header and configurations.

    Args:
        experiments (QuantumCircuit or list[QuantumCircuit] or Schedule or list[Schedule]):
            Circuit(s) or pulse schedule(s) to execute

        backend (BaseBackend):
            If set, some runtime options are automatically grabbed from
            backend.configuration() and backend.defaults().
            If any other option is explicitly set (e.g. rep_rate), it
            will override the backend's.
            If any other options is set in the run_config, it will
            also override the backend's.

        qobj_id (str):
            String identifier to annotate the Qobj

        qobj_header (QobjHeader or dict):
            User input that will be inserted in Qobj header, and will also be
            copied to the corresponding Result header. Headers do not affect the run.

        shots (int):
            Number of repetitions of each circuit, for sampling. Default: 2014

        memory (bool):
            If True, per-shot measurement bitstrings are returned as well
            (provided the backend supports it). For OpenPulse jobs, only
            measurement level 2 supports this option. Default: False

        max_credits (int):
            Maximum credits to spend on job. Default: 10

        seed_simulator (int):
            Random seed to control sampling, for when backend is a simulator

        default_qubit_los (list):
            List of default qubit lo frequencies

        default_meas_los (list):
            List of default meas lo frequencies

        schedule_los (None or list[Union[Dict[PulseChannel, float], LoConfig]] or
                      Union[Dict[PulseChannel, float], LoConfig]):
            Experiment LO configurations

        meas_level (int):
            Set the appropriate level of the measurement output for pulse experiments.

        meas_return (str):
            Level of measurement data for the backend to return
            For `meas_level` 0 and 1:
                "single" returns information from every shot.
                "avg" returns average measurement output (averaged over number of shots).

        memory_slots (int):
            Number of classical memory slots used in this job.

        memory_slot_size (int):
            Size of each memory slot if the output is Level 0.

        rep_time (int): repetition time of the experiment in μs.
            The delay between experiments will be rep_time.
            Must be from the list provided by the device.

        parameter_binds (list[dict{Parameter: Value}]):
            List of Parameter bindings over which the set of experiments will be
            executed. Each list element (bind) should be of the form
            {Parameter1: value1, Parameter2: value2, ...}. All binds will be
            executed across all experiments, e.g. if parameter_binds is a
            length-n list, and there are m experiments, a total of m x n
            experiments will be run (one for each experiment/bind pair).

        seed (int):
            DEPRECATED in 0.8: use ``seed_simulator`` kwarg instead

        config (dict):
            DEPRECATED in 0.8: use run_config instead

        run_config (dict):
            extra arguments used to configure the run (e.g. for Aer configurable backends)
            Refer to the backend documentation for details on these arguments

    Returns:
        Qobj: a qobj which can be run on a backend. Depending on the type of input,
            this will be either a QasmQobj or a PulseQobj.

    Raises:
        QiskitError: if the input cannot be interpreted as either circuits or schedules


def _parse_run_args(backend, qobj_id, qobj_header,<EOL>shots, memory, max_credits, seed_simulator,<EOL>default_qubit_los, default_meas_los,<EOL>schedule_los, meas_level, meas_return,<EOL>memory_slots, memory_slot_size, rep_time,<EOL>parameter_binds, **run_config):

<EOL>backend_config = None<EOL>backend_default = None<EOL>if backend:<EOL><INDENT>backend_config = backend.configuration()<EOL>try:<EOL><INDENT>backend_default = backend.defaults()<EOL><DEDENT>except (ModelValidationError, AttributeError):<EOL><INDENT>from collections import namedtuple<EOL>backend_config_defaults = getattr(backend_config, '<STR_LIT>', {})<EOL>BackendDefault = namedtuple('<STR_LIT>', ('<STR_LIT>', '<STR_LIT>'))<EOL>backend_default = BackendDefault(<EOL>qubit_freq_est=backend_config_defaults.get('<STR_LIT>'),<EOL>meas_freq_est=backend_config_defaults.get('<STR_LIT>')<EOL>)<EOL><DEDENT><DEDENT>memory_slots = memory_slots or getattr(backend_config, '<STR_LIT>', None)<EOL>rep_time = rep_time or getattr(backend_config, '<STR_LIT>', None)<EOL>if isinstance(rep_time, list):<EOL><INDENT>rep_time = rep_time[-<NUM_LIT:1>]<EOL><DEDENT>parameter_binds = parameter_binds or []<EOL>schedule_los = schedule_los or []<EOL>if isinstance(schedule_los, (LoConfig, dict)):<EOL><INDENT>schedule_los = [schedule_los]<EOL><DEDENT>schedule_los = [lo_config if isinstance(lo_config, LoConfig) else LoConfig(lo_config)<EOL>for lo_config in schedule_los]<EOL>qubit_lo_freq = default_qubit_los or getattr(backend_default, '<STR_LIT>', [])<EOL>meas_lo_freq = default_meas_los or getattr(backend_default, '<STR_LIT>', [])<EOL>qobj_id = qobj_id or str(uuid.uuid4())<EOL>qobj_header = qobj_header or {}<EOL>if isinstance(qobj_header, QobjHeader):<EOL><INDENT>qobj_header = qobj_header.to_dict()<EOL><DEDENT>backend_name = getattr(backend_config, '<STR_LIT>', None)<EOL>backend_version = getattr(backend_config, '<STR_LIT>', None)<EOL>qobj_header = {**dict(backend_name=backend_name, backend_version=backend_version),<EOL>**qobj_header}<EOL>qobj_header = QobjHeader(**{k: v for k, v in qobj_header.items() if v is not None})<EOL>run_config_dict = dict(shots=shots,<EOL>memory=memory,<EOL>max_credits=max_credits,<EOL>seed_simulator=seed_simulator,<EOL>seed=seed_simulator,  <EOL>qubit_lo_freq=qubit_lo_freq,<EOL>meas_lo_freq=meas_lo_freq,<EOL>schedule_los=schedule_los,<EOL>meas_level=meas_level,<EOL>meas_return=meas_return,<EOL>memory_slots=memory_slots,<EOL>memory_slot_size=memory_slot_size,<EOL>rep_time=rep_time,<EOL>parameter_binds=parameter_binds,<EOL>**run_config)<EOL>run_config = RunConfig(**{k: v for k, v in run_config_dict.items() if v is not None})<EOL>return qobj_id, qobj_header, run_config<EOL>

Resolve the various types of args allowed to the assemble() function through
    duck typing, overriding args, etc. Refer to the assemble() docstring for details on
    what types of inputs are allowed.

    Here the args are resolved by converting them to standard instances, and prioritizing
    them in case a run option is passed through multiple args (explicitly setting an arg
    has more priority than the arg set by backend)

    Returns:
        RunConfig: a run config, which is a standardized object that configures the qobj
            and determines the runtime environment.


parameter_binds = run_config.parameter_binds<EOL>if parameter_binds orany(circuit.parameters for circuit in circuits):<EOL><INDENT>all_bind_parameters = [bind.keys()<EOL>for bind in parameter_binds]<EOL>all_circuit_parameters = [circuit.parameters for circuit in circuits]<EOL>unique_parameters = set(param<EOL>for param_list in all_bind_parameters + all_circuit_parameters<EOL>for param in param_list)<EOL>if not all_bind_parametersor not all_circuit_parametersor any(unique_parameters != bind_params for bind_params in all_bind_parameters)or any(unique_parameters != parameters for parameters in all_circuit_parameters):<EOL><INDENT>raise QiskitError(<EOL>('<STR_LIT>' +<EOL>'<STR_LIT>' +<EOL>'<STR_LIT>').format(all_bind_parameters, all_circuit_parameters))<EOL><DEDENT>circuits = [circuit.bind_parameters(binds)<EOL>for circuit in circuits<EOL>for binds in parameter_binds]<EOL>run_config = copy.deepcopy(run_config)<EOL>run_config.parameter_binds = []<EOL><DEDENT>return circuits, run_config<EOL>

Verifies that there is a single common set of parameters shared between
    all circuits and all parameter binds in the run_config. Returns an expanded
    list of circuits (if parameterized) with all parameters bound, and a copy of
    the run_config with parameter_binds cleared.

    If neither the circuits nor the run_config specify parameters, the two are
    returned unmodified.

    Raises:
        QiskitError: if run_config parameters are not compatible with circuit parameters

    Returns:
        Tuple(List[QuantumCircuit], RunConfig):
          - List of input circuits expanded and with parameters bound
          - RunConfig with parameter_binds removed


<EOL>if seed_mapper:<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>seed_transpiler = seed_mapper<EOL><DEDENT>if isinstance(circuits, Schedule) or(isinstance(circuits, list) and all(isinstance(c, Schedule) for c in circuits)):<EOL><INDENT>return circuits<EOL><DEDENT>circuits = circuits if isinstance(circuits, list) else [circuits]<EOL>transpile_configs = _parse_transpile_args(circuits, backend, basis_gates, coupling_map,<EOL>backend_properties, initial_layout,<EOL>seed_transpiler, optimization_level,<EOL>pass_manager)<EOL>circuits = parallel_map(_transpile_circuit, list(zip(circuits, transpile_configs)))<EOL>if len(circuits) == <NUM_LIT:1>:<EOL><INDENT>return circuits[<NUM_LIT:0>]<EOL><DEDENT>return circuits<EOL>

transpile one or more circuits, according to some desired
    transpilation targets.

    All arguments may be given as either singleton or list. In case of list,
    the length must be equal to the number of circuits being transpiled.

    Transpilation is done in parallel using multiprocessing.

    Args:
        circuits (QuantumCircuit or list[QuantumCircuit]):
            Circuit(s) to transpile

        backend (BaseBackend):
            If set, transpiler options are automatically grabbed from
            backend.configuration() and backend.properties().
            If any other option is explicitly set (e.g. coupling_map), it
            will override the backend's.
            Note: the backend arg is purely for convenience. The resulting
                circuit may be run on any backend as long as it is compatible.

        basis_gates (list[str]):
            List of basis gate names to unroll to.
            e.g:
                ['u1', 'u2', 'u3', 'cx']
            If None, do not unroll.

        coupling_map (CouplingMap or list):
            Coupling map (perhaps custom) to target in mapping.
            Multiple formats are supported:
            a. CouplingMap instance

            b. list
                Must be given as an adjacency matrix, where each entry
                specifies all two-qubit interactions supported by backend
                e.g:
                    [[0, 1], [0, 3], [1, 2], [1, 5], [2, 5], [4, 1], [5, 3]]

        backend_properties (BackendProperties):
            properties returned by a backend, including information on gate
            errors, readout errors, qubit coherence times, etc. For a backend
            that provides this information, it can be obtained with:
            ``backend.properties()``

        initial_layout (Layout or dict or list):
            Initial position of virtual qubits on physical qubits.
            If this layout makes the circuit compatible with the coupling_map
            constraints, it will be used.
            The final layout is not guaranteed to be the same, as the transpiler
            may permute qubits through swaps or other means.

            Multiple formats are supported:
            a. Layout instance

            b. dict
                virtual to physical:
                    {qr[0]: 0,
                     qr[1]: 3,
                     qr[2]: 5}

                physical to virtual:
                    {0: qr[0],
                     3: qr[1],
                     5: qr[2]}

            c. list
                virtual to physical:
                    [0, 3, 5]  # virtual qubits are ordered (in addition to named)

                physical to virtual:
                    [qr[0], None, None, qr[1], None, qr[2]]

        seed_transpiler (int):
            sets random seed for the stochastic parts of the transpiler

        optimization_level (int):
            How much optimization to perform on the circuits.
            Higher levels generate more optimized circuits,
            at the expense of longer transpilation time.
                0: no optimization
                1: light optimization
                2: heavy optimization

        pass_manager (PassManager):
            The pass manager to use for a custom pipeline of transpiler passes.
            If this arg is present, all other args will be ignored and the
            pass manager will be used directly (Qiskit will not attempt to
            auto-select a pass manager based on transpile options).

        seed_mapper (int):
            DEPRECATED in 0.8: use ``seed_transpiler`` kwarg instead

    Returns:
        QuantumCircuit or list[QuantumCircuit]: transpiled circuit(s).

    Raises:
        TranspilerError: in case of bad inputs to transpiler or errors in passes


circuit, transpile_config = circuit_config_tuple<EOL>if transpile_config.pass_manager:<EOL><INDENT>pass_manager = transpile_config.pass_manager<EOL><DEDENT>elif transpile_config.coupling_map:<EOL><INDENT>pass_manager = default_pass_manager(transpile_config.basis_gates,<EOL>transpile_config.coupling_map,<EOL>transpile_config.initial_layout,<EOL>transpile_config.seed_transpiler)<EOL><DEDENT>else:<EOL><INDENT>pass_manager = default_pass_manager_simulator(transpile_config.basis_gates)<EOL><DEDENT>return pass_manager.run(circuit)<EOL>

Select a PassManager and run a single circuit through it.

    Args:
        circuit_config_tuple (tuple):
            circuit (QuantumCircuit): circuit to transpile
            transpile_config (TranspileConfig): configuration dictating how to transpile

    Returns:
        QuantumCircuit: transpiled circuit


def _parse_transpile_args(circuits, backend,<EOL>basis_gates, coupling_map, backend_properties,<EOL>initial_layout, seed_transpiler, optimization_level,<EOL>pass_manager):

<EOL>num_circuits = len(circuits)<EOL>basis_gates = _parse_basis_gates(basis_gates, backend, circuits)<EOL>coupling_map = _parse_coupling_map(coupling_map, backend, num_circuits)<EOL>backend_properties = _parse_backend_properties(backend_properties, backend, num_circuits)<EOL>initial_layout = _parse_initial_layout(initial_layout, circuits)<EOL>seed_transpiler = _parse_seed_transpiler(seed_transpiler, num_circuits)<EOL>optimization_level = _parse_optimization_level(optimization_level, num_circuits)<EOL>pass_manager = _parse_pass_manager(pass_manager, num_circuits)<EOL>transpile_configs = []<EOL>for args in zip(basis_gates, coupling_map, backend_properties, initial_layout,<EOL>seed_transpiler, optimization_level, pass_manager):<EOL><INDENT>transpile_config = TranspileConfig(basis_gates=args[<NUM_LIT:0>],<EOL>coupling_map=args[<NUM_LIT:1>],<EOL>backend_properties=args[<NUM_LIT:2>],<EOL>initial_layout=args[<NUM_LIT:3>],<EOL>seed_transpiler=args[<NUM_LIT:4>],<EOL>optimization_level=args[<NUM_LIT:5>],<EOL>pass_manager=args[<NUM_LIT:6>])<EOL>transpile_configs.append(transpile_config)<EOL><DEDENT>return transpile_configs<EOL>

Resolve the various types of args allowed to the transpile() function through
    duck typing, overriding args, etc. Refer to the transpile() docstring for details on
    what types of inputs are allowed.

    Here the args are resolved by converting them to standard instances, and prioritizing
    them in case a transpile option is passed through multiple args (explicitly setting an
    arg has more priority than the arg set by backend)

    Returns:
        list[TranspileConfig]: a transpile config for each circuit, which is a standardized
            object that configures the transpiler and determines the pass manager to use.


if isinstance(qubits, QuantumRegister):<EOL><INDENT>qubits = qubits[:]<EOL><DEDENT>else:<EOL><INDENT>qubits = _convert_to_bits([qubits], [qbit for qreg in self.qregs for qbit in qreg])[<NUM_LIT:0>]<EOL><DEDENT>return self.append(Initialize(params), qubits)<EOL>


num_qubits = math.log2(len(params))<EOL>if num_qubits == <NUM_LIT:0> or not num_qubits.is_integer():<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>if not math.isclose(sum(np.absolute(params) ** <NUM_LIT:2>), <NUM_LIT:1.0>,<EOL>abs_tol=_EPS):<EOL><INDENT>raise QiskitError("<STR_LIT>")<EOL><DEDENT>num_qubits = int(num_qubits)<EOL>super().__init__("<STR_LIT>", num_qubits, <NUM_LIT:0>, params)<EOL>

Create new initialize composite.

        params (list): vector of complex amplitudes to initialize to


<EOL>disentangling_circuit = self.gates_to_uncompute()<EOL>initialize_instr = disentangling_circuit.to_instruction().inverse()<EOL>q = QuantumRegister(self.num_qubits, '<STR_LIT:q>')<EOL>initialize_circuit = QuantumCircuit(q, name='<STR_LIT>')<EOL>for qubit in q:<EOL><INDENT>initialize_circuit.append(Reset(), [qubit])<EOL><DEDENT>initialize_circuit.append(initialize_instr, q[:])<EOL>self.definition = initialize_circuit.data<EOL>

Calculate a subcircuit that implements this initialization

        Implements a recursive initialization algorithm, including optimizations,
        from "Synthesis of Quantum Logic Circuits" Shende, Bullock, Markov
        https://arxiv.org/abs/quant-ph/0406176v5

        Additionally implements some extra optimizations: remove zero rotations and
        double cnots.


q = QuantumRegister(self.num_qubits)<EOL>circuit = QuantumCircuit(q, name='<STR_LIT>')<EOL>remaining_param = self.params<EOL>for i in range(self.num_qubits):<EOL><INDENT>(remaining_param,<EOL>thetas,<EOL>phis) = Initialize._rotations_to_disentangle(remaining_param)<EOL>rz_mult = self._multiplex(RZGate, phis)<EOL>ry_mult = self._multiplex(RYGate, thetas)<EOL>circuit.append(rz_mult.to_instruction(), q[i:self.num_qubits])<EOL>circuit.append(ry_mult.to_instruction(), q[i:self.num_qubits])<EOL><DEDENT>return circuit<EOL>

Call to create a circuit with gates that take the
desired vector to zero.

Returns:
    QuantumCircuit: circuit to take self.params vector to |00..0>


remaining_vector = []<EOL>thetas = []<EOL>phis = []<EOL>param_len = len(local_param)<EOL>for i in range(param_len // <NUM_LIT:2>):<EOL><INDENT>(remains,<EOL>add_theta,<EOL>add_phi) = Initialize._bloch_angles(local_param[<NUM_LIT:2> * i: <NUM_LIT:2> * (i + <NUM_LIT:1>)])<EOL>remaining_vector.append(remains)<EOL>thetas.append(-add_theta)<EOL>phis.append(-add_phi)<EOL><DEDENT>return remaining_vector, thetas, phis<EOL>

Static internal method to work out Ry and Rz rotation angles used
to disentangle the LSB qubit.
These rotations make up the block diagonal matrix U (i.e. multiplexor)
that disentangles the LSB.

[[Ry(theta_1).Rz(phi_1)  0   .   .   0],
 [0         Ry(theta_2).Rz(phi_2) .  0],
                            .
                                .
  0         0           Ry(theta_2^n).Rz(phi_2^n)]]


[a_complex, b_complex] = pair_of_complex<EOL>a_complex = complex(a_complex)<EOL>b_complex = complex(b_complex)<EOL>mag_a = np.absolute(a_complex)<EOL>final_r = float(np.sqrt(mag_a ** <NUM_LIT:2> + np.absolute(b_complex) ** <NUM_LIT:2>))<EOL>if final_r < _EPS:<EOL><INDENT>theta = <NUM_LIT:0><EOL>phi = <NUM_LIT:0><EOL>final_r = <NUM_LIT:0><EOL>final_t = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>theta = float(<NUM_LIT:2> * np.arccos(mag_a / final_r))<EOL>a_arg = np.angle(a_complex)<EOL>b_arg = np.angle(b_complex)<EOL>final_t = a_arg + b_arg<EOL>phi = b_arg - a_arg<EOL><DEDENT>return final_r * np.exp(<NUM_LIT> * final_t / <NUM_LIT:2>), theta, phi<EOL>

Static internal method to work out rotation to create the passed in
qubit from the zero vector.


def _multiplex(self, target_gate, list_of_angles):

list_len = len(list_of_angles)<EOL>local_num_qubits = int(math.log2(list_len)) + <NUM_LIT:1><EOL>q = QuantumRegister(local_num_qubits)<EOL>circuit = QuantumCircuit(q, name="<STR_LIT>" + local_num_qubits.__str__())<EOL>lsb = q[<NUM_LIT:0>]<EOL>msb = q[local_num_qubits - <NUM_LIT:1>]<EOL>if local_num_qubits == <NUM_LIT:1>:<EOL><INDENT>circuit.append(target_gate(list_of_angles[<NUM_LIT:0>]), [q[<NUM_LIT:0>]])<EOL>return circuit<EOL><DEDENT>angle_weight = scipy.kron([[<NUM_LIT:0.5>, <NUM_LIT:0.5>], [<NUM_LIT:0.5>, -<NUM_LIT:0.5>]],<EOL>np.identity(<NUM_LIT:2> ** (local_num_qubits - <NUM_LIT:2>)))<EOL>list_of_angles = angle_weight.dot(np.array(list_of_angles)).tolist()<EOL>multiplex_1 = self._multiplex(target_gate, list_of_angles[<NUM_LIT:0>:(list_len // <NUM_LIT:2>)])<EOL>circuit.append(multiplex_1.to_instruction(), q[<NUM_LIT:0>:-<NUM_LIT:1>])<EOL>circuit.append(CnotGate(), [msb, lsb])<EOL>multiplex_2 = self._multiplex(target_gate, list_of_angles[(list_len // <NUM_LIT:2>):])<EOL>if list_len > <NUM_LIT:1>:<EOL><INDENT>circuit.append(multiplex_2.to_instruction().mirror(), q[<NUM_LIT:0>:-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>circuit.append(multiplex_2.to_instruction(), q[<NUM_LIT:0>:-<NUM_LIT:1>])<EOL><DEDENT>circuit.append(CnotGate(), [msb, lsb])<EOL>return circuit<EOL>

Return a recursive implementation of a multiplexor circuit,
where each instruction itself has a decomposition based on
smaller multiplexors.

The LSB is the multiplexor "data" and the other bits are multiplexor "select".

Args:
    target_gate (Gate): Ry or Rz gate to apply to target qubit, multiplexed
        over all other "select" qubits
    list_of_angles (list[float]): list of rotation angles to apply Ry and Rz

Returns:
    DAGCircuit: the circuit implementing the multiplexor's action


def unitary(self, obj, qubits, label=None):

if isinstance(qubits, QuantumRegister):<EOL><INDENT>qubits = qubits[:]<EOL><DEDENT>return self.append(UnitaryGate(obj, label=label), qubits, [])<EOL>


if hasattr(data, '<STR_LIT>'):<EOL><INDENT>data = data.to_matrix()<EOL><DEDENT>elif hasattr(data, '<STR_LIT>'):<EOL><INDENT>data = data.to_operator().data<EOL><DEDENT>data = numpy.array(data, dtype=complex)<EOL>if not is_unitary_matrix(data):<EOL><INDENT>raise ExtensionError("<STR_LIT>")<EOL><DEDENT>input_dim, output_dim = data.shape<EOL>n_qubits = int(numpy.log2(input_dim))<EOL>if input_dim != output_dim or <NUM_LIT:2>**n_qubits != input_dim:<EOL><INDENT>raise ExtensionError(<EOL>"<STR_LIT>")<EOL><DEDENT>super().__init__('<STR_LIT>', n_qubits, [data], label=label)<EOL>

Create a gate from a numeric unitary matrix.

        Args:
            data (matrix or Operator): unitary operator.
            label (str): unitary name for backend [Default: None].

        Raises:
            ExtensionError: if input data is not an N-qubit unitary operator.


return self.params[<NUM_LIT:0>]<EOL>


return self.adjoint()<EOL>


return UnitaryGate(numpy.conj(self.to_matrix()))<EOL>


return self.transpose().conjugate()<EOL>


return UnitaryGate(numpy.transpose(self.to_matrix()))<EOL>


if self.num_qubits == <NUM_LIT:1>:<EOL><INDENT>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>angles = euler_angles_1q(self.to_matrix())<EOL>self.definition = [(U3Gate(*angles), [q[<NUM_LIT:0>]], [])]<EOL><DEDENT>if self.num_qubits == <NUM_LIT:2>:<EOL><INDENT>self.definition = two_qubit_kak(self.to_matrix())<EOL><DEDENT>

Calculate a subcircuit that implements this unitary.


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cu1(self, theta, ctl, tgt):

return self.append(Cu1Gate(theta), [ctl, tgt], [])<EOL>

Apply cu1 from ctl to tgt with angle theta.


super().__init__("<STR_LIT>", <NUM_LIT:2>, [theta])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(self.params[<NUM_LIT:0>] / <NUM_LIT:2>), [q[<NUM_LIT:0>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U1Gate(-self.params[<NUM_LIT:0>] / <NUM_LIT:2>), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U1Gate(self.params[<NUM_LIT:0>] / <NUM_LIT:2>), [q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate cu1(lambda) a,b
{ u1(lambda/2) a; cx a,b;
  u1(-lambda/2) b; cx a,b;
  u1(lambda/2) b;
}


return Cu1Gate(-self.params[<NUM_LIT:0>])<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def u_base(self, theta, phi, lam, q):

return self.append(UBase(theta, phi, lam), [q], [])<EOL>


return UBase(-self.params[<NUM_LIT:0>], -self.params[<NUM_LIT:2>], -self.params[<NUM_LIT:1>])<EOL>

Invert this gate.

        U(theta,phi,lambda)^dagger = U(-theta,-lambda,-phi)


theta, phi, lam = self.params<EOL>return numpy.array(<EOL>[[<EOL>numpy.cos(theta / <NUM_LIT:2>),<EOL>-numpy.exp(<NUM_LIT> * lam) * numpy.sin(theta / <NUM_LIT:2>)<EOL>],<EOL>[<EOL>numpy.exp(<NUM_LIT> * phi) * numpy.sin(theta / <NUM_LIT:2>),<EOL>numpy.exp(<NUM_LIT> * (phi + lam)) * numpy.cos(theta / <NUM_LIT:2>)<EOL>]],<EOL>dtype=complex)<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def u1(self, theta, q):

return self.append(U1Gate(theta), [q], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [theta], label=label)<EOL>


return U1Gate(-self.params[<NUM_LIT:0>])<EOL>


lam = self.params[<NUM_LIT:0>]<EOL>lam = float(lam)<EOL>return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:0>, numpy.exp(<NUM_LIT> * lam)]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def u2(self, phi, lam, q):

return self.append(U2Gate(phi, lam), [q], [])<EOL>


def __init__(self, phi, lam, label=None):

super().__init__("<STR_LIT>", <NUM_LIT:1>, [phi, lam], label=label)<EOL>


return U2Gate(-self.params[<NUM_LIT:1>] - pi, -self.params[<NUM_LIT:0>] + pi)<EOL>

Invert this gate.

        u2(phi,lamb)^dagger = u2(-lamb-pi,-phi+pi)


isqrt2 = <NUM_LIT:1> / numpy.sqrt(<NUM_LIT:2>)<EOL>phi, lam = self.params<EOL>phi, lam = float(phi), float(lam)<EOL>return numpy.array([[isqrt2, -numpy.exp(<NUM_LIT> * lam) * isqrt2],<EOL>[<EOL>numpy.exp(<NUM_LIT> * phi) * isqrt2,<EOL>numpy.exp(<NUM_LIT> * (phi + lam)) * isqrt2<EOL>]],<EOL>dtype=complex)<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def crz(self, theta, ctl, tgt):

return self.append(CrzGate(theta), [ctl, tgt], [])<EOL>

Apply crz from ctl to tgt with angle theta.


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(self.params[<NUM_LIT:0>] / <NUM_LIT:2>), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U1Gate(-self.params[<NUM_LIT:0>] / <NUM_LIT:2>), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate crz(lambda) a,b
{ u1(lambda/2) b; cx a,b;
  u1(-lambda/2) b; cx a,b;
}


return CrzGate(-self.params[<NUM_LIT:0>])<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>, broadcastable=[False, False])<EOL>def rzz(self, theta, qubit1, qubit2):

return self.append(RZZGate(theta), [qubit1, qubit2], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:2>, [theta])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U1Gate(self.params[<NUM_LIT:0>]), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate rzz(theta) a, b { cx a, b; u1(theta) b; cx a, b; }


return RZZGate(-self.params[<NUM_LIT:0>])<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def u0(self, m, q):

return self.append(U0Gate(m), [q], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [m])<EOL>


return U0Gate(self.params[<NUM_LIT:0>])<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>]], dtype=complex)<EOL>


return self.append(HGate(), [q], [])<EOL>


super().__init__("<STR_LIT:h>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U2Gate(<NUM_LIT:0>, pi), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return HGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:1>],<EOL>[<NUM_LIT:1>, -<NUM_LIT:1>]], dtype=complex) / numpy.sqrt(<NUM_LIT:2>)<EOL>


return self.append(YGate(), [q], [])<EOL>


super().__init__("<STR_LIT:y>", <NUM_LIT:1>, [], label=label)<EOL>


return YGate()<EOL>


return numpy.array([[<NUM_LIT:0>, -<NUM_LIT>],<EOL>[<NUM_LIT>, <NUM_LIT:0>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:3>)<EOL>@_op_expand(<NUM_LIT:3>, broadcastable=[True, True, False])<EOL>def ccx(self, ctl1, ctl2, tgt):

return self.append(ToffoliGate(), [ctl1, ctl2, tgt], [])<EOL>

Apply Toffoli to from ctl1 and ctl2 to tgt.


super().__init__("<STR_LIT>", <NUM_LIT:3>, [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:3>, "<STR_LIT:q>")<EOL>rule = [<EOL>(HGate(), [q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:1>], q[<NUM_LIT:2>]], []),<EOL>(TdgGate(), [q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:2>]], []),<EOL>(TGate(), [q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:1>], q[<NUM_LIT:2>]], []),<EOL>(TdgGate(), [q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:2>]], []),<EOL>(TGate(), [q[<NUM_LIT:1>]], []),<EOL>(TGate(), [q[<NUM_LIT:2>]], []),<EOL>(HGate(), [q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(TGate(), [q[<NUM_LIT:0>]], []),<EOL>(TdgGate(), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate ccx a,b,c
{
h c; cx b,c; tdg c; cx a,c;
t c; cx b,c; tdg c; cx a,c;
t b; t c; h c; cx a,b;
t a; tdg b; cx a,b;}


return ToffoliGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]], dtype=complex)<EOL>

Return a Numpy.array for the Toffoli gate.


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def u3(self, theta, phi, lam, q):

return self.append(U3Gate(theta, phi, lam), [q], [])<EOL>


def __init__(self, theta, phi, lam, label=None):

super().__init__("<STR_LIT>", <NUM_LIT:1>, [theta, phi, lam], label=label)<EOL>


return U3Gate(-self.params[<NUM_LIT:0>], -self.params[<NUM_LIT:2>], -self.params[<NUM_LIT:1>])<EOL>

Invert this gate.

        u3(theta, phi, lamb)^dagger = u3(-theta, -lam, -phi)


theta, phi, lam = self.params<EOL>theta, phi, lam = float(theta), float(phi), float(lam)<EOL>return numpy.array(<EOL>[[<EOL>numpy.cos(theta / <NUM_LIT:2>),<EOL>-numpy.exp(<NUM_LIT> * lam) * numpy.sin(theta / <NUM_LIT:2>)<EOL>],<EOL>[<EOL>numpy.exp(<NUM_LIT> * phi) * numpy.sin(theta / <NUM_LIT:2>),<EOL>numpy.exp(<NUM_LIT> * (phi + lam)) * numpy.cos(theta / <NUM_LIT:2>)<EOL>]],<EOL>dtype=complex)<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>, broadcastable=[False, False])<EOL>def swap(self, qubit1, qubit2):

return self.append(SwapGate(), [qubit1, qubit2], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:2>, [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:1>], q[<NUM_LIT:0>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate swap a,b { cx a,b; cx b,a; cx a,b; }


return SwapGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def ch(self, ctl, tgt):

return self.append(CHGate(), [ctl, tgt], [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(HGate(), [q[<NUM_LIT:1>]], []),<EOL>(SdgGate(), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(HGate(), [q[<NUM_LIT:1>]], []),<EOL>(TGate(), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(TGate(), [q[<NUM_LIT:1>]], []),<EOL>(HGate(), [q[<NUM_LIT:1>]], []),<EOL>(SGate(), [q[<NUM_LIT:1>]], []),<EOL>(XGate(), [q[<NUM_LIT:1>]], []),<EOL>(SGate(), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate ch a,b {
h b;
sdg b;
cx a,b;
h b;
t b;
cx a,b;
t b;
h b;
s b;
x b;
s a;}


return CHGate()<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cu3(self, theta, phi, lam, ctl, tgt):

return self.append(Cu3Gate(theta, phi, lam), [ctl, tgt], [])<EOL>

Apply cu3 from ctl to tgt with angle theta, phi, lam.


super().__init__("<STR_LIT>", <NUM_LIT:2>, [theta, phi, lam])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate((self.params[<NUM_LIT:2>] - self.params[<NUM_LIT:1>]) / <NUM_LIT:2>), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U3Gate(-self.params[<NUM_LIT:0>] / <NUM_LIT:2>, <NUM_LIT:0>, -(self.params[<NUM_LIT:1>] + self.params[<NUM_LIT:2>]) / <NUM_LIT:2>), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(U3Gate(self.params[<NUM_LIT:0>] / <NUM_LIT:2>, self.params[<NUM_LIT:1>], <NUM_LIT:0>), [q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate cu3(theta,phi,lambda) c, t
{ u1((lambda-phi)/2) t; cx c,t;
  u3(-theta/2,0,-(phi+lambda)/2) t; cx c,t;
  u3(theta/2,phi,0) t;
}


return Cu3Gate(-self.params[<NUM_LIT:0>], -self.params[<NUM_LIT:2>], -self.params[<NUM_LIT:1>])<EOL>


return self.append(XGate(), [q], [])<EOL>


super().__init__("<STR_LIT:x>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U3Gate(pi, <NUM_LIT:0>, pi), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return XGate()<EOL>


return numpy.array([[<NUM_LIT:0>, <NUM_LIT:1>],<EOL>[<NUM_LIT:1>, <NUM_LIT:0>]], dtype=complex)<EOL>


return self.append(IdGate(), [q], [])<EOL>


super().__init__("<STR_LIT:id>", <NUM_LIT:1>, [], label=label)<EOL>


return IdGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def rz(self, phi, q):

return self.append(RZGate(phi), [q], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [phi])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(self.params[<NUM_LIT:0>]), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return RZGate(-self.params[<NUM_LIT:0>])<EOL>

Invert this gate.

        rz(phi)^dagger = rz(-phi)


@_to_bits(<NUM_LIT:3>)<EOL>@_op_expand(<NUM_LIT:3>, broadcastable=[True, False, False])<EOL>def cswap(self, ctl, tgt1, tgt2):

return self.append(FredkinGate(), [ctl, tgt1, tgt2], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:3>, [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:3>, "<STR_LIT:q>")<EOL>rule = [<EOL>(CnotGate(), [q[<NUM_LIT:2>], q[<NUM_LIT:1>]], []),<EOL>(ToffoliGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>], q[<NUM_LIT:2>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:2>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate cswap a,b,c
{ cx c,b;
  ccx a,b,c;
  cx c,b;
}


return FredkinGate()<EOL>


qubits = []<EOL>qargs = _convert_to_bits(qargs, [qbit for qreg in self.qregs for qbit in qreg])<EOL>if not qargs:  <EOL><INDENT>for qreg in self.qregs:<EOL><INDENT>for j in range(qreg.size):<EOL><INDENT>qubits.append((qreg, j))<EOL><DEDENT><DEDENT><DEDENT>for qarg in qargs:<EOL><INDENT>if isinstance(qarg, (QuantumRegister, list)):<EOL><INDENT>if isinstance(qarg, QuantumRegister):<EOL><INDENT>qubits.extend([(qarg, j) for j in range(qarg.size)])<EOL><DEDENT>else:<EOL><INDENT>qubits.extend(qarg)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>qubits.append(qarg)<EOL><DEDENT><DEDENT>return self.append(Barrier(len(qubits)), qubits, [])<EOL>

Apply barrier to circuit.
    If qargs is None, applies to all the qbits.
    Args is a list of QuantumRegister or single qubits.
    For QuantumRegister, applies barrier to all the qubits in that register.


super().__init__("<STR_LIT>", num_qubits, <NUM_LIT:0>, [])<EOL>


return Barrier(self.num_qubits)<EOL>


return self.append(SGate(), [q], [])<EOL>


return self.append(SdgGate(), [q], [])<EOL>


super().__init__("<STR_LIT:s>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(pi/<NUM_LIT:2>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return SdgGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT>]], dtype=complex)<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(-pi/<NUM_LIT:2>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return SGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, -<NUM_LIT>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cz(self, ctl, tgt):

return self.append(CzGate(), [ctl, tgt], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:2>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(HGate(), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(HGate(), [q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return CzGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, -<NUM_LIT:1>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cx_base(self, ctl, tgt):

return self.append(CXBase(), [ctl, tgt], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:2>, [])<EOL>


return CXBase()<EOL>


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cy(self, ctl, tgt):

return self.append(CyGate(), [ctl, tgt], [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(SdgGate(), [q[<NUM_LIT:1>]], []),<EOL>(CnotGate(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], []),<EOL>(SGate(), [q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return CyGate()<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def rx(self, theta, q):

return self.append(RXGate(theta), [q], [])<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [theta])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U3Gate(self.params[<NUM_LIT:0>], -pi/<NUM_LIT:2>, pi/<NUM_LIT:2>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>

gate rx(theta) a {u3(theta, -pi/2, pi/2) a;}


return RXGate(-self.params[<NUM_LIT:0>])<EOL>

Invert this gate.

        rx(theta)^dagger = rx(-theta)


@_to_bits(<NUM_LIT:2>)<EOL>@_op_expand(<NUM_LIT:2>)<EOL>def cx(self, ctl, tgt):

return self.append(CnotGate(), [ctl, tgt], [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:2>, "<STR_LIT:q>")<EOL>rule = [<EOL>(CXBase(), [q[<NUM_LIT:0>], q[<NUM_LIT:1>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return CnotGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>],<EOL>[<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:0>]], dtype=complex)<EOL>


return self.append(ZGate(), [q], [])<EOL>


super().__init__("<STR_LIT:z>", <NUM_LIT:1>, [], label=label)<EOL>


return ZGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, -<NUM_LIT:1>]], dtype=complex)<EOL>


@_to_bits(<NUM_LIT:1>)<EOL>@_op_expand(<NUM_LIT:1>)<EOL>def ry(self, theta, q):

return self.append(RYGate(theta), [q], [])<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U3Gate(self.params[<NUM_LIT:0>], <NUM_LIT:0>, <NUM_LIT:0>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return RYGate(-self.params[<NUM_LIT:0>])<EOL>

Invert this gate.

        ry(theta)^dagger = ry(-theta)


return self.append(TGate(), [q], [])<EOL>


return self.append(TdgGate(), [q], [])<EOL>


super().__init__("<STR_LIT:t>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(pi/<NUM_LIT:4>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return TdgGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, (<NUM_LIT:1>+<NUM_LIT>) / numpy.sqrt(<NUM_LIT:2>)]], dtype=complex)<EOL>


super().__init__("<STR_LIT>", <NUM_LIT:1>, [], label=label)<EOL>


definition = []<EOL>q = QuantumRegister(<NUM_LIT:1>, "<STR_LIT:q>")<EOL>rule = [<EOL>(U1Gate(-pi/<NUM_LIT:4>), [q[<NUM_LIT:0>]], [])<EOL>]<EOL>for inst in rule:<EOL><INDENT>definition.append(inst)<EOL><DEDENT>self.definition = definition<EOL>


return TGate()<EOL>


return numpy.array([[<NUM_LIT:1>, <NUM_LIT:0>],<EOL>[<NUM_LIT:0>, (<NUM_LIT:1>-<NUM_LIT>) / numpy.sqrt(<NUM_LIT:2>)]], dtype=complex)<EOL>


<EOL>if not isinstance(label, str):<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>label = str(label)<EOL><DEDENT>if isinstance(qubits, QuantumRegister):<EOL><INDENT>qubits = qubits[:]<EOL><DEDENT>if not qubits:<EOL><INDENT>tuples = []<EOL>if isinstance(self, QuantumCircuit):<EOL><INDENT>for register in self.qregs:<EOL><INDENT>tuples.append(register)<EOL><DEDENT><DEDENT>if not tuples:<EOL><INDENT>raise ExtensionError('<STR_LIT>')<EOL><DEDENT>qubits = []<EOL>for tuple_element in tuples:<EOL><INDENT>if isinstance(tuple_element, QuantumRegister):<EOL><INDENT>for j in range(tuple_element.size):<EOL><INDENT>qubits.append((tuple_element, j))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>qubits.append(tuple_element)<EOL><DEDENT><DEDENT><DEDENT>return self.append(<EOL>Snapshot(<EOL>label,<EOL>snapshot_type=snapshot_type,<EOL>num_qubits=len(qubits),<EOL>params=params), qubits)<EOL>

Take a statevector snapshot of the internal simulator representation.
    Works on all qubits, and prevents reordering (like barrier).

    For other types of snapshots use the Snapshot extension directly.

    Args:
        label (str): a snapshot label to report the result
        snapshot_type (str): the type of the snapshot.
        qubits (list or None): the qubits to apply snapshot to [Default: None].
        params (list or None): the parameters for snapshot_type [Default: None].

    Returns:
        QuantumCircuit: with attached command

    Raises:
        ExtensionError: malformed command


if not isinstance(label, str):<EOL><INDENT>raise ExtensionError('<STR_LIT>')<EOL><DEDENT>self._label = label<EOL>self._snapshot_type = snapshot_type<EOL>if params is None:<EOL><INDENT>params = []<EOL><DEDENT>super().__init__('<STR_LIT>', num_qubits, num_clbits, params)<EOL>

Create new snapshot instruction.

        Args:
            label (str): the snapshot label for result data.
            snapshot_type (str): the type of the snapshot.
            num_qubits (int): the number of qubits for the snapshot type [Default: 0].
            num_clbits (int): the number of classical bits for the snapshot type [Default: 0].
            params (list or None): the parameters for snapshot_type [Default: None].

        Raises:
            ExtensionError: if snapshot label is invalid.


instruction = super().assemble()<EOL>instruction.label = self._label<EOL>instruction.snapshot_type = self._snapshot_type<EOL>return instruction<EOL>


return Snapshot(self.num_qubits, self.num_clbits, self.params[<NUM_LIT:0>],<EOL>self.params[<NUM_LIT:1>])<EOL>


return self._snapshot_type<EOL>


return self._label<EOL>


if isinstance(name, str):<EOL><INDENT>self._label = name<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>

Set snapshot label to name

        Args:
            name (str or None): label to assign unitary

        Raises:
            TypeError: name is not string or None.


super().__init__(*message)<EOL>self.message = '<STR_LIT:U+0020>'.join(message)<EOL>


return repr(self.message)<EOL>


if os.getenv('<STR_LIT>'):<EOL><INDENT>if os.getenv('<STR_LIT>'):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif os.getenv('<STR_LIT>'):<EOL><INDENT>if os.getenv('<STR_LIT>'):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Check if the tests are being run in a CI environment from a PR.

    Check if the tests are being run in a CI environment and if it is a pull
    request.

    Returns:
        bool: True if the tests are executed inside a CI tool, and the changes
            are not against the "master" branch.


def assertNoLogs(self, logger=None, level=None):

return _AssertNoLogsContext(self, logger, level)<EOL>

Assert that no message is sent to the specified logger and level.

        Context manager to test that no message is sent to the specified
        logger and level (the opposite of TestCase.assertLogs()).


def assertDictAlmostEqual(self, dict1, dict2, delta=None, msg=None,<EOL>places=None, default_value=<NUM_LIT:0>):

def valid_comparison(value):<EOL><INDENT>"""<STR_LIT>"""<EOL>if places is not None:<EOL><INDENT>return round(value, places) == <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>return value < delta<EOL><DEDENT><DEDENT>if dict1 == dict2:<EOL><INDENT>return<EOL><DEDENT>if places is not None:<EOL><INDENT>if delta is not None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>msg_suffix = '<STR_LIT>' % places<EOL><DEDENT>else:<EOL><INDENT>delta = delta or <NUM_LIT><EOL>msg_suffix = '<STR_LIT>' % delta<EOL><DEDENT>error_msg = '<STR_LIT>'<EOL>for key in set(dict1.keys()) | set(dict2.keys()):<EOL><INDENT>val1 = dict1.get(key, default_value)<EOL>val2 = dict2.get(key, default_value)<EOL>if not valid_comparison(abs(val1 - val2)):<EOL><INDENT>error_msg += '<STR_LIT>' % (safe_repr(key),<EOL>safe_repr(val1),<EOL>safe_repr(val2))<EOL><DEDENT><DEDENT>if error_msg:<EOL><INDENT>msg = self._formatMessage(msg, error_msg[:-<NUM_LIT:2>] + msg_suffix)<EOL>raise self.failureException(msg)<EOL><DEDENT>

Assert two dictionaries with numeric values are almost equal.

        Fail if the two dictionaries are unequal as determined by
        comparing that the difference between values with the same key are
        not greater than delta (default 1e-8), or that difference rounded
        to the given number of decimal places is not zero. If a key in one
        dictionary is not in the other the default_value keyword argument
        will be used for the missing value (default 0). If the two objects
        compare equal then they will automatically compare almost equal.

        Args:
            dict1 (dict): a dictionary.
            dict2 (dict): a dictionary.
            delta (number): threshold for comparison (defaults to 1e-8).
            msg (str): return a custom message on failure.
            places (int): number of decimal places for comparison.
            default_value (number): default value for missing keys.

        Raises:
            TypeError: raises TestCase failureException if the test fails.


my_vcr = VCR(<EOL>cassette_library_dir=cassette_dir,<EOL>record_mode=vcr_mode,<EOL>match_on=['<STR_LIT>', '<STR_LIT>', '<STR_LIT:host>', '<STR_LIT:port>', '<STR_LIT:path>', '<STR_LIT>'],<EOL>filter_headers=['<STR_LIT>', '<STR_LIT>'],<EOL>filter_query_parameters=[('<STR_LIT>', '<STR_LIT>')],<EOL>filter_post_data_parameters=[('<STR_LIT>', '<STR_LIT>')],<EOL>decode_compressed_response=True,<EOL>before_record_response=_purge_headers_cb(['<STR_LIT>',<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>']))<EOL>my_vcr.register_matcher('<STR_LIT>', _unordered_query_matcher)<EOL>my_vcr.register_persister(IdRemoverPersister)<EOL>return my_vcr<EOL>

Creates a VCR object in vcr_mode mode.

    Args:
        vcr_mode (string): the parameter for record_mode.
        cassette_dir (string): path to the cassettes.

    Returns:
        VCR: a VCR object.


header_list = []<EOL>for item in headers:<EOL><INDENT>if not isinstance(item, tuple):<EOL><INDENT>item = (item, None)<EOL><DEDENT>header_list.append(item[<NUM_LIT:0>:<NUM_LIT:2>])  <EOL><DEDENT>def before_record_response_cb(response):<EOL><INDENT>"""<STR_LIT>"""<EOL>for (header, value) in header_list:<EOL><INDENT>with suppress(KeyError):<EOL><INDENT>if value:<EOL><INDENT>response['<STR_LIT>'][header] = value<EOL><DEDENT>else:<EOL><INDENT>del response['<STR_LIT>'][header]<EOL><DEDENT><DEDENT><DEDENT>return response<EOL><DEDENT>return before_record_response_cb<EOL>

Remove headers from the response.

    Args:
        headers (list): headers to remove from the response

    Returns:
        callable: for been used in before_record_response VCR constructor.


if request1.query == request2.query:<EOL><INDENT>return True<EOL><DEDENT>dict1 = dict(request1.query)<EOL>dict2 = dict(request2.query)<EOL>if dict1 == dict2:<EOL><INDENT>return True<EOL><DEDENT>if dict1.keys() != dict2.keys():<EOL><INDENT>return False<EOL><DEDENT>for key, value in dict1.items():<EOL><INDENT>with suppress(ValueError):<EOL><INDENT>dict1[key] = json.loads(value)<EOL>dict2[key] = json.loads(dict2[key])<EOL><DEDENT><DEDENT>return dict1 == dict2<EOL>

A VCR matcher that ignores the order of values in the query string.

    A VCR matcher (a la VCR.matcher) that ignores the order of the values in the query string.
    Useful for filter params, for example.

    Args:
        request1 (Request): a VCR request
        request2 (Request): a VCR request

    Returns:
        bool: True if they match.


return [response for response, request in<EOL>zip(cassette_dict['<STR_LIT>'], cassette_dict['<STR_LIT>'])<EOL>if string_to_find in request.path]<EOL>

Filters the requests from cassette_dict

        Args:
            string_to_find (str): request path
            cassette_dict (dict): a VCR cassette dictionary

        Returns:
            Request: VCR's representation of a request.


@staticmethod<EOL><INDENT>def get_new_id(field, path, id_tracker, type_=str):<DEDENT>

if type_ == float:<EOL><INDENT>return <NUM_LIT><EOL><DEDENT>if type_ == int:<EOL><INDENT>return <NUM_LIT><EOL><DEDENT>dummy_name = '<STR_LIT>' % (path.replace('<STR_LIT:/>', '<STR_LIT>'), field)<EOL>count = len(list(filter(lambda x: str(x).startswith(dummy_name), id_tracker.values())))<EOL>return "<STR_LIT>" % (dummy_name, count + <NUM_LIT:1>)<EOL>

Creates a new dummy id (or value) for replacing an existing id (or value).

        Args:
            field (str): field name is used, in same cases, to create a dummy value.
            path (str): path of the request is used, in same cases, to create a dummy value.
            id_tracker (dict): a map of already assigned ids and generated ids.
            type_ (type): type of the value.

        Returns:
            str: that is used to replace a value.


ret = []<EOL>if not map_list:<EOL><INDENT>return ret<EOL><DEDENT>if isinstance(data_dict, list):<EOL><INDENT>for sub_data_dict in data_dict:<EOL><INDENT>ret.extend(IdRemoverPersister.get_matching_dicts(sub_data_dict, map_list))<EOL><DEDENT><DEDENT>if isinstance(data_dict, dict):<EOL><INDENT>if map_list[<NUM_LIT:0>] in data_dict.keys():<EOL><INDENT>if len(map_list) == <NUM_LIT:1>:<EOL><INDENT>return [data_dict]<EOL><DEDENT>else:<EOL><INDENT>ret.extend(<EOL>IdRemoverPersister.get_matching_dicts(data_dict[map_list[<NUM_LIT:0>]], map_list[<NUM_LIT:1>:]))<EOL><DEDENT><DEDENT><DEDENT>return ret<EOL>

Find subdicts that are described in map_list.

        Args:
            data_dict (dict): in which the map_list is going to be searched.
            map_list (list): the list of nested keys to find in the data_dict

        Returns:
            list: a list of dictionaries, each of them matches map_list.


@staticmethod<EOL><INDENT>def remove_id_in_a_json(jsonobj, field, path, id_tracker):<DEDENT>

map_list = field.split('<STR_LIT:.>')<EOL>for matching_dict in IdRemoverPersister.get_matching_dicts(jsonobj, map_list):<EOL><INDENT>with suppress(KeyError):<EOL><INDENT>old_id = matching_dict[map_list[-<NUM_LIT:1>]]<EOL>if old_id not in id_tracker:<EOL><INDENT>new_id = IdRemoverPersister.get_new_id(field, path, id_tracker, type(old_id))<EOL>id_tracker[old_id] = new_id<EOL><DEDENT>matching_dict[map_list[-<NUM_LIT:1>]] = id_tracker[old_id]<EOL><DEDENT><DEDENT>

Replaces ids with dummy values in a json.

        Replaces in jsonobj (in-place) the field with dummy value (which is constructed with
        id_tracker, if it was already replaced, or path, if it needs to be created).

        Args:
            jsonobj (dict): json dictionary from the response body
            field (str): string with the field in the response to by replaced
            path (str): request path
            id_tracker (dict): a dictionary of the ids already assigned.


@staticmethod<EOL><INDENT>def remove_ids_in_a_response(response, fields, path, id_tracker):<DEDENT>

body = json.loads(response['<STR_LIT:body>']['<STR_LIT:string>'].decode('<STR_LIT:utf-8>'))<EOL>for field in fields:<EOL><INDENT>IdRemoverPersister.remove_id_in_a_json(body, field, path, id_tracker)<EOL><DEDENT>response['<STR_LIT:body>']['<STR_LIT:string>'] = json.dumps(body).encode('<STR_LIT:utf-8>')<EOL>

Replaces ids with dummy values in a response.

        Replaces in response (in-place) the fields with dummy values (which is constructed with
        id_tracker, if it was already replaced, or path, if it needs to be created).

        Args:
            response (dict): dictionary of the response body
            fields (list): list of fields in the response to by replaced
            path (str): request path
            id_tracker (dict): a dictionary of the ids already assigned.


id_tracker = {}  <EOL>for path, fields in ids2remove.items():<EOL><INDENT>responses = IdRemoverPersister.get_responses_with(path, cassette_dict)<EOL>for response in responses:<EOL><INDENT>IdRemoverPersister.remove_ids_in_a_response(response, fields, path, id_tracker)<EOL><DEDENT><DEDENT>for old_id, new_id in id_tracker.items():<EOL><INDENT>if isinstance(old_id, str):<EOL><INDENT>for request in cassette_dict['<STR_LIT>']:<EOL><INDENT>request.uri = request.uri.replace(old_id, new_id)<EOL><DEDENT><DEDENT><DEDENT>

Replaces ids with dummy values in a cassette.

        Replaces in cassette_dict (in-place) the fields defined by ids2remove with dummy values.
        Internally, it used a map (id_tracker) between real values and dummy values to keep
        consistency during the renaming.

        Args:
            ids2remove (dict): {request_path: [json_fields]}
            cassette_dict (dict): a VCR cassette dictionary.


@staticmethod<EOL><INDENT>def save_cassette(cassette_path, cassette_dict, serializer):<DEDENT>

ids2remove = {'<STR_LIT>': ['<STR_LIT:id>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'],<EOL>'<STR_LIT>': ['<STR_LIT:id>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'],<EOL>'<STR_LIT>': ['<STR_LIT>',<EOL>'<STR_LIT>'],<EOL>'<STR_LIT>': ['<STR_LIT>'],<EOL>'<STR_LIT>': ['<STR_LIT>']}<EOL>IdRemoverPersister.remove_ids(ids2remove, cassette_dict)<EOL>super(IdRemoverPersister, IdRemoverPersister).save_cassette(cassette_path,<EOL>cassette_dict,<EOL>serializer)<EOL>

Extends FilesystemPersister.save_cassette

        Extends FilesystemPersister.save_cassette. Replaces particular values (defined by
        ids2remove) which are replaced by a dummy value. The full manipulation is in
        cassette_dict, before saving it using FilesystemPersister.save_cassette

        Args:
            cassette_path (str): the file location where the cassette will be saved.
            cassette_dict (dict): a VCR cassette dictionary. This is the information that will
            be dump in cassette_path, using serializer.
            serializer (callable): the serializer for dumping cassette_dict in cassette_path.


Create fake `Qobj` and backend instances.


def __init__(self, configuration, time_alive=<NUM_LIT:10>):

super().__init__(configuration)<EOL>self.time_alive = time_alive<EOL>

Args:
    configuration (BackendConfiguration): backend configuration
    time_alive (int): time to wait before returning result


properties = {<EOL>'<STR_LIT>': self.name(),<EOL>'<STR_LIT>': self.configuration().backend_version,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': [[{'<STR_LIT:name>': '<STR_LIT>', '<STR_LIT:date>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>', '<STR_LIT:value>': <NUM_LIT:0>}]],<EOL>'<STR_LIT>': [{'<STR_LIT>': [<NUM_LIT:0>], '<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>':<EOL>[{'<STR_LIT:name>': '<STR_LIT>', '<STR_LIT:date>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>', '<STR_LIT:value>': <NUM_LIT:0>}]}],<EOL>'<STR_LIT>': []<EOL>}<EOL>return BackendProperties.from_dict(properties)<EOL>


time.sleep(self.time_alive)<EOL>return Result.from_dict(<EOL>{'<STR_LIT>': job_id, '<STR_LIT:result>': [], '<STR_LIT:status>': '<STR_LIT>'})<EOL>


cmap = [[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:2>, <NUM_LIT:0>], [<NUM_LIT:2>, <NUM_LIT:1>], [<NUM_LIT:3>, <NUM_LIT:2>], [<NUM_LIT:3>, <NUM_LIT:4>], [<NUM_LIT:4>, <NUM_LIT:2>]]<EOL>configuration = BackendConfiguration(<EOL>backend_name='<STR_LIT>',<EOL>backend_version='<STR_LIT>',<EOL>n_qubits=<NUM_LIT:5>,<EOL>basis_gates=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:id>'],<EOL>simulator=False,<EOL>local=True,<EOL>conditional=False,<EOL>open_pulse=False,<EOL>memory=False,<EOL>max_shots=<NUM_LIT>,<EOL>gates=[GateConfig(name='<STR_LIT>', parameters=[], qasm_def='<STR_LIT>')],<EOL>coupling_map=cmap,<EOL>)<EOL>super().__init__(configuration)<EOL>


cmap = [[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:2>, <NUM_LIT:3>], [<NUM_LIT:4>, <NUM_LIT:3>], [<NUM_LIT:4>, <NUM_LIT:10>], [<NUM_LIT:5>, <NUM_LIT:4>],<EOL>[<NUM_LIT:5>, <NUM_LIT:6>], [<NUM_LIT:5>, <NUM_LIT:9>], [<NUM_LIT:6>, <NUM_LIT:8>], [<NUM_LIT:7>, <NUM_LIT:8>], [<NUM_LIT:9>, <NUM_LIT:8>], [<NUM_LIT:9>, <NUM_LIT:10>],<EOL>[<NUM_LIT:11>, <NUM_LIT:3>], [<NUM_LIT:11>, <NUM_LIT:10>], [<NUM_LIT:11>, <NUM_LIT:12>], [<NUM_LIT:12>, <NUM_LIT:2>], [<NUM_LIT>, <NUM_LIT:1>], [<NUM_LIT>, <NUM_LIT:12>]]<EOL>configuration = BackendConfiguration(<EOL>backend_name='<STR_LIT>',<EOL>backend_version='<STR_LIT>',<EOL>n_qubits=<NUM_LIT>,<EOL>basis_gates=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:id>'],<EOL>simulator=False,<EOL>local=True,<EOL>conditional=False,<EOL>open_pulse=False,<EOL>memory=False,<EOL>max_shots=<NUM_LIT>,<EOL>gates=[GateConfig(name='<STR_LIT>', parameters=[], qasm_def='<STR_LIT>')],<EOL>coupling_map=cmap,<EOL>)<EOL>super().__init__(configuration)<EOL>


cmap = [[<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:2>, <NUM_LIT:3>], [<NUM_LIT:3>, <NUM_LIT:4>], [<NUM_LIT:3>, <NUM_LIT>], [<NUM_LIT:5>, <NUM_LIT:4>], [<NUM_LIT:6>, <NUM_LIT:5>],<EOL>[<NUM_LIT:6>, <NUM_LIT:7>], [<NUM_LIT:6>, <NUM_LIT:11>], [<NUM_LIT:7>, <NUM_LIT:10>], [<NUM_LIT:8>, <NUM_LIT:7>], [<NUM_LIT:9>, <NUM_LIT:8>], [<NUM_LIT:9>, <NUM_LIT:10>],<EOL>[<NUM_LIT:11>, <NUM_LIT:10>], [<NUM_LIT:12>, <NUM_LIT:5>], [<NUM_LIT:12>, <NUM_LIT:11>], [<NUM_LIT:12>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT:4>],<EOL>[<NUM_LIT>, <NUM_LIT>], [<NUM_LIT:15>, <NUM_LIT:0>], [<NUM_LIT:15>, <NUM_LIT:2>], [<NUM_LIT:15>, <NUM_LIT>]]<EOL>configuration = BackendConfiguration(<EOL>backend_name='<STR_LIT>',<EOL>backend_version='<STR_LIT>',<EOL>n_qubits=<NUM_LIT:16>,<EOL>basis_gates=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:id>'],<EOL>simulator=False,<EOL>local=True,<EOL>conditional=False,<EOL>open_pulse=False,<EOL>memory=False,<EOL>max_shots=<NUM_LIT>,<EOL>gates=[GateConfig(name='<STR_LIT>', parameters=[], qasm_def='<STR_LIT>')],<EOL>coupling_map=cmap,<EOL>)<EOL>super().__init__(configuration)<EOL>


cmap = [[<NUM_LIT:0>, <NUM_LIT:1>], [<NUM_LIT:0>, <NUM_LIT:5>], [<NUM_LIT:1>, <NUM_LIT:0>], [<NUM_LIT:1>, <NUM_LIT:2>], [<NUM_LIT:1>, <NUM_LIT:6>], [<NUM_LIT:2>, <NUM_LIT:1>],<EOL>[<NUM_LIT:2>, <NUM_LIT:3>], [<NUM_LIT:2>, <NUM_LIT:6>], [<NUM_LIT:3>, <NUM_LIT:2>], [<NUM_LIT:3>, <NUM_LIT:8>], [<NUM_LIT:3>, <NUM_LIT:9>], [<NUM_LIT:4>, <NUM_LIT:8>], [<NUM_LIT:4>, <NUM_LIT:9>],<EOL>[<NUM_LIT:5>, <NUM_LIT:0>], [<NUM_LIT:5>, <NUM_LIT:6>], [<NUM_LIT:5>, <NUM_LIT:10>], [<NUM_LIT:5>, <NUM_LIT:11>], [<NUM_LIT:6>, <NUM_LIT:1>], [<NUM_LIT:6>, <NUM_LIT:2>], [<NUM_LIT:6>, <NUM_LIT:5>],<EOL>[<NUM_LIT:6>, <NUM_LIT:7>], [<NUM_LIT:6>, <NUM_LIT:10>], [<NUM_LIT:6>, <NUM_LIT:11>], [<NUM_LIT:7>, <NUM_LIT:1>], [<NUM_LIT:7>, <NUM_LIT:6>], [<NUM_LIT:7>, <NUM_LIT:8>], [<NUM_LIT:7>, <NUM_LIT:12>],<EOL>[<NUM_LIT:7>, <NUM_LIT>], [<NUM_LIT:8>, <NUM_LIT:3>], [<NUM_LIT:8>, <NUM_LIT:4>], [<NUM_LIT:8>, <NUM_LIT:7>], [<NUM_LIT:8>, <NUM_LIT:9>], [<NUM_LIT:8>, <NUM_LIT:12>], [<NUM_LIT:8>, <NUM_LIT>],<EOL>[<NUM_LIT:9>, <NUM_LIT:3>], [<NUM_LIT:9>, <NUM_LIT:4>], [<NUM_LIT:9>, <NUM_LIT:8>], [<NUM_LIT:10>, <NUM_LIT:5>], [<NUM_LIT:10>, <NUM_LIT:6>], [<NUM_LIT:10>, <NUM_LIT:11>], [<NUM_LIT:10>, <NUM_LIT:15>],<EOL>[<NUM_LIT:11>, <NUM_LIT:5>], [<NUM_LIT:11>, <NUM_LIT:6>], [<NUM_LIT:11>, <NUM_LIT:10>], [<NUM_LIT:11>, <NUM_LIT:12>], [<NUM_LIT:11>, <NUM_LIT:16>], [<NUM_LIT:11>, <NUM_LIT>],<EOL>[<NUM_LIT:12>, <NUM_LIT:7>], [<NUM_LIT:12>, <NUM_LIT:8>], [<NUM_LIT:12>, <NUM_LIT:11>], [<NUM_LIT:12>, <NUM_LIT>], [<NUM_LIT:12>, <NUM_LIT:16>], [<NUM_LIT>, <NUM_LIT:7>],<EOL>[<NUM_LIT>, <NUM_LIT:8>], [<NUM_LIT>, <NUM_LIT:12>], [<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>],<EOL>[<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>], [<NUM_LIT:15>, <NUM_LIT:10>], [<NUM_LIT:15>, <NUM_LIT:16>], [<NUM_LIT:16>, <NUM_LIT:11>], [<NUM_LIT:16>, <NUM_LIT:12>],<EOL>[<NUM_LIT:16>, <NUM_LIT:15>], [<NUM_LIT:16>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT:11>], [<NUM_LIT>, <NUM_LIT:16>], [<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>],<EOL>[<NUM_LIT>, <NUM_LIT>], [<NUM_LIT>, <NUM_LIT>]]<EOL>configuration = BackendConfiguration(<EOL>backend_name='<STR_LIT>',<EOL>backend_version='<STR_LIT>',<EOL>n_qubits=<NUM_LIT:16>,<EOL>basis_gates=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:id>'],<EOL>simulator=False,<EOL>local=True,<EOL>conditional=False,<EOL>open_pulse=False,<EOL>memory=False,<EOL>max_shots=<NUM_LIT>,<EOL>gates=[GateConfig(name='<STR_LIT>', parameters=[], qasm_def='<STR_LIT>')],<EOL>coupling_map=cmap,<EOL>)<EOL>super().__init__(configuration)<EOL>


qr = QuantumRegister(<NUM_LIT:2>, name='<STR_LIT>')<EOL>cr = ClassicalRegister(<NUM_LIT:2>, name='<STR_LIT>')<EOL>qc = QuantumCircuit(qr, cr, name='<STR_LIT>')<EOL>qc.h(qr[<NUM_LIT:0>])<EOL>qc.cx(qr[<NUM_LIT:0>], qr[<NUM_LIT:1>])<EOL>qc.measure(qr, cr)<EOL>return qc<EOL>


qr = QuantumRegister(<NUM_LIT:2>, name='<STR_LIT>')<EOL>qc = QuantumCircuit(qr, name='<STR_LIT>')<EOL>qc.h(qr[<NUM_LIT:0>])<EOL>qc.cx(qr[<NUM_LIT:0>], qr[<NUM_LIT:1>])<EOL>return qc<EOL>


return self.provider_cls()<EOL>


return self.backend_cls()<EOL>


def __exit__(self, exc_type, exc_value, tb):

self.logger.handlers = self.old_handlers<EOL>self.logger.propagate = self.old_propagate<EOL>self.logger.setLevel(self.old_level)<EOL>if exc_type is not None:<EOL><INDENT>return False<EOL><DEDENT>if self.watcher.records:<EOL><INDENT>msg = '<STR_LIT>'.format(<EOL>logging.getLevelName(self.level), self.logger.name)<EOL>for record in self.watcher.records:<EOL><INDENT>msg += '<STR_LIT>' % (record.name, record.pathname,<EOL>record.lineno,<EOL>record.getMessage())<EOL><DEDENT>self._raiseFailure(msg)<EOL><DEDENT>

This is a modified version of TestCase._AssertLogsContext.__exit__(...)


<EOL>if sys.platform == '<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>import qiskit.providers.aer  <EOL><DEDENT>except ImportError:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>

Check if the C++ simulator can be instantiated.

    Returns:
        bool: True if simulator executable is available


@functools.wraps(func)<EOL>def _wrapper(self, *args, **kwargs):<EOL><INDENT>if TEST_OPTIONS['<STR_LIT>']:<EOL><INDENT>raise unittest.SkipTest('<STR_LIT>')<EOL><DEDENT>credentials = _get_credentials(self, TEST_OPTIONS)<EOL>self.using_ibmq_credentials = credentials.is_ibmq()<EOL>kwargs.update({'<STR_LIT>': credentials.token,<EOL>'<STR_LIT>': credentials.url})<EOL>decorated_func = func<EOL>if TEST_OPTIONS['<STR_LIT>'] or TEST_OPTIONS['<STR_LIT>']:<EOL><INDENT>vcr_mode = '<STR_LIT>' if TEST_OPTIONS['<STR_LIT>'] else '<STR_LIT:none>'<EOL>decorated_func = http_recorder(<EOL>vcr_mode, Path.CASSETTES.value).use_cassette()(decorated_func)<EOL><DEDENT>return decorated_func(self, *args, **kwargs)<EOL><DEDENT>return _wrapper<EOL>

Decorator that signals that the test uses the online API:

    It involves:
        * determines if the test should be skipped by checking environment
            variables.
        * if the `USE_ALTERNATE_ENV_CREDENTIALS` environment variable is
          set, it reads the credentials from an alternative set of environment
          variables.
        * if the test is not skipped, it reads `qe_token` and `qe_url` from
            `Qconfig.py`, environment variables or qiskitrc.
        * if the test is not skipped, it appends `qe_token` and `qe_url` as
            arguments to the test function.

    Args:
        func (callable): test function to be decorated.

    Returns:
        callable: the decorated function.


warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>return synthesis.euler_angles_1q(unitary_matrix)<EOL>


warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>", DeprecationWarning)<EOL>return synthesis.two_qubit_kak(unitary_matrix)<EOL>


super().__init__(*msg)<EOL>self.msg = '<STR_LIT:U+0020>'.join(msg)<EOL>


return repr(self.msg)<EOL>