parameters: (
      parent, node, full_name, name, logs)
return_statement: return node
docstring: Wrap labels argument with stop_gradients.
docstring_summary: Wrap labels argument with stop_gradients.
docstring_tokens: Wrap labels argument with stop_gradients .
function: def _softmax_cross_entropy_with_logits_transformer(
      parent, node, full_name, name, logs):
    """Wrap labels argument with stop_gradients."""
    def _wrap_label(parent, old_value):
      """Wrap labels with tf.stop_gradient."""
      already_stop_grad = (isinstance(old_value, ast.Call) and
                           isinstance(old_value.func, ast.Attribute) and
                           old_value.func.attr == "stop_gradient" and
                           isinstance(old_value.func.value, ast.Name) and
                           old_value.func.value.id == "tf")
      if already_stop_grad:
        return False
      try:
        new_value = ast.Call(
            ast.Name(id="tf.stop_gradient", ctx=ast.Load()),
            [old_value], [])
      except TypeError:
        new_value = ast.Call(
            ast.Name(id="tf.stop_gradient", ctx=ast.Load()),
            [old_value], [], None, None)
  
      # This copies the prefix and suffix on old_value to new_value.
      pasta.ast_utils.replace_child(parent, old_value, new_value)
      ast.copy_location(new_value, old_value)
      return True
  
    # Check if we have a labels keyword arg
    for karg in node.keywords:
      if karg.arg == "labels":
        if _wrap_label(karg, karg.value):
          logs.append((ast_edits.INFO, node.lineno, node.col_offset,
                       "Changing labels arg of "
                       "tf.nn.softmax_cross_entropy_with_logits to "
                       "tf.stop_gradient(labels). Please check this "
                       "transformation.\n"))
        return node
    return node
function_tokens: def _softmax_cross_entropy_with_logits_transformer ( parent , node , full_name , name , logs ) : def _wrap_label ( parent , old_value ) : """Wrap labels with tf.stop_gradient.""" already_stop_grad = ( isinstance ( old_value , ast . Call ) and isinstance ( old_value . func , ast . Attribute ) and old_value . func . attr == "stop_gradient" and isinstance ( old_value . func . value , ast . Name ) and old_value . func . value . id == "tf" ) if already_stop_grad : return False try : new_value = ast . Call ( ast . Name ( id = "tf.stop_gradient" , ctx = ast . Load ( ) ) , [ old_value ] , [ ] ) except TypeError : new_value = ast . Call ( ast . Name ( id = "tf.stop_gradient" , ctx = ast . Load ( ) ) , [ old_value ] , [ ] , None , None ) # This copies the prefix and suffix on old_value to new_value. pasta . ast_utils . replace_child ( parent , old_value , new_value ) ast . copy_location ( new_value , old_value ) return True # Check if we have a labels keyword arg for karg in node . keywords : if karg . arg == "labels" : if _wrap_label ( karg , karg . value ) : logs . append ( ( ast_edits . INFO , node . lineno , node . col_offset , "Changing labels arg of " "tf.nn.softmax_cross_entropy_with_logits to " "tf.stop_gradient(labels). Please check this " "transformation.\n" ) ) return node return node