code: def global_norm(
      arrays: Union[
          Generator[NDArray, NDArray, NDArray],
          List[NDArray],
          Tuple[NDArray],
      ]
  ) -> NDArray:
      """
      Calculate global norm on list or tuple of NDArrays using this formula:
          `global_norm = sqrt(sum([l2norm(p)**2 for p in parameters]))`
  
      :param arrays: list or tuple of parameters to calculate global norm on
      :return: single-value NDArray
      """
  
      def _norm(array):
          if array.stype == "default":
              x = array.reshape((-1,))
              return nd.dot(x, x)
          return array.norm().square()
  
      total_norm = nd.add_n(*[_norm(arr) for arr in arrays])
      total_norm = nd.sqrt(total_norm)
      return total_norm
  
imports: import inspect
  from typing import Any, Dict, Generator, Iterable, List, Tuple, Union
  from types import ModuleType
  import mxnet
  from mxnet import gluon, nd
  from mxnet.ndarray import NDArray
  import numpy
  from rl_coach.core_types import GradientClippingMethod
label_desc: Use image node_id 3 for calling a global function with example usage: global_norm(arrays) and returns: total_norm, array, nd