nodes: 0, module; 1, function_definition; 2, function_name:top_k_with_unique; 3, parameters; 4, block; 5, identifier:inputs; 6, identifier:k; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Finds the values and indices of the k largests entries.
  
    Instead of doing sort like tf.nn.top_k, this function finds the max value
    k times. The running time is proportional to k, which is be faster when k
    is small. The current implementation supports only inputs of rank 2.
    In addition, iota is used to replace the lower bits of each element, this
    makes the selection more stable when there are equal elements. The
    overhead is that output values are approximated.
  
    Args:
      inputs: A tensor with rank of 2. [batch_size, original_size].
      k: An integer, number of top elements to select.
  
    Returns:
      top_values: A tensor, the k largest elements in sorted order.
        [batch_size, k].
      indices: A tensor, indices of the top_values. [batch_size, k].
    """; 13, assignment; 14, assignment; 15, assignment; 16, expression_list; 17, identifier:unique_inputs; 18, call; 19, pattern_list; 20, call; 21, identifier:top_values; 22, call; 23, identifier:top_values; 24, identifier:indices; 25, identifier:_create_make_unique; 26, argument_list; 27, identifier:top_values; 28, identifier:indices; 29, identifier:_create_topk_unique; 30, argument_list; 31, attribute; 32, argument_list; 33, call; 34, identifier:unique_inputs; 35, identifier:k; 36, identifier:tf; 37, identifier:cast; 38, identifier:top_values; 39, attribute; 40, attribute; 41, argument_list; 42, identifier:inputs; 43, identifier:dtype; 44, identifier:tf; 45, identifier:cast; 46, identifier:inputs; 47, attribute; 48, identifier:tf; 49, identifier:float32
code: def top_k_with_unique(inputs, k):
    """Finds the values and indices of the k largests entries.
  
    Instead of doing sort like tf.nn.top_k, this function finds the max value
    k times. The running time is proportional to k, which is be faster when k
    is small. The current implementation supports only inputs of rank 2.
    In addition, iota is used to replace the lower bits of each element, this
    makes the selection more stable when there are equal elements. The
    overhead is that output values are approximated.
  
    Args:
      inputs: A tensor with rank of 2. [batch_size, original_size].
      k: An integer, number of top elements to select.
  
    Returns:
      top_values: A tensor, the k largest elements in sorted order.
        [batch_size, k].
      indices: A tensor, indices of the top_values. [batch_size, k].
    """
    unique_inputs = _create_make_unique(tf.cast(inputs, tf.float32))
    top_values, indices = _create_topk_unique(unique_inputs, k)
    top_values = tf.cast(top_values, inputs.dtype)
    return top_values, indices