import time


def update_stats(stats, start_time, step_result):
    """Update stats: write summary and accumulate statistics."""
    (_, _, step_loss, step_summary, global_step, grad_norm, learning_rate) = step_result
    # Update statistics
    stats["step_time"] += (time.time() - start_time)
    stats["exp_loss"] += step_loss
    stats["grad_norm"] += grad_norm
    return global_step, learning_rate, step_summary