code: def _get_estimator_spec_with_metrics(
      logits,  # type: tf.Tensor
      softmax_logits,  # type: tf.Tensor
      duplicate_mask,  # type: tf.Tensor
      num_training_neg,  # type: int
      match_mlperf=False,  # type: bool
      use_tpu_spec=False,  # type: bool
  ):
      """Returns a EstimatorSpec that includes the metrics."""
      (
          cross_entropy,
          metric_fn,
          in_top_k,
          ndcg,
          metric_weights,
      ) = compute_eval_loss_and_metrics_helper(
          logits,
          softmax_logits,
          duplicate_mask,
          num_training_neg,
          match_mlperf,
          use_tpu_spec,
      )
  
      if use_tpu_spec:
          return tf.contrib.tpu.TPUEstimatorSpec(
              mode=tf.estimator.ModeKeys.EVAL,
              loss=cross_entropy,
              eval_metrics=(
                  metric_fn,
                  [in_top_k, ndcg, metric_weights],
              ),
          )
  
      return tf.estimator.EstimatorSpec(
          mode=tf.estimator.ModeKeys.EVAL,
          loss=cross_entropy,
          eval_metric_ops=metric_fn(in_top_k, ndcg, metric_weights),
      )
  
file_path: autodist/examples/benchmark/utils/recommendation/neumf_model.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from six.moves import xrange
  import tensorflow
  from utils.recommendation import constants
  from utils.recommendation import movielens
  from utils.recommendation import ncf_common
  from utils.recommendation import stat_utils
  from utils.logs import mlperf_helper
label_desc: Use image node_id 5 for calling a global function with example usage: _get_estimator_spec_with_metrics(logits, softmax_logits, duplicate_mask, num_training_neg, match_mlperf, use_tpu_spec) and returns: tf, tf