def METHOD_NAME(counts, name=None):
  """Repeat integers given by range(len(counts)) each the given number of times.
  Example behavior:
  [0, 1, 2, 3] -> [1, 2, 2, 3, 3, 3]
  Args:
    counts: 1D tensor with dtype=int32.
    name: optional name for operation.
  Returns:
    1D tensor with dtype=int32 and dynamic length giving the repeated integers.
  """
  with ops.name_scope(name, 'repeat_range', [counts]) as scope:
    counts = ops.convert_to_tensor(counts, name='counts')
    def cond(unused_output, i):
      return i < size
    def body(output, i):
      value = array_ops.fill(counts[i:i+1], i)
      return (output.write(i, value), i + 1)
    size = array_ops.shape(counts)[0]
    init_output_array = tensor_array_ops.TensorArray(
        dtype=dtypes.int32, size=size, infer_shape=False)
    output_array, num_writes = control_flow_ops.while_loop(
        cond, body, loop_vars=[init_output_array, 0])
    return control_flow_ops.cond(
        num_writes > 0,
        output_array.concat,
        lambda: array_ops.zeros(shape=[0], dtype=dtypes.int32),
        name=scope)