from qiskit_ibm_runtime.executor_sampler import Sampler
from qiskit_ibm_runtime.fake_provider import FakeFez

from common import IDEAL, SHOTS, ghz, noisy_sampler, transpile_for

backend = FakeFez()
isa = transpile_for(backend, ghz(4), level=1)

# Le Sampler d'IBM, en mode local : avec un fake backend, il simule son bruit sur votre poste
sampler = Sampler(mode=backend, options={"simulator": {"seed_simulator": 42}})
counts = sampler.run([isa], shots=SHOTS).result()[0].data.meas.get_counts()
print("Sampler d'IBM, mode local :", {key: counts[key] for key in sorted(IDEAL)})

reference = noisy_sampler(backend).run([isa], shots=SHOTS).result()[0].data.meas.get_counts()
print("Mêmes counts que la simulation Aer :", counts == reference)
