title: Creating a pytorch tensor binary mask using specific values
body: <p>I am given a pytorch 2-D tensor with integers, and 2 integers that always appear in each row of the tensor.
  I want to create a binary mask that will contain 1 between the <strong>two</strong> appearances of these 2 integers, otherwise 0. For example, if the integers are 4 and 2 and the 1-D array is <code>[1,1,9,4,6,5,1,2,9,9,11,4,3,6,5,2,3,4]</code>, the returned mask will be: <code>[0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0].</code>
  Is there any efficient and quick way to compute this mask without iterations?</p>