code: def _safe_average(totals, counts):
      # This tf.where protects `totals` from getting a gradient signal
      # when `counts` is 0.
      safe_totals = tf.where(~tf.equal(counts, 0), totals, 0)
      return tf.where(~tf.equal(counts, 0), safe_totals / counts, 0)
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math.generic import reduce_logmeanexp
label_desc: Use image node_id 11 for calling a global function with example usage: _safe_average(totals, counts) and returns: tf