title: Incrementally adds one to a list of indices given positions of specified item in list
body: <p>Given a list of tokens, input:</p>
  
  <pre><code>&gt;&gt;&gt; tokenized_text = "[CLS] my dog is cute [SEP] he likes slack ##ing [SEP]".split()
  &gt;&gt;&gt; tokenized_text 
  ['[CLS]', 'my', 'dog', 'is', 'cute', '[SEP]', 'he', 'likes', 'slack', '##ing', '[SEP]']
  </code></pre>
  
  <p>The goal is to create an index for up till every <code>[SEP]</code> from left to right, find the <code>[SEP]</code> tokens and then incrementally adds the 1 after every <code>[SEP]</code>, so the desired output indices for the <code>tokenize_text</code> list above is:</p>
  
  <pre><code>[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code># Find the indices of `[SEP]`.
  &gt;&gt;&gt; sep_indices = np.array(np.where(np.array(tokenized_text) == "[SEP]"))[0]
  &gt;&gt;&gt; sep_indices
  array([ 5, 10])
  
  &gt;&gt;&gt; prev = 0
  &gt;&gt;&gt; out =[]
  &gt;&gt;&gt; for i, idx in enumerate(sep_indices):
  ...     for _ in range(idx-prev):
  ...         out.append(i)
  ...     prev = idx
  ... 
  &gt;&gt;&gt; out = [0] + out[:-1]
  &gt;&gt;&gt; out
  [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
  </code></pre>
  
  <p>But is there an easier way to achieve the correct output?</p>