code: def _safe_mean(losses, num_present):
      """Computes a safe mean of the losses.
  
      Args:
        losses: `Tensor` whose elements contain individual loss measurements.
        num_present: The number of measurable elements in `losses`.
  
      Returns:
        A scalar representing the mean of `losses`. If `num_present` is zero,
          then zero is returned.
      """
      total_loss = math_ops.reduce_sum(losses)
      return math_ops.div_no_nan(total_loss, num_present, name="value")
  
imports: from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import confusion_matrix
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import weights_broadcast_ops
  from tensorflow.python.ops.losses import util
  from tensorflow.python.util import dispatch
  from tensorflow.python.util.deprecation import deprecated_args
  from tensorflow.python.util.deprecation import deprecated_argument_lookup
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 for calling a global function with example usage: _safe_mean(losses, num_present) and returns: math_ops