The Gaussian process regression example  (Gaussian Process Regression in TensorFlow Probability) is  giving following error
ValueError: No gradients provided for any variable: ['amplitude:0', 'length_scale:0', 'observation_noise_variance_var:0'].
This error goes away when I comment out the tf.function decorator.
I am using tensorflow 2.5.0.
What is the cause of the error?