import tensorflow as tf

      string, out_string will contain a random integer casted to a string.
      Otherwise string_tensor is returned unchanged.

  """

  empty_string = tf.constant('', dtype=tf.string, name='EmptyString')

  random_source_id = tf.as_string(
    tf.random_uniform(shape=[], maxval=2 ** 63 - 1, dtype=tf.int64))

  out_string = tf.cond(
    tf.equal(string_tensor, empty_string),
    true_fn=lambda: random_source_id,
    false_fn=lambda: string_tensor)

  return out_string
