docstr: Tests for merging losses from multi-head and regularization loss.
docstr_tok: ["Tests","for","merging","losses","from","multi-head","and","regularization","loss","."]
code: def test_merge_loss(self):
      """Tests for merging losses from multi-head and regularization loss."""
      head1 = ranking_head.create_ranking_head(
          loss_fn=_make_loss_fn(), name="head1"
      )
      head2 = ranking_head.create_ranking_head(
          loss_fn=_make_loss_fn(), name="head2"
      )
      multi_head = ranking_head.create_multi_ranking_head(
          [head1, head2], [1.0, 2.0]
      )
      logits = {
          "head1": tf.convert_to_tensor(value=[[1.0, 3.0], [1.0, 2.0]]),
          "head2": tf.convert_to_tensor(value=[[2.0, 3.0], [2.0, 2.0]]),
      }
      labels = {
          "head1": tf.convert_to_tensor(value=[[0.0, 1.0], [0.0, 2.0]]),
          "head2": tf.convert_to_tensor(value=[[0.0, 1.0], [0.0, 2.0]]),
      }
      regularization_losses = [1.5, 0.5]
      expected_loss = 1.0 * 4.0 + 2.0 * 6.0 + 1.5 + 0.5
  
      # Create loss.
      training_loss = multi_head._merge_loss(
          features={},
          mode=tf_estimator.ModeKeys.TRAIN,
          logits=logits,
          labels=labels,
          regularization_losses=regularization_losses,
      )
      self.assertAllClose(training_loss, expected_loss)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow import estimator
  from tensorflow_ranking.python import head
  from tensorflow_ranking.python import metrics
label_desc: Use image node_id 5 for calling the MultiRankingHeadTest obj's underlying member method code with example usage: obj.test_merge_loss() without return types