code: def process_stats(stats, info, global_step, steps_per_stats, log_f):
      """Update info and check for overflow."""
      # Per-step info
      info["avg_step_time"] = stats["step_time"] / steps_per_stats
      info["avg_grad_norm"] = stats["grad_norm"] / steps_per_stats
      info["avg_sequence_count"] = (
          stats["sequence_count"] / steps_per_stats
      )
      info["speed"] = stats["word_count"] / (1000 * stats["step_time"])
  
      # Per-predict info
      info["train_ppl"] = utils.safe_exp(
          stats["train_loss"] / stats["predict_count"]
      )
  
      # Check for overflow
      is_overflow = False
      train_ppl = info["train_ppl"]
      if (
          math.isnan(train_ppl)
          or math.isinf(train_ppl)
          or train_ppl > 1e20
      ):
          utils.print_out(
              "  step %d overflow, stop early" % global_step, log_f
          )
          is_overflow = True
  
      return is_overflow
  
imports: from __future__ import print_function
  import math
  import os
  import random
  import time
  import tensorflow
  from .None import inference, gnmt_model
  from .gnmt import attention_model, model
  from .gnmt import model_helper
  from .gnmt.utils import nmt_utils, misc_utils
label_desc: Use image node_id 11 for calling a global function with example usage: process_stats(stats, info, global_step, steps_per_stats, log_f) and returns: is_overflow