code: def discounted_cumulative_gain(
      labels,
      predictions,
      weights=None,
      topn=None,
      name=None,
      gain_fn=_DEFAULT_GAIN_FN,
      rank_discount_fn=_DEFAULT_RANK_DISCOUNT_FN,
  ):
      """Computes discounted cumulative gain (DCG).
  
      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.
        topn: A cutoff for how many examples to consider for this metric.
        name: A string used as the name for this metric.
        gain_fn: (function) Transforms labels.
        rank_discount_fn: (function) The rank discount function.
  
      Returns:
        A metric for the weighted discounted cumulative gain of the batch.
      """
      metric = metrics_impl.DCGMetric(
          name, topn, gain_fn, rank_discount_fn
      )
      with tf.compat.v1.name_scope(
          name,
          "discounted_cumulative_gain",
          (labels, predictions, weights),
      ):
          # TODO: Add mask argument for metric.compute() call
          dcg, per_list_weights = metric.compute(
              labels, predictions, weights
          )
      return tf.compat.v1.metrics.mean(dcg, 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 10 for calling a global function with example usage: discounted_cumulative_gain(labels, predictions, weights, topn, name, gain_fn, rank_discount_fn) and returns: tf