code: def _weighted_norm(weights, xs):
      """Returns sqrt(sum_{axis=-1}(w_i * x_i**2)) without overflow in x_i**2."""
      # Notably, this implementation differs from tf.norm in supporting weights and
      # avoiding overflow.  The weights are assumed < 1, i.e., incapable of causing
      # overflow themselves.
      magnitude = tf.reduce_max(tf.math.abs(xs), axis=-1)
      xs = xs / magnitude[..., tf.newaxis]
      normalized_result = tf.sqrt(
          tf.reduce_sum(weights * tf.square(xs), axis=-1)
      )
      return tf.math.multiply_no_nan(normalized_result, magnitude)
  
imports: import functools
  import hashlib
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 4 for calling a global function with example usage: _weighted_norm(weights, xs) and returns: tf