class_docstr: A `ControlFlowContext` for nodes inside an XLA computation cluster.
  
  THIS IS ONLY FOR TENSORFLOW INTERNAL IMPLEMENTATION, DO NO USE DIRECTLY.
  
  The primary role of `XLACompileContext` is to mark operators inside a
  xla.compile() computation with attribute "_xla_compile_id=XYZ", where XYZ is
  a unique name.
  
  `ControlFlowContext` is used to perform the annotation since it integrates
  with Tensorflow constructs like ResourceVariables. For example, if a
  `ResourceVariable` is constructed inside a xla.compile() block, the
  `ResourceVariable` implementation can use
  `with ops.control_dependencies(None)` to build the variable's definition
  outside the compiled computation.
docstr: Create op in XLACompileContext and notifies outer context recursively.
docstr_tok: ["Create","op","in","XLACompileContext","and","notifies","outer","context","recursively","."]
code: def AddOp(self, op: ops.Operation):
      """Create op in XLACompileContext and notifies outer context recursively."""
      # pylint: disable=protected-access
      if op.type in _DENYLISTED_OPS:
          logging.error(
              "Operation of type %s (%s) is not supported in XLA. Execution will "
              "fail if this op is used in the graph. ",
              op.type,
              op.name,
          )
  
      # TODO(ycao): Automatically disable summaries instead of reporting them.
      if op.type in _UNSUPPORTED_OPS:
          self._unsupported_ops.append(op)
  
      if any(x.dtype._is_ref_dtype for x in op.inputs):
          raise NotImplementedError(
              "Non-resource Variables are not supported inside XLA computations "
              "(operator name: %s)" % op.name
          )
  
      if _XLA_COMPILE_ATTR in op.node_def.attr:
          raise ValueError(
              "XLA compiled computations cannot be nested, (operator "
              "name: %s)" % op.name
          )
  
      op._set_attr(
          _XLA_COMPILE_ATTR,
          attr_value_pb2.AttrValue(s=self._name_as_bytes),
      )
  
      op.graph.prevent_feeding(op)
      op.graph.prevent_fetching(op)
  
      # Remove any control edges from outer control flow contexts. These may cause
      # mismatched frame errors. An example is when one of op's inputs is
      # generated in a different While control flow context.
      (
          internal_control_inputs,
          external_control_inputs,
      ) = self._RemoveExternalControlEdges(op)
  
      if not op.inputs:
          # Add a control edge from the control pivot to this op.
          if not internal_control_inputs:
              # pylint: disable=protected-access
              op._add_control_input(self._pivot)
              # pylint: enable=protected-access
      else:
          for index in range(len(op.inputs)):
              x = op.inputs[index]
              real_x = self.AddValue(x)
              if real_x is not x:
                  op._update_input(
                      index, real_x
                  )  # pylint: disable=protected-access
  
      if external_control_inputs:
          # Use an identity to pull control inputs as data inputs. Note that we
          # ignore ops which don't have outputs. TODO(phawkins): fix that.
          with ops.control_dependencies(None):
              self.Enter()
              external_control_inputs = [
                  array_ops.identity(x.outputs[0]).op
                  for x in external_control_inputs
                  if x.outputs
              ]
              self.Exit()
          # pylint: disable=protected-access
          op._add_control_inputs(external_control_inputs)
          # pylint: enable=protected-access
  
      # Mark op's outputs as seen by this context and any outer contexts.
      output_names = [x.name for x in op.outputs]
      context = self
      while context is not None:
          # pylint: disable=protected-access
          context._values.update(output_names)
          context = context._outer_context
          # pylint: enable=protected-access
  
      if self._outer_context:
          self._outer_context.AddInnerOp(op)
  
imports: import contextlib
  from tensorflow.compiler.jit.ops import xla_ops
  from tensorflow.compiler.jit.ops import xla_ops_grad
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.python.distribute import summary_op_util
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import compat
  from tensorflow.python.util import nest
  from tensorflow.python.util import tf_inspect
  from tensorflow.python.util.compat import collections_abc
  from tensorflow.python.util.deprecation import deprecated
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 4 for calling the XLACompileContext obj's underlying member method code with example usage: obj.AddOp(op) without return types