code: def _enclosing_xla_context():
      """Returns the XLAControlFlowContext, which exists inside a tpu.rewrite()."""
      graph = ops.get_default_graph()
      while graph is not None:
          # pylint: disable=protected-access
          context_ = graph._get_control_flow_context()
          # pylint: enable=protected-access
          while context_ is not None:
              if isinstance(
                  context_, control_flow_ops.XLAControlFlowContext
              ):
                  return context_
              context_ = context_.outer_context
          # This may be a FuncGraph due to defuns or v2 control flow. We need to
          # find the original graph with the XLAControlFlowContext.
          graph = getattr(graph, "outer_graph", None)
      return None
  
file_path: tensorflow/tensorflow/python/eager/polymorphic_function/function_context.py
imports: from typing import NamedTuple, Any
  from tensorflow.core.function.polymorphism import function_cache
  from tensorflow.python.eager import context
  from tensorflow.python.framework import device
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.saved_model import save_context
label_desc: Use image node_id 2 for calling a global function with example usage: _enclosing_xla_context() and returns: None, context_