code: def _batch_global_norm(vals: List[tf.Tensor]) -> tf.Tensor:
      """Computes the global norm for each row in the batch."""
  
      def _norm_squared(v):
          return tf.cast(
              tf.reduce_sum(
                  tf.reshape(
                      tf.square(v), tf.stack([tf.shape(v)[0], -1])
                  ),
                  axis=1,
              ),
              tf.float32,
          )
  
      return tf.sqrt(
          tf.add_n([_norm_squared(v) for v in vals if v is not None])
      )
  
imports: from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union
  import tensorflow
  from tensorflow.python.ops.parallel_for import control_flow_ops
label_desc: Use image node_id 2 for calling a global function with example usage: _batch_global_norm(vals) and returns: tf, tf