code: def mrr_score(logits, negative_logits, name=None):
      """
      Mean reciprocal rank score.
      """
      with tf.variable_scope(name, "mrr", (logits, negative_logits)):
          all_logits = tf.concat([negative_logits, logits], axis=2)
          size = tf.shape(all_logits)[2]
          _, indices_of_ranks = tf.nn.top_k(all_logits, k=size)
          _, ranks = tf.nn.top_k(-indices_of_ranks, k=size)
          return tf.reduce_mean(
              tf.reciprocal(tf.to_float(ranks[:, :, -1] + 1))
          )
  
file_path: euler/tf_euler/python/utils/metrics.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: mrr_score(logits, negative_logits, name) and returns: tf