Qiskit/qiskit_humaneval huggingface dataset:
from qiskit import QuantumCircuit
def count_instructions(circuit: QuantumCircuit) -> int:
    """ Return the total number of instructions in the circuit.
    """
    return len(circuit.data)


def check(candidate):
    qc = QuantumCircuit(4)
    qc.x(0)
    assert candidate(qc) == 1

    qc.cx(0, [1, 2])
    assert candidate(qc) == 3

    qc.measure_all()
    assert candidate(qc) == 8
from qiskit import QuantumCircuit
from qiskit.circuit import Gate
def count_gates(circuit: QuantumCircuit) -> int:
    """ Return the total number of unitary gates in the circuit.
    """
    count = 0
    for inst in circuit.data:
        if isinstance(inst.operation, Gate):
            count += 1
    return count


def check(candidate):
    qc = QuantumCircuit(4)
    qc.reset(0)
    qc.tdg(0)
    assert candidate(qc) == 1

    qc.cx(0, [1, 2])
    assert candidate(qc) == 3

    qc.measure_all()
    assert candidate(qc) == 3
from qiskit import QuantumCircuit
def convert_qasm_string_to_quantum_circuit() -> QuantumCircuit:
    """ Generate a QASM 2 string representing a Phi plus Bell state quantum circuit. Then, convert this QASM 2 string into a Quantum Circuit object and return the resulting circuit.
    """
    qasm_string="""OPENQASM 2.0;
    include "qelib1.inc";
    qreg q[2];
    creg c[2];
    h q[0];
    cx q[0],q[1];"""
    qc = QuantumCircuit.from_qasm_str(qasm_string)
    return qc


def check(candidate):
    from qiskit.quantum_info import Statevector
    from math import sqrt
    data = candidate()
    bell_state = (Statevector.from_label("11") + Statevector.from_label("00"))/sqrt(2)
    assert Statevector.from_instruction(data) == bell_state
from qiskit import QuantumCircuit
from qiskit import qpy
def create_binary_serialization():
    """ Create a file containing the binary serialization of a Phi plus Bell state quantum circuit and write it as 'bell.qpy' in binary mode.
    """
    qc = QuantumCircuit(2, name='Bell', metadata={'test': True})
    qc.h(0)
    qc.cx(0, 1)
    with open('bell.qpy', 'wb') as fd:
        qpy.dump(qc, fd)


def check(candidate):
    from qiskit.quantum_info import Statevector
    from math import sqrt
    candidate()
    with open('bell.qpy', 'rb') as fd:
        data = qpy.load(fd)[0]
    bell_state = (Statevector.from_label("11") + Statevector.from_label("00"))/sqrt(2)
    assert Statevector.from_instruction(data) == bell_state
from qiskit import QuantumCircuit
from qiskit.quantum_info import DensityMatrix, concurrence
def calculate_bell_state_properties():
    """ Construct a Phi plus Bell state quantum circuit, compute its Density Matrix and Concurrence, and return these results in a tuple in the same order.
    """
    qc = QuantumCircuit(2, name='Bell')
    qc.h(0)
    qc.cx(0, 1)
    rho = DensityMatrix.from_instruction(qc)
    concur = concurrence(rho)
    return rho, concur


def check(candidate):
    import numpy as np
    DensityMatrix, concurrence = candidate()
    assert round(concurrence,1) == 1
    expected_rho = np.array([[0.5, 0, 0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]])
    np.testing.assert_array_almost_equal(DensityMatrix, expected_rho, decimal=5, err_msg='Density matrix does not match the expected Bell state density matrix')
from qiskit import pulse
from qiskit_ibm_runtime.fake_provider import FakeBelemV2
from qiskit.pulse import DriveChannel, Gaussian
def define_gaussian_pulse_schedule():
    """ Using Qiskit Pulse, create a Gaussian pulse schedule on drive channel 0 with a duration of 128 and name this schedule 'gaussian_pulse_schedule'. Configure it for the FakeBelem backend and return the resulting pulse schedule.
    """
    backend = FakeBelemV2()
    gaussian_pulse = Gaussian(duration=128, amp=0.1, sigma=16)
    d0 = DriveChannel(0)
    with pulse.build(backend=backend, name='gaussian_pulse_schedule') as gaussian_pulse_schedule:
        pulse.play(gaussian_pulse, d0)
    return gaussian_pulse_schedule


