docstr: Helper function to test `make_loss_fn`.
code: def _check_make_pairwise_loss(self, loss_key):
      """Helper function to test `make_loss_fn`."""
      scores = [[1.0, 3.0, 2.0], [1.0, 2.0, 3.0]]
      labels = [[0.0, 0.0, 1.0], [0.0, 0.0, 2.0]]
      listwise_weights = [[2.0], [1.0]]
      listwise_weights_expanded = [[2.0] * 3, [1.0] * 3]
      itemwise_weights = [[2.0, 3.0, 4.0], [1.0, 1.0, 1.0]]
      default_weights = [1.0] * 3
      weights_feature_name = "weights"
      list_size = 3.0
      features = {}
  
      loss_fn = ranking_losses.make_loss_fn(loss_key)
      # Individual lists.
      self.assertAlmostEqual(
          loss_fn([labels[0]], [scores[0]], features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[0], scores[0], default_weights, loss_key
                  )
              ]
          ),
          places=5,
      )
      self.assertAlmostEqual(
          loss_fn([labels[1]], [scores[1]], features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[1], scores[1], default_weights, loss_key
                  )
              ]
          ),
          places=5,
      )
  
      # Itemwise weights.
      loss_fn = ranking_losses.make_loss_fn(
          loss_key, weights_feature_name=weights_feature_name
      )
      features[weights_feature_name] = [itemwise_weights[0]]
      self.assertAlmostEqual(
          loss_fn([labels[0]], [scores[0]], features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[0],
                      scores[0],
                      itemwise_weights[0],
                      loss_key,
                  )
              ]
          ),
          places=5,
      )
  
      features[weights_feature_name] = [itemwise_weights[1]]
      self.assertAlmostEqual(
          loss_fn([labels[1]], [scores[1]], features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[1],
                      scores[1],
                      itemwise_weights[1],
                      loss_key,
                  )
              ]
          ),
          places=5,
      )
  
      # Multiple lists.
      features[weights_feature_name] = listwise_weights
      self.assertAlmostEqual(
          loss_fn(labels, scores, features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[0],
                      scores[0],
                      listwise_weights_expanded[0],
                      loss_key,
                  ),
                  _pairwise_loss(
                      labels[1],
                      scores[1],
                      listwise_weights_expanded[1],
                      loss_key,
                  ),
              ]
          ),
          places=5,
      )
  
      # Test LambdaWeight.
      lambda_weight = losses_impl.DCGLambdaWeight(
          rank_discount_fn=lambda r: 1.0 / tf.math.log1p(r),
          smooth_fraction=1.0,
      )
      loss_fn = ranking_losses.make_loss_fn(
          loss_key,
          weights_feature_name=weights_feature_name,
          lambda_weight=lambda_weight,
      )
      self.assertAlmostEqual(
          loss_fn(labels, scores, features).numpy(),
          _batch_aggregation(
              [
                  _pairwise_loss(
                      labels[0],
                      scores[0],
                      listwise_weights_expanded[0],
                      loss_key,
                      rank_discount_form="LOG",
                  ),
                  _pairwise_loss(
                      labels[1],
                      scores[1],
                      listwise_weights_expanded[1],
                      loss_key,
                      rank_discount_form="LOG",
                  ),
              ]
          )
          * list_size,
          places=5,
      )
  
      # Test loss reduction method.
      # Two reduction methods should return different loss values.
      loss_fn_1 = ranking_losses.make_loss_fn(
          loss_key, reduction=tf.compat.v1.losses.Reduction.SUM
      )
      loss_fn_2 = ranking_losses.make_loss_fn(
          loss_key, reduction=tf.compat.v1.losses.Reduction.MEAN
      )
      self.assertNotAlmostEqual(
          loss_fn_1(labels, scores, features).numpy(),
          loss_fn_2(labels, scores, features).numpy(),
      )
  
imports: import math
  import tensorflow
  from tensorflow_ranking.python import losses
  from tensorflow_ranking.python import losses_impl
label_desc: Use image node_id 2 for calling the LossesTest obj's underlying member method code with example usage: obj._check_make_pairwise_loss(loss_key) without return types