Hi,
You can use  torch.ge (greater or equal) and  torch.le (lower or equal) with :
lower = torch.LongTensor([2, 0, 4]).unsqueeze(dim=-1)
upper = torch.LongTensor([3, 2, 4]).unsqueeze(dim=-1)

idx = torch.arange(5)
mask = idx.ge(lower) & idx.le(upper)

It will give you a tensor with True and False
Use mask.long() if you need ones and zeros