TensorFlow is executing eagerly. Please disable eager execution. code example
Example: tf disable eager execution
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
import tensorflow as tf
tf.compat.v1.disable_eager_execution()