parameters: (_, grad)
return_statement: return result
docstring: Gradients for an exit op are calculated using an Enter op.
docstring_summary: Gradients for an exit op are calculated using an Enter op.
docstring_tokens: Gradients for an exit op are calculated using an Enter op .
function: def _ExitGrad(_, grad):
    """Gradients for an exit op are calculated using an Enter op."""
    graph = ops.get_default_graph()
    # pylint: disable=protected-access
    grad_ctxt = graph._get_control_flow_context()
    # pylint: enable=protected-access
    if not grad_ctxt.back_prop:
      # The flag `back_prop` is set by users to suppress gradient
      # computation for this loop. If the attribute `back_prop` is false,
      # no gradient computation.
      return None
    if isinstance(grad, ops.Tensor):
      grad_ctxt.AddName(grad.name)
    else:
      if not isinstance(grad, (ops.IndexedSlices, ops.SparseTensor)):
        raise TypeError("Type %s not supported" % type(grad))
      grad_ctxt.AddName(grad.values.name)
      grad_ctxt.AddName(grad.indices.name)
      if isinstance(grad, ops.IndexedSlices):
        dense_shape = grad.dense_shape
      else:
        dense_shape = grad.shape
      if dense_shape is not None:
        grad_ctxt.AddName(dense_shape.name)
    enter_fn = control_flow_ops._Enter  # pylint: disable=protected-access
    grad_ctxt.Enter()
    result = enter_fn(grad, grad_ctxt.name, is_constant=False,
                      parallel_iterations=grad_ctxt.parallel_iterations,
                      name="b_exit")
    grad_ctxt.Exit()
    return result
function_tokens: def _ExitGrad ( _ , grad ) : graph = ops . get_default_graph ( ) # pylint: disable=protected-access grad_ctxt = graph . _get_control_flow_context ( ) # pylint: enable=protected-access if not grad_ctxt . back_prop : # The flag `back_prop` is set by users to suppress gradient # computation for this loop. If the attribute `back_prop` is false, # no gradient computation. return None if isinstance ( grad , ops . Tensor ) : grad_ctxt . AddName ( grad . name ) else : if not isinstance ( grad , ( ops . IndexedSlices , ops . SparseTensor ) ) : raise TypeError ( "Type %s not supported" % type ( grad ) ) grad_ctxt . AddName ( grad . values . name ) grad_ctxt . AddName ( grad . indices . name ) if isinstance ( grad , ops . IndexedSlices ) : dense_shape = grad . dense_shape else : dense_shape = grad . shape if dense_shape is not None : grad_ctxt . AddName ( dense_shape . name ) enter_fn = control_flow_ops . _Enter # pylint: disable=protected-access grad_ctxt . Enter ( ) result = enter_fn ( grad , grad_ctxt . name , is_constant = False , parallel_iterations = grad_ctxt . parallel_iterations , name = "b_exit" ) grad_ctxt . Exit ( ) return result