def build_stats(history, eval_output, callbacks):
    'Normalizes and returns dictionary of stats.\n\n  Args:\n    history: Results of the training step. Supports both categorical_accuracy\n      and sparse_categorical_accuracy.\n    eval_output: Output of the eval step. Assumes first value is eval_loss and\n      second value is accuracy_top_1.\n    callbacks: a list of callbacks which might include a time history callback\n      used during keras.fit.\n\n  Returns:\n    Dictionary of normalized results.\n  '
    stats = {}
    if eval_output:
        stats['accuracy_top_1'] = eval_output[1].item()
        stats['eval_loss'] = eval_output[0].item()
    if (history and history.history):
        train_hist = history.history
        stats['loss'] = train_hist['loss'][(- 1)].item()
        if ('categorical_accuracy' in train_hist):
            stats[TRAIN_TOP_1] = train_hist['categorical_accuracy'][(- 1)].item()
        elif ('sparse_categorical_accuracy' in train_hist):
            stats[TRAIN_TOP_1] = train_hist['sparse_categorical_accuracy'][(- 1)].item()
    if (not callbacks):
        return stats
    for callback in callbacks:
        if isinstance(callback, keras_utils.TimeHistory):
            timestamp_log = callback.timestamp_log
            stats['step_timestamp_log'] = timestamp_log
            stats['train_finish_time'] = callback.train_finish_time
            if (len(timestamp_log) > 1):
                stats['avg_exp_per_second'] = (((callback.batch_size * callback.log_steps) * (len(callback.timestamp_log) - 1)) / (timestamp_log[(- 1)].timestamp - timestamp_log[0].timestamp))
    return stats
Normalizes and returns dictionary of stats.

Args:
  history: Results of the training step. Supports both categorical_accuracy
    and sparse_categorical_accuracy.
  eval_output: Output of the eval step. Assumes first value is eval_loss and
    second value is accuracy_top_1.
  callbacks: a list of callbacks which might include a time history callback
    used during keras.fit.

Returns:
  Dictionary of normalized results.
def build_stats(history, eval_output, callbacks):
    'Normalizes and returns dictionary of stats.\n\n  Args:\n    history: Results of the training step. Supports both categorical_accuracy\n      and sparse_categorical_accuracy.\n    eval_output: Output of the eval step. Assumes first value is eval_loss and\n      second value is accuracy_top_1.\n    callbacks: a list of callbacks which might include a time history callback\n      used during keras.fit.\n\n  Returns:\n    Dictionary of normalized results.\n  '
    stats = {}
    if eval_output:
        stats['accuracy_top_1'] = eval_output[1].item()
        stats['eval_loss'] = eval_output[0].item()
    if (history and history.history):
        train_hist = history.history
        stats['loss'] = train_hist['loss'][(- 1)].item()
        if ('categorical_accuracy' in train_hist):
            stats[TRAIN_TOP_1] = train_hist['categorical_accuracy'][(- 1)].item()
        elif ('sparse_categorical_accuracy' in train_hist):
            stats[TRAIN_TOP_1] = train_hist['sparse_categorical_accuracy'][(- 1)].item()
    if (not callbacks):
        return stats
    for callback in callbacks:
        if isinstance(callback, keras_utils.TimeHistory):
            timestamp_log = callback.timestamp_log
            stats['step_timestamp_log'] = timestamp_log
            stats['train_finish_time'] = callback.train_finish_time
            if (len(timestamp_log) > 1):
                stats['avg_exp_per_second'] = (((callback.batch_size * callback.log_steps) * (len(callback.timestamp_log) - 1)) / (timestamp_log[(- 1)].timestamp - timestamp_log[0].timestamp))
    return stats