As you are trying to use function decorator in TF 2.0, please enable run function eagerly by using below line after importing TensorFlow:
tf.config.experimental_run_functions_eagerly(True)
Since the above is deprecated(no longer experimental?), please use the following instead:
tf.config.run_functions_eagerly(True)
If you want to know more do refer to this link.