code: def _replicate_index(index_array, replicate_times):
      """Replicates index in `index_array` by the values in `replicate_times`."""
      batch_size = tf.shape(input=replicate_times)[0]
      replicated_idx_array = tf.TensorArray(
          dtype=tf.dtypes.int32, size=batch_size, infer_shape=False
      )
      init_iter = tf.constant(0)
  
      index_less_than_batch_size = (
          lambda i, *unused_args: i < batch_size
      )
  
      def duplicate_index(i, outputs):
          """Duplicates the current index by the value in the replicate_times."""
          outputs = outputs.write(
              i, tf.tile([index_array[i]], [replicate_times[i]])
          )
          return i + 1, outputs
  
      # Replicate the indices by the number of times indicated in 'replicate_times'.
      # For example, given `index_array = [0, 1, 2]`, `replicate_times = [3, 0, 1]`,
      # the `replicated_idx_array`  will be `[[0, 0, 0], [2]]`.
      unused_iter, replicated_idx_array = tf.while_loop(
          cond=index_less_than_batch_size,
          body=duplicate_index,
          loop_vars=[init_iter, replicated_idx_array],
      )
      # Concats 'replicated_idx_array' as a single tensor, which can be  used for
      # duplicating the input embeddings by 'embedding_lookup'.
      replicated_idx = tf.reshape(
          replicated_idx_array.concat(), shape=[-1]
      )
      return replicated_idx
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import neural_structured_learning.configs
  import six
  import tensorflow
label_desc: Use image node_id 8 for calling a global function with example usage: _replicate_index(index_array, replicate_times) and returns: replicated_idx, unknown,  outputs