import tensorflow as tf

data = tf.constant(data_raw, name='event_data', dtype=tf.float64)

# // --- Perform extended ML fit of composite PDF to toy data ---
# sum.fitTo(*data,"Extended") ;

# convert to tf constants, otherwise you'll get complaints about float32s...
constraint_tf = {}
for key in constraint.keys():
    low = constraint[key][0]
    high = constraint[key][1]
    constraint_tf[key] = (tf.constant(low, dtype=tf.float64),
                          tf.constant(high, dtype=tf.float64))


print("N.B.: using direct data entry")
likelihood = sum_pdf(data, nsig, sigmean, sigwidth, nbkg, m0, argpar, constraint_tf['mes'][0], constraint_tf['mes'][1])
nll = tf.neg(tf.reduce_sum(tf.log(likelihood)), name="nll")


variables = tf.all_variables()

grads = tf.gradients(nll, variables)
