code: def weighted_avg(t, mask=None, axis=None, expand_mask=False):
      if mask is None:
          return tf.reduce_mean(t, axis=axis)
      else:
          if expand_mask:
              mask = tf.expand_dims(mask, axis=-1)
          return tf.reduce_sum(
              tf.multiply(t, mask), axis=axis
          ) / tf.reduce_sum(mask, axis=axis)
  
imports: from magenta.contrib import rnn
  from magenta.models.piano_genie import util
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: weighted_avg(t, mask, axis, expand_mask) and returns: tf, unknown