Enables / disables eager execution of tf.functions.

Used in the notebooks

Used in the guide

Calling tf.config.run_functions_eagerly(True) will make all invocations of tf.function run eagerly instead of running as a traced graph function.

This can be useful for debugging or profiling. For example, let's say you implemented a simple iterative sqrt function, and you want to collect the intermediate values and plot the convergence. Appending the values to a list in @tf.function normally wouldn't work since it will just record the Tensors being traced, not the values. Instead, you can do the following.

ys = []

def sqrt(x):
  y = x / 2
  d = y
  for _ in range(10):
    d /= 2
    if y * y < x: