def func_gp_prior_tf(xdim, l, sigma, seed, name='', dtype=tf.float64):
    filename = 'func_gp_prior_param_seed{}_{}.pkl'.format(seed, name)
    n_feats = 1000
    if os.path.isfile(filename):
        with open(filename, 'rb') as infile:
            data = pickle.load(infile)
            W = tf.constant(data['W'], dtype=dtype)
            b = tf.constant(data['b'], dtype=dtype)
            theta = tf.constant(data['theta'], dtype=dtype)
    else:
        raise Exception('Require to run func_gp_prior to generate the parameters!')

    def f(x):
        x = tf.reshape(x, shape=((- 1), xdim))
        return tf.squeeze(((tf.cast(tf.sqrt(((2.0 * sigma) / n_feats)), dtype=dtype) * tf.linalg.matrix_transpose(theta)) @ tf.cos(((W @ tf.linalg.matrix_transpose(x)) + tf.tile(b, multiples=(1, tf.shape(x)[0]))))))
    return f
def func_gp_prior_tf(xdim, l, sigma, seed, name=, dtype=tf.float64):
    filename = 'func_gp_prior_param_seed{}_{}.pkl'.format(seed, name)
    n_feats = 1000
    if os.path.isfile(filename):
        with open(filename, 'rb') as infile:
            data = pickle.load(infile)
            W = tf.constant(data['W'], dtype=dtype)
            b = tf.constant(data['b'], dtype=dtype)
            theta = tf.constant(data['theta'], dtype=dtype)
    else:
        raise Exception('Require to run func_gp_prior to generate the parameters!')

    def f(x):
        x = tf.reshape(x, shape=((- 1), xdim))
        return tf.squeeze(((tf.cast(tf.sqrt(((2.0 * sigma) / n_feats)), dtype=dtype) * tf.linalg.matrix_transpose(theta)) @ tf.cos(((W @ tf.linalg.matrix_transpose(x)) + tf.tile(b, multiples=(1, tf.shape(x)[0]))))))
    return f