code: def test_eval(self):
      with tf.Graph().as_default():
          metric_fns = {
              "metric/precision@1": metrics_lib.make_ranking_metric_fn(
                  metrics_lib.RankingMetricKey.PRECISION, topn=1
              ),
          }
          head1 = ranking_head.create_ranking_head(
              loss_fn=_make_loss_fn(),
              eval_metric_fns=metric_fns,
              name="head1",
          )
          head2 = ranking_head.create_ranking_head(
              loss_fn=_make_loss_fn(),
              eval_metric_fns=metric_fns,
              name="head2",
          )
          multi_head = ranking_head.create_multi_ranking_head(
              [head1, head2]
          )
  
          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]]
              ),
          }
          spec = multi_head.create_estimator_spec(
              features={},
              mode=tf_estimator.ModeKeys.EVAL,
              logits=logits,
              labels=labels,
          )
  
          expected_metrics = [
              "head1/labels_mean",
              "head1/logits_mean",
              "head1/metric/precision@1",
              "head2/labels_mean",
              "head2/logits_mean",
              "head2/metric/precision@1",
          ]
  
          # Assert spec contains expected tensors.
          self.assertIsNotNone(spec.loss)
          self.assertIsNone(spec.train_op)
          self.assertIsNone(spec.export_outputs)
          self.assertCountEqual(
              spec.eval_metric_ops.keys(), expected_metrics
          )
  
          # Assert predictions, loss, and metrics.
          with self.cached_session() as sess:
              _initialize_variables(self, spec.scaffold)
              self.assertIsNone(spec.scaffold.summary_op)
              update_ops = {
                  k: spec.eval_metric_ops[k][1]
                  for k in spec.eval_metric_ops
              }
              loss, metrics = sess.run((spec.loss, update_ops))
              self.assertAllClose(loss, 10.0)
              self.assertItemsEqual(metrics.keys(), expected_metrics)
  
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 2 for calling the MultiRankingHeadTest obj's underlying member method code with example usage: obj.test_eval() without return types