import numpy as np
import pandas as pd
import itertools
import cma
import os
import sys
import argparse
import pickle
import random
import re
from pprint import pprint

import qiskit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute
from qiskit import Aer
from qiskit import IBMQ
from qiskit.compiler import transpile
from qiskit.providers.aer.noise.noise_model import NoiseModel
from qiskit.test.mock import *
from qiskit.providers.aer import AerSimulator, QasmSimulator
from qiskit.ignis.mitigation.measurement import complete_meas_cal, CompleteMeasFitter
import mitiq

IBMQ.load_account()
# provider = IBMQ.get_provider(hub='ibm-q-utokyo', group='internal', project='hirashi-jst')
provider = IBMQ.get_provider(hub='ibm-q-community', group='ibmquantumawards', project='open-science-22')
print("provider:", provider)

real_device = provider.get_backend('ibmq_jakarta')

def qrem_encoder(num_qubits: int, initial_layout: list) -> list:
    qr = QuantumRegister(num_qubits)
    meas_calibs, state_labels = complete_meas_cal(qr=qr, circlabel='mcal')
    return transpile(meas_calibs, initial_layout=initial_layout, basis_gates=["sx", "rz", "cx"])

def execute_circuits(qcs: list, backend) -> (qiskit.providers.Job, str):
    job = exec
    meas_fitter = CompleteMeasFitter(cal_results, state_labels, circlabel='mcal')

def qrem_decoder():