def check(candidate):
    gaussian_pulse_schedule = candidate()
    assert gaussian_pulse_schedule.name == 'gaussian_pulse_schedule'
    assert gaussian_pulse_schedule.duration == 128
from qiskit import QuantumCircuit
import qiskit.qasm2
def convert_quantum_circuit_to_qasm_string(circuit: QuantumCircuit) -> str:
    """ Given a QuantumCircuit, convert it into qasm2 string and return it.
    """
    qasm_str = qiskit.qasm2.dumps(circuit)
    return qasm_str


def check(candidate):
    from qiskit.quantum_info import Statevector
    qc = QuantumCircuit(2, 2)
    qc.h(0)
    qc.cx(0,1)
    qasm_str = candidate(qc)
    circuit = QuantumCircuit.from_qasm_str(qasm_str)
    assert Statevector.from_instruction(circuit) == Statevector.from_instruction(qc)
from qiskit import pulse
from qiskit_ibm_runtime.fake_provider import FakeBelemV2
from qiskit.pulse import DriveChannel, Constant, Play, Delay
def pulse_schedule_with_constant_and_delay():
    """ Using Qiskit Pulse, create a schedule with a constant pulse on drive channel 0, featuring a duration of 160 and an amplitude of 0.1 and name this schedule "pulse_schedule_with_constant_and_delay". Use the FakeBelem backend for configuration. After creating the pulse, add a delay of 400 to the schedule, then replay the same pulse. Return the completed pulse schedule.
    """
    backend = FakeBelemV2()
    constant_pulse = Constant(duration=160, amp=0.1)
    drive_chan = DriveChannel(0)
    with pulse.build(backend=backend, name="pulse_schedule_with_constant_and_delay") as pulse_sched:
        pulse.play(constant_pulse, drive_chan)
        pulse.delay(400, drive_chan)
        pulse.play(constant_pulse, drive_chan)
    return pulse_sched


def check(candidate):
    pulse_sched = candidate()
    constant_pulses = 0
    delays = 0
    for _, inst in pulse_sched.instructions:
        if isinstance(inst, Play):
            if isinstance(inst.pulse, Constant):
                constant_pulses += 1
        elif isinstance(inst, Delay):
            delays += 1
    assert constant_pulses == 2, "Schedule should contain exactly two Constant pulses."
    assert delays == 1, "Schedule should contain exactly one Delay instruction."
    assert pulse_sched.name == "pulse_schedule_with_constant_and_delay"
from qiskit import QuantumCircuit
def quantum_circuit_with_delay():
    """ Create a one-qubit quantum circuit, apply hadamard gate, then add a delay of 100 and then again apply hadamard gate and return the circuit.
    """
    qc = QuantumCircuit(1)
    qc.h(0)
    delay_duration = 100
    qc.delay(delay_duration, 0, unit="dt")
    qc.h(0)
    return qc


def check(candidate):
    from qiskit import QuantumRegister
    from qiskit.circuit import CircuitInstruction
    from qiskit.circuit.library import HGate
    from qiskit.circuit import Delay
    qr = QuantumRegister(1, name="q")
    data = candidate().data
    assert data[0]==CircuitInstruction(HGate(), [qr[0]], [])
    assert data[1]==CircuitInstruction(Delay(100), [qr[0]], [])
    assert data[2]==CircuitInstruction(HGate(), [qr[0]], [])
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit.circuit import IfElseOp
def create_conditional_circuit():
    """ Create a one-qubit quantum circuit, apply a Hadamard gate, and then measure it. Based on the classical output, use an IfElseOp operation: if the output is 1, append a one-qubit quantum circuit with a Z gate; if the output is 0, append a one-qubit quantum circuit with an X gate. Finally, add a measurement to the appended circuit and return the complete quantum circuit.
    """
    qr = QuantumRegister(1, 'q')
    cr = ClassicalRegister(1, 'c')
    circuit = QuantumCircuit(qr, cr)
    circuit.h(qr[0])
    circuit.measure(qr[0], cr[0])
    true_body = QuantumCircuit(qr, cr)
    true_body.z(qr[0])
    false_body = QuantumCircuit(qr, cr)
    false_body.x(qr[0])
    if_else_gate = IfElseOp((cr, 1), true_body, false_body)
    circuit.append(if_else_gate, [qr[0]], [cr[0]])
    circuit.measure(qr[0], cr[0])
    return circuit


