ends have the same size.
starts is variable.
ends is variable, but each end is larger than each start.
starts = torch.tensor([0, 1, 2, 3]) ends = torch.tensor([2, 4, 6, 8]) aranges =  for s, e in zip(starts, ends): aranges.append(torch.arange(s, e)) result = torch.cat(aranges, dim=0) result
Can we get the same
result without loop?