# pylint: disable=import-error, wrong-import-position, pointless-statement
import os
import sys
import numpy as np

from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
from qiskit_machine_learning.kernels import TrainableFidelityQuantumKernel

NUM_QUBITS = 3
fm = QuantumCircuit(NUM_QUBITS)
input_params = ip = ParameterVector("x", NUM_QUBITS)
training_params = tp = ParameterVector("θ", NUM_QUBITS)

for i in range(NUM_QUBITS):
    fm.h(i)
    fm.ry(tp[i], i)

for i in range(NUM_QUBITS):
    fm.crx(ip[i], (i) % NUM_QUBITS, (i + 1) % NUM_QUBITS)

# Define a Quantum Kernel using our trainable feature map
qk = TrainableFidelityQuantumKernel(
    feature_map=fm, training_parameters=training_params[:NUM_QUBITS]
)

print("input_params:", input_params)
print("training_params:", training_params)
qk.feature_map.draw()

# Bind parameters to numeric values
param_binds = {tp[0]: np.pi / 2, tp[1]: np.pi / 3, tp[2]: np.pi / 4}

qk.assign_training_parameters(param_binds)
qk.parameter_values

# Create incomplete training param bindings
param_binds = {tp[0]: np.pi / 6, tp[1]: np.pi / 5}

qk.assign_training_parameters(param_binds)
qk.parameter_values

# Create incomplete user param bindings
param_binds = {tp[0]: tp[0], tp[1]: tp[0] + tp[2], tp[2]: tp[2]}

qk.assign_training_parameters(param_binds)
qk.parameter_values

qk = TrainableFidelityQuantumKernel(feature_map=fm, training_parameters=training_params)
qk.feature_map.draw()

param_values = [np.pi / 7, tp[1], np.pi / 9]
qk.assign_training_parameters(param_values)
qk.parameter_values

param_values = [np.pi / 7, np.pi / 6, np.pi / 9]
qk.assign_training_parameters(param_values)
qk.parameter_values

param_values = [tp[0], tp[1], tp[2]]
qk.assign_training_parameters(param_values)
qk.parameter_values

#import qiskit.tools.jupyter
#
#%qiskit_version_table
#%qiskit_copyright