code: def scale_check_overflow_python(
      model_grad, master_grad, scale, check_overflow=False
  ):
      # Exception handling for 18.04 compatibility
      if check_overflow:
          cpu_sum = float(model_grad.float().sum())
          if (
              cpu_sum == float("inf")
              or cpu_sum == -float("inf")
              or cpu_sum != cpu_sum
          ):
              return True
  
      if (
          master_grad is not model_grad
      ):  # copy_ probably internally short-circuits this
          master_grad.copy_(model_grad)
      if scale != 1.0:
          master_grad.mul_(scale)
      return False
  
file_path: apex/apex/amp/scaler.py
imports: import torch
  from ..multi_tensor_apply import multi_tensor_applier
  from ._amp_state import _amp_state, master_params, maybe_print
  from itertools import product
label_desc: Use image node_id 1 for calling a global function with example usage: scale_check_overflow_python(model_grad, master_grad, scale, check_overflow) and returns: False, True