def check(candidate):
    from qiskit import QuantumRegister
    from qiskit.circuit import CircuitInstruction
    from qiskit.circuit.library import HGate
    from qiskit_aer import AerSimulator
    from qiskit_ibm_runtime import Sampler
    qr = QuantumRegister(1, name="q")
    circuit = candidate()
    data = circuit.data
    assert data[0]==CircuitInstruction(HGate(), [qr[0]], [])
    assert data[2].operation.name == "if_else"
    backend = AerSimulator()
    sampler = Sampler(mode=backend)
    results = sampler.run([circuit],shots=1024).result()
    counts= results[0].data.c.get_counts()
    assert counts == {'1': 1024}
    assert sum(counts.values()) == 1024
from qiskit.circuit.library import HGate
from qiskit import QuantumCircuit, QuantumRegister
def create_controlled_hgate()->QuantumCircuit:
    """ Construct a quantum circuit with a three-qubit controlled-Hadamard gate, using qubit 0 and qubit 1 as the control bits and qubit 2 as the target bit. Return the circuit.
    """
    qr = QuantumRegister(3)
    qc = QuantumCircuit(qr)
    c3h_gate = HGate().control(2)
    qc.append(c3h_gate, qr)
    return qc


def check(candidate):
    from qiskit.quantum_info import Operator
    solution_register = QuantumRegister(3)
    solution_circuit = QuantumCircuit(solution_register)
    c3h_gate = HGate().control(2)
    solution_circuit.append(c3h_gate, solution_register)
    qc = candidate()
    assert Operator(qc).equiv(solution_circuit)
from qiskit import QuantumCircuit
def create_custom_controlled()-> QuantumCircuit:
    """ Create a custom 2-qubit gate with an X gate on qubit 0 and an H gate on qubit 1. Then, add two control qubits to this gate. Apply this controlled gate to a 4-qubit circuit, using qubits 0 and 3 as controls and qubits 1 and 2 as targets. Return the final circuit.
    """
    qc1 = QuantumCircuit(2)
    qc1.x(0)
    qc1.h(1)
    custom = qc1.to_gate().control(2)
    qc2 = QuantumCircuit(4)
    qc2.append(custom, [0, 3, 1, 2])
    return qc2


def check(candidate):
    from qiskit.quantum_info import Operator
    qc1 = QuantumCircuit(2)
    qc1.x(0)
    qc1.h(1)
    custom = qc1.to_gate().control(2)
    qc2 = QuantumCircuit(4)
    qc2.append(custom, [0, 3, 1, 2])
    candidate_circuit = candidate()
    assert Operator(qc2).equiv(candidate_circuit)
from qiskit import QuantumCircuit
from qiskit.converters import circuit_to_instruction
def convert_circuit_to_instruction():
    """ Create a circuit that produces a phi plus bell state with name bell_instruction and convert it into a quantum instruction.
    """
    circ = QuantumCircuit(2, 2, name="bell_instruction")
    circ.h(0)
    circ.cx(0,1)
    circ.measure([0, 1], [0, 1])
    instruction = circuit_to_instruction(circ)
    return instruction


def check(candidate):
    instruction = candidate()
    assert instruction.name == "bell_instruction"
    assert instruction.num_qubits == 2
    circ = QuantumCircuit(2, 2)
    circ.h(0)
    circ.cx(0,1)
    circ.measure([0, 1], [0, 1])
    assert instruction.definition == circ
from qiskit import QuantumCircuit
from qiskit.quantum_info import StabilizerState
def calculate_stabilizer_state_info():
    """ Construct a Phi plus Bell state quantum circuit, compute its stabilizer state, and return both the stabilizer state and a dictionary of the stabilizer state measurement probabilities.
    """
    qc = QuantumCircuit(2)
    qc.h(0)
    qc.cx(0, 1)
    stab = StabilizerState(qc)
    probabilities_dict = stab.probabilities_dict()
    return stab, probabilities_dict


def check(candidate):
    stab, probabilities_dict = candidate()
    assert isinstance(stab, StabilizerState)
    assert isinstance(probabilities_dict, dict)
    assert probabilities_dict == {"00": 0.5, "11": 0.5}
    qc = QuantumCircuit(2)
    qc.h(0)
    qc.cx(0, 1)
    new_stab = StabilizerState(qc)
    assert stab.equiv(new_stab)
