Solved by ArEsKay3 in post #2 
              
              
                For now I’ve found this to work OK. 
s = torch.cumsum(I, dim=0)
x = s.index_select(0,start)
y = s.index_select(0,stop)
O = ((y-x) == (stop-start))