def use_tf_compat_v1(force_tf_compat_v1: bool) -> bool:
  """Evaluate from environment variables if TF should be used in compat.v1 mode."""
  # If tf.enable_v2_behavior has been called, but eager execution has been
  # disabled, force compat v1 behavior. Hence, check
  # `executing_eagerly_outside_functions` as well.
  return (force_tf_compat_v1 or not tf2.enabled() or
          not tf.compat.v1.executing_eagerly_outside_functions())
Evaluate from environment variables if TF should be used in compat.v1 mode.
tensorflow_transform/tf2_utils.py