from qiskit.synthesis import synth_clifford_full
from qiskit.quantum_info.random import random_clifford
def synthesize_clifford_circuit(n_qubits:int):
    """ Create a random clifford circuit using the random_clifford function for a given n qubits with seed 1234 and synthesize it using synth_clifford_full method and return.
    """
    qc = random_clifford(n_qubits, seed=1234)
    synthesized_qc = synth_clifford_full(qc)
    return synthesized_qc


def check(candidate):
    from qiskit.quantum_info import Operator
    n_qubits = 6
    synthesized_qc = candidate(n_qubits)
    qc = random_clifford(n_qubits)
    synthesized_qc = synth_clifford_full(qc)
    assert Operator(synthesized_qc) == Operator(qc)
from qiskit import QuantumCircuit
import qiskit.qasm3
def convert_quantum_circuit_to_qasm_string(circuit: QuantumCircuit) -> str:
    """ Given a Quantum Circuit as the argument, convert it into qasm3 string and return it.
    """
    qasm_str = qiskit.qasm3.dumps(circuit)
    return qasm_str


def check(candidate):
    from qiskit.quantum_info import Operator
    qc = QuantumCircuit(2, 2)
    qc.h(0)
    qc.cx(0,1)
    qasm_str = candidate(qc)
    circuit = qiskit.qasm3.loads(qasm_str)
    assert Operator(circuit).equiv(Operator(qc)), "Loaded QASM does not match circuit"
from qiskit import QuantumCircuit
from qiskit.transpiler.passes import RemoveBarriers
def remove_barrier(circuit: QuantumCircuit):
    """ For a given Quantum Circuit remove all the barriers from it and return.
    """
    return  RemoveBarriers()(circuit)


def check(candidate):
    from qiskit.quantum_info import Operator
    circuit = QuantumCircuit(1)
    circuit.h(0)
    circuit.barrier()
    circuit.x(0)
    candidate_circuit = candidate(circuit)
    for inst in candidate_circuit.data:
        assert inst.operation.name != 'barrier'
    assert Operator(circuit).equiv(candidate_circuit)
from qiskit_ibm_runtime.fake_provider import FakeKyoto
from qiskit.circuit import QuantumCircuit
from qiskit_ibm_runtime import Sampler
from qiskit_ibm_runtime.options import SamplerOptions
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
def bell_state_noisy() -> dict:
    """ Create the phi+ Bell state, run it in the FakeKyoto backend and return the counts. Use seed 42 for the sampler.
    """
    backend = FakeKyoto()
    qc = QuantumCircuit(2)
    qc.h(0)
    qc.cx(0, 1)
    qc.measure_all()
    pass_manager = generate_preset_pass_manager(optimization_level=1, backend=backend)
    isa_circuit = pass_manager.run(qc)
    options = SamplerOptions()
    options.simulator.seed_simulator=42
    sampler = Sampler(backend, options=options)
    result = sampler.run([isa_circuit]).result()
    counts = result[0].data.meas.get_counts()
    return counts


def check(candidate):
    from qiskit.quantum_info import hellinger_fidelity
    counts_can = candidate()
    backend = FakeKyoto()
    qc = QuantumCircuit(2)
    qc.h(0)
    qc.cx(0, 1)
    qc.measure_all()
    pass_manager = generate_preset_pass_manager(optimization_level=1, backend=backend)
    isa_circuit = pass_manager.run(qc)
    sampler = Sampler(backend)
    result = sampler.run([isa_circuit]).result()
    counts_exp = result[0].data.meas.get_counts()
    assert isinstance(counts_can, dict), "Return the counts"
    assert 0.7 < hellinger_fidelity(counts_can, counts_exp) < 1, "Output doesn't match with the results from Fake Kyoto"
from qiskit_ibm_runtime.fake_provider.fake_backend import FakeBackendV2
from qiskit_ibm_runtime import IBMBackend
from typing import Union
def two_qubit_conections(
    backend: Union[FakeBackendV2, IBMBackend]
) -> list:
    """ Return the two qubit connections for any input backend of type FakeBackendV2, IBMBackend.
    """
    if isinstance(backend, FakeBackendV2):
        return backend.coupling_map
    return backend.configuration().coupling_map


