import tensorflow as tf


    s= len(tensor) #number of tensors in the list

    for i in range(s):

        dl = tensor[i] #take one element of the gradient list (hence the zero)
        d1, d2 = dl.get_shape() #Obtain tensor dimensions

        fl = tf.reshape(dl,[-1, d1*d2]) #reshape the tensor to a (1, d1*d2) tensor

        #concatenate over all the elemets in the list
        if i==0: flattened = fl # the first time
        else: flattened = tf.concat([flattened, fl], axis=1)

    return flattened

#Hessian
def hessian(grads, par):

    '''
    Evaluates the exact Hessian matrix.
    This function uses the same convention of the Autograd package.

    Inputs:
