code: def _example_weights_to_list_weights(weights, relevances, boost_form):
      """Returns list with per list weights derived from the per example weights.
  
      Args:
        weights: List of lists with per example weight.
        relevances:  List of lists with per example relevance score.
        boost_form: Either NDCG or PRECISION.
  
      Returns:
        A list of per list weight.
      """
      list_weights = []
      nonzero_relevance = 0.0
      for example_weights, labels in zip(weights, relevances):
          boosted_labels = [
              _label_boost(boost_form, label) for label in labels
          ]
          numerator = sum(
              (weight * boosted_labels[i])
              for i, weight in enumerate(example_weights)
          )
          denominator = sum(boosted_labels)
          if denominator == 0.0:
              list_weights.append(0.0)
          else:
              list_weights.append(numerator / denominator)
              nonzero_relevance += 1.0
      list_weights_sum = sum(list_weights)
      if list_weights_sum > 0.0:
          list_weights = [
              list_weights_sum / nonzero_relevance if w == 0.0 else w
              for w in list_weights
          ]
  
      return list_weights
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import math
  import tensorflow
  from tensorflow_ranking.python import metrics
label_desc: Use image node_id 5 for calling a global function with example usage: _example_weights_to_list_weights(weights, relevances, boost_form) and returns: list_weights