code: def set_output_all_intermediates(
      state,
  ):  # pylint: disable=invalid-name
      """Whether to output all intermediates from functional control flow ops.
  
      The "default" behavior to is to output all intermediates when using v2 control
      flow inside Keras models in graph mode (possibly inside Estimators). This is
      needed to support taking gradients of v2 control flow. In graph mode, Keras
      can sometimes freeze the forward graph before the gradient computation which
      does not work for v2 control flow since it requires updating the forward ops
      to output the needed intermediates. We work around this by proactively
      outputting the needed intermediates when building the forward pass itself.
      Ideally any such extra tensors should be pruned out at runtime. However, if
      for any reason this doesn't work for you or if you have an inference-only
      model you can turn this behavior off using
      `tf.compat.v1.experimental.output_all_intermediates(False)`.
  
      If with the default behavior you are still seeing errors of the form
      "Connecting to invalid output X of source node Y which has Z outputs" try
      setting `tf.compat.v1.experimental.output_all_intermediates(True)` and
      please file an issue at https://github.com/tensorflow/tensorflow/issues.
  
      Args:
        state: True, False or None. None restores the default behavior.
      """
      global _EXPERIMENTAL_OUTPUT_ALL_INTERMEDIATES_OVERRIDE
      _EXPERIMENTAL_OUTPUT_ALL_INTERMEDIATES_OVERRIDE = state
  
imports: from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.eager import context
  from tensorflow.python.eager.polymorphic_function import atomic_function
  from tensorflow.python.eager.polymorphic_function import concrete_function
  from tensorflow.python.eager.polymorphic_function import tracing_compilation
  from tensorflow.python.eager.polymorphic_function import transform
  from tensorflow.python.framework import function_def_to_graph
  from tensorflow.python.framework import ops
  from tensorflow.python.framework.func_graph import FuncGraph
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import control_flow_v2_func_graphs
  from tensorflow.python.ops import gradients_util
  from tensorflow.python.util import keras_deps
  from tensorflow.python.util import tf_contextlib
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 17 for calling a global function with example usage: set_output_all_intermediates(state) without return types