code: def has_overflow(grad_norm):
      """
      Detect inf and NaN in grad_norm.
      """
      if grad_norm == float("inf") or grad_norm != grad_norm:
          return True
      return False
  
imports: import math
  from itertools import chain
  from typing import Optional
  import parlai.utils.logging
label_desc: Use image node_id 2 for calling a global function with example usage: has_overflow(grad_norm) and returns: False, True