code: def _check_abs_max_grad(abs_max_grad, model):
      """Checks `model` for a new largest gradient for this epoch, in order to
      track gradient explosions.
      """
      finite_grads = [
          p.grad.data for p in model.parameters() if p.grad is not None
      ]
  
      new_max_grad = max([grad.max() for grad in finite_grads])
      new_min_grad = min([grad.min() for grad in finite_grads])
  
      new_abs_max_grad = max(new_max_grad, abs(new_min_grad))
      if new_abs_max_grad > abs_max_grad:
          logger.info(f"abs max grad {abs_max_grad}")
          return new_abs_max_grad
  
      return abs_max_grad
  
imports: import contextlib
  import glob
  import math
  import os
  import numpy
  import scipy.signal
  from tensorboard import TensorBoard
  import torch
  from torch import nn
  import torch.nn.parallel
  from torch.autograd import Variable
  import models
  import utils
label_desc: Use image node_id 5 for calling a global function with example usage: _check_abs_max_grad(abs_max_grad, model) and returns: abs_max_grad, new_abs_max_grad