def check(candidate):
    from qiskit_ibm_runtime.fake_provider import FakeKyoto
    from qiskit_ibm_runtime import QiskitRuntimeService
    backend_v2 = FakeKyoto()
    backend_ser = QiskitRuntimeService().least_busy()
    connections_can_v2 = candidate(backend_v2)
    connections_exp_v2 = backend_v2.coupling_map
    assert connections_exp_v2 == connections_can_v2, "The list of connections doesn't match the two qubit connections from the backend"
    connections_can_ser = candidate(backend_ser)
    connections_exp_ser = backend_ser.configuration().coupling_map
    assert connections_exp_ser == connections_can_ser, "The list of connections doesn't match the two qubit connections from the backend"
import numpy as np
from typing import Union
from qiskit_ibm_runtime.fake_provider.fake_backend import FakeBackendV2
from qiskit_ibm_runtime import IBMBackend
def qubit_with_least_readout_error(backend: Union[IBMBackend, FakeBackendV2])-> float:
    """ Return the minimum readout error of any input backend of type FakeBackendV2, IBMBackend.
    """
    error_list = []
    if issubclass(type(backend), FakeBackendV2):    
        for qubits in range(backend.num_qubits):
            error_list.append(backend.target["measure"][(qubits,)].error)
    else:
        for qubits in range(backend.configuration().num_qubits):
            error_list.append(backend.properties().readout_error(qubits))
    return np.min(error_list)


def check(candidate):
    from qiskit_ibm_runtime.fake_provider import FakeKyoto
    from qiskit_ibm_runtime import QiskitRuntimeService
    backend_v2 = FakeKyoto()
    error_can_v2 = candidate(backend_v2)
    error_list_v2 = []
    for qubits in range(backend_v2.num_qubits):
        error_list_v2.append(backend_v2.target["measure"][(qubits,)].error)
    error_exp_v2 = np.min(error_list_v2)
    assert error_can_v2 == error_exp_v2, "The qubit returned doesn't have the least readout error"
    backend_ser = QiskitRuntimeService().least_busy()
    error_can_ser = candidate(backend_ser)
    error_list_ser = []
    for qubits in range(backend_ser.configuration().num_qubits):
        error_list_ser.append(backend_ser.properties().readout_error(qubits))
    error_exp_ser = np.min(error_list_ser)
    assert error_can_ser == error_exp_ser, "The qubit returned doesn't have the least readout error"
from qiskit.circuit import Parameter, QuantumCircuit

def remove_unassigned_parameterized_gates(circuit: QuantumCircuit) -> QuantumCircuit:
    """ Remove all the gates with unassigned parameters from the given circuit.
    """
    circuit_data = circuit.data.copy()
    circuit_without_params = QuantumCircuit(circuit.num_qubits, circuit.num_clbits)
    
    #for instr, qargs, cargs in circuit_data:
    for instruction in circuit_data:
        instr, qargs, cargs = instruction.operation, instruction.qubits, instruction.clbits
        if not (isinstance(instr.params, Parameter) or 
                isinstance(instr.params[0], Parameter)):
            circuit_without_params.append(instr, qargs, cargs)

    return circuit_without_params


def check(candidate):
    from qiskit.circuit.library import RXGate, RZGate
    circ = QuantumCircuit(2)
    theta = Parameter("θ")
    circ.rx(0.1, 1)
    circ.ry(theta, 1)
    circ.rx(theta, 0)
    circ.cp(theta, 0, 1)
    circ.rz(0.4, 0)
    circ_can = candidate(circ)
    assert isinstance(circ_can, QuantumCircuit), "Not a quantum circuit"
    assert len(circ_can.parameters) == 0, "Circuit consists of gates with unassigned parameters."
    has_rx = False
    has_rz = False
    for instruction in circ_can:
        instr, qargs, cargs = instruction.operation, instruction.qubits, instruction.clbits
        if isinstance(instr, RXGate):
            has_rx = True
        if isinstance(instr, RZGate):
            has_rz = True
    assert has_rx is True, "Removed rx gates with assigned parameters from the circuit"
    assert has_rz is True, "Removed rz gates with assigned parameters from the circuit"
from qiskit.transpiler.passes import SolovayKitaev
from qiskit.transpiler import PassManager
from qiskit.circuit import QuantumCircuit
def sol_kit_decomp(circuit: QuantumCircuit) -> QuantumCircuit:
    """ Create a pass manager to decompose the single qubit gates into gates of the dense subset ['t', 'tdg', 'h'] in the given circuit.
    """
    pm = PassManager([SolovayKitaev()])
    circ_dec = pm.run(circuit)
    return circ_dec


