code: def check_nonnegative(value):
    
    if isinstance(value, tf.Tensor):
      with tf.control_dependencies([tf.assert_greater_equal(value, 0)]):
        value = tf.identity(value)
    elif value < 0:
      raise ValueError("Value must be non-negative.")
    return value
docs: Check that the value is nonnegative.