import tensorflow as tf
tf.enable_eager_execution()
or
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
tf.enable_eager_execution()
import tensorflow as tf
tf.enable_eager_execution()
or
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
tf.enable_eager_execution()