code: def ordered_pair_accuracy(
      labels, predictions, weights=None, name=None
  ):
      """Computes the percentage of correctly ordered pair.
  
      For any pair of examples, we compare their orders determined by `labels` and
      `predictions`. They are correctly ordered if the two orders are compatible.
      That is, labels l_i > l_j and predictions s_i > s_j and the weight for this
      pair is the weight from the l_i.
  
      Args:
        labels: A `Tensor` of the same shape as `predictions`.
        predictions: A `Tensor` with shape [batch_size, list_size]. Each value is
          the ranking score of the corresponding example.
        weights: A `Tensor` of the same shape of predictions or [batch_size, 1]. The
          former case is per-example and the latter case is per-list.
        name: A string used as the name for this metric.
  
      Returns:
        A metric for the accuracy or ordered pairs.
      """
      metric = metrics_impl.OPAMetric(name)
      with tf.compat.v1.name_scope(
          metric.name,
          "ordered_pair_accuracy",
          (labels, predictions, weights),
      ):
          # TODO: Add mask argument for metric.compute() call
          per_list_opa, per_list_weights = metric.compute(
              labels, predictions, weights
          )
      return tf.compat.v1.metrics.mean(per_list_opa, per_list_weights)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import tensorflow
  from tensorflow_ranking.python import metrics_impl
  from tensorflow_ranking.python import utils
label_desc: Use image node_id 12 for calling a global function with example usage: ordered_pair_accuracy(labels, predictions, weights, name) and returns: tf