code: def clip_by_global_norm(grads, clip_norm):
      """Clip the grads by global norm."""
      global_norm = mtf.sqrt(
          mtf.add_n(
              [
                  mtf.reduce_sum(mtf.square(t))
                  for t in grads
                  if t is not None
              ]
          )
      )
      multiplier = clip_norm / mtf.maximum(global_norm, clip_norm)
      clipped_grads = [
          None if t is None else t * multiplier for t in grads
      ]
      return clipped_grads, global_norm
  
file_path: mesh/mesh_tensorflow/bert/optimization.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import mesh_tensorflow
  import mesh_tensorflow.optimize
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: clip_by_global_norm(grads, clip_norm) and returns: clipped_grads,  global_norm