code: def sorted_ranks(scores, shuffle_ties=True, seed=None):
      """Returns an int `Tensor` as the ranks (1-based) after sorting scores.
  
      Example: Given scores = [[1.0, 3.5, 2.1]], the returned ranks will be [[3, 1,
      2]]. It means that scores 1.0 will be ranked at position 3, 3.5 will be ranked
      at position 1, and 2.1 will be ranked at position 2.
  
      Args:
        scores: A `Tensor` of shape [batch_size, list_size] representing the
          per-example scores.
        shuffle_ties: See `sort_by_scores`.
        seed: See `sort_by_scores`.
  
      Returns:
        A 1-based int `Tensor`s as the ranks.
      """
      with tf.compat.v1.name_scope(name="sorted_ranks"):
          batch_size, list_size = tf.unstack(tf.shape(input=scores))
          # The current position in the list for each score.
          positions = tf.tile(
              tf.expand_dims(tf.range(list_size), 0), [batch_size, 1]
          )
          # For score [[1.0, 3.5, 2.1]], sorted_positions are [[1, 2, 0]], meaning the
          # largest score is at position 1, the 2nd is at position 2 and 3rd is at
          # position 0.
          sorted_positions = sort_by_scores(
              scores, [positions], shuffle_ties=shuffle_ties, seed=seed
          )[0]
          # The indices of sorting sorted_positions will be [[2, 0, 1]] and ranks are
          # 1-based and thus are [[3, 1, 2]].
          ranks = tf.argsort(sorted_positions) + 1
          return ranks
  
file_path: ranking/tensorflow_ranking/python/utils.py
imports: from typing import Callable, Dict, Tuple
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: sorted_ranks(scores, shuffle_ties, seed) and returns: ranks