def check(candidate):
    import numpy as np
    from qiskit.circuit.library import EfficientSU2
    from qiskit.quantum_info import Operator
    circ = EfficientSU2(3).decompose()
    circ = circ.assign_parameters(np.random.random(circ.num_parameters))
    circ_can = candidate(circ)
    op_or = Operator(circ)
    op_can = Operator(circ_can)
    assert Operator.equiv(op_or, op_can, rtol=0.1, atol=0.1), "Operators are not the same"
    assert isinstance(circ_can, QuantumCircuit), "Not a quantum circuit"
    for instruction in circ_can.data:
        instr, qargs, cargs = instruction.operation, instruction.qubits, instruction.clbits
        if instr.num_qubits == 1 and instr.name not in {"h", "tdg", "t"}:
            raise AssertionError("Circuit contains gates outside the given dense subset")
from qiskit_ibm_runtime.fake_provider import FakeKyoto
from qiskit.circuit.library import GraphState
import networkx as nx
from qiskit.circuit import QuantumCircuit
def get_graph_state() -> QuantumCircuit:
    """ Return the circuit for the graph state of the coupling map of the Fake Kyoto backend. Hint: Use the networkx library to convert the coupling map to a dense adjacency matrix.
    """
    backend = FakeKyoto()
    coupling_map = backend.coupling_map
    G = nx.Graph()
    G.add_edges_from(coupling_map)
    adj_matrix = nx.adjacency_matrix(G).todense()
    gr_state_circ = GraphState(adjacency_matrix=adj_matrix)
    return gr_state_circ


def check(candidate):
    from collections import OrderedDict
    from qiskit.transpiler.passes import UnitarySynthesis
    from qiskit.transpiler import PassManager
    gr_state_circ_can = candidate()
    assert isinstance(gr_state_circ_can, QuantumCircuit)
    gr_state_circ_exp_ops = OrderedDict([("cz", 144), ("h", 127)])
    basis_gates = ["cz", "h"]
    pm = PassManager([UnitarySynthesis(basis_gates)])
    gr_state_circ_can_ops = pm.run(gr_state_circ_can.decompose()).count_ops()
    assert gr_state_circ_can_ops == gr_state_circ_exp_ops
from qiskit.circuit import QuantumCircuit
from qiskit_ibm_runtime.fake_provider import FakeKyoto, FakeKyiv, FakeAuckland
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
def backend_with_least_instructions() -> str:
    """ Transpile the circuit for the phi plus bell state for FakeKyoto, FakeKyiv and FakeAuckland using the level 1 preset pass manager and return the backend name with the lowest number of instructions.
    """
    qc = QuantumCircuit(2)
    qc.h(0)
    qc.cx(0, 1)
    backends = [FakeKyiv(), FakeKyoto(), FakeAuckland()]
    qc_isa_num_intruc = {}
    for backend in backends:
        pm = generate_preset_pass_manager(optimization_level=0, backend=backend)
        qc_isa_num_intruc[backend.name] = len(pm.run(qc).data)
    return min(qc_isa_num_intruc, key=qc_isa_num_intruc.get)


def check(candidate):
    backend_can = candidate()
    assert backend_can in "fake_auckland" or "auckland" in backend_can
import importlib
import inspect
from qiskit_ibm_runtime.fake_provider import fake_backend
def fake_providers_v2_with_ecr() -> list:
    """ Return the list of names of all the fake providers of type FakeBackendV2 which contains ecr gates in its available operations.
    """
    fake_provider_module = importlib.import_module("qiskit_ibm_runtime.fake_provider")
    fake_providers = {}
    for name, obj in inspect.getmembers(fake_provider_module):
        if inspect.isclass(obj) and issubclass(obj, fake_backend.FakeBackendV2):
            fake_providers[name] = obj
    fake_providers_ecr = []
    for name, provider in fake_providers.items():
        backend = provider()
        if "ecr" in backend.operation_names:
            fake_providers_ecr.append(name)
    return fake_providers_ecr


def check(candidate):
    providers_can = candidate()
    providers_exp = [
        "FakeCusco",
        "FakeKawasaki",
        "FakeKyiv",
        "FakeKyoto",
        "FakeOsaka",
        "FakePeekskill",
        "FakeQuebec",
        "FakeSherbrooke",
        "FakeBrisbane",
        "FakeCairoV2",
    ]
    for providers in providers_can:
        assert providers in providers_exp
    for providers in providers_exp:
        assert providers in providers_can