parameters: ()
docstring: Check if it is currently under `_TPUInferenceContext`.
docstring_summary: Check if it is currently under `_TPUInferenceContext`.
docstring_tokens: Check if it is currently under _TPUInferenceContext .
function: def under_tpu_inference_context():
    """Check if it is currently under `_TPUInferenceContext`."""
    graph = ops.get_default_graph()
    while graph:
      context = graph._get_control_flow_context()  # pylint: disable=protected-access
      while context:
        if isinstance(context, _TPUInferenceContext):
          return True
        context = context.outer_context
      if isinstance(graph, function._FuncGraph):  # pylint: disable=protected-access
        graph = graph._outer_graph  # pylint: disable=protected-access
      elif isinstance(graph, func_graph.FuncGraph):
        graph = graph.outer_graph
      else:
        return False
function_tokens: def under_tpu_inference_context ( ) : graph = ops . get_default_graph ( ) while graph : context = graph . _get_control_flow_context ( ) # pylint: disable=protected-access while context : if isinstance ( context , _TPUInferenceContext ) : return True context = context . outer_context if isinstance ( graph , function . _FuncGraph ) : # pylint: disable=protected-access graph = graph . _outer_graph # pylint: disable=protected-access elif isinstance ( graph , func_graph . FuncGraph ) : graph = graph . outer_graph else : return False