code: def build_stats(loss, eval_result, time_callback):
      """Normalizes and returns dictionary of stats.
  
      Args:
          loss: The final loss at training time.
          eval_result: Output of the eval step. Assumes first value is eval_loss and
              second value is accuracy_top_1.
          time_callback: Time tracking callback likely used during keras.fit.
  
      Returns:
          Dictionary of normalized results.
      """
      stats = {}
      if loss:
          stats["loss"] = loss
  
      if eval_result:
          stats["eval_loss"] = eval_result[0]
          stats["eval_hit_rate"] = eval_result[1]
  
      if time_callback:
          timestamp_log = time_callback.timestamp_log
          stats["step_timestamp_log"] = timestamp_log
          stats["train_finish_time"] = time_callback.train_finish_time
          if len(timestamp_log) > 1:
              stats["avg_exp_per_second"] = (
                  time_callback.batch_size
                  * time_callback.log_steps
                  * (len(time_callback.timestamp_log) - 1)
                  / (
                      timestamp_log[-1].timestamp
                      - timestamp_log[0].timestamp
                  )
              )
  
      return stats
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import json
  import yaml
  import os
  import sys
  import tensorflow
  from absl import app
  from absl import flags
  from absl import logging
  from os.path import expanduser
  from tensorflow_addons.optimizers import LazyAdam
  from utils.recommendation import constants
  from utils.recommendation import movielens
  from utils.recommendation import ncf_common
  from utils.recommendation import ncf_input_pipeline
  from utils.recommendation import neumf_model
  from utils.flags import core
  from utils.logs import logger
  from utils.logs import mlperf_helper
  from utils.misc import keras_utils
  from utils.misc import model_helpers
  from autodist import AutoDist
  from autodist.strategy.ps_strategy import PS
  from autodist.strategy.ps_lb_strategy import PSLoadBalancing
  from autodist.strategy.partitioned_ps_strategy import PartitionedPS
  from autodist.strategy.all_reduce_strategy import AllReduce
  from autodist.strategy.parallax_strategy import Parallax
label_desc: Use image node_id 4 for calling a global function with example usage: build_stats(loss, eval_result, time_callback) and returns: stats