Given a 1D tensor x, and a 2D tensor (N * 2) of start and end indices, is there a way to set the values in the start and end range to a specific value (say 0)?
I’m looking for a vectorized way to do the following:

>>> x = torch.randint(10, (8,))
>>> x
tensor([1, 6, 1, 9, 3, 2, 6, 2])
>>> indices = torch.tensor([[1,2], [4,6]])
>>> indices
tensor([[1, 2],
[4, 6]])
>>> desired_output = torch.tensor([1, 0, 1, 9, 0, 0, 6, 2])
>>> desired_output
tensor([1, 0, 1, 9, 0, 0, 6, 2])

The range between start and end is not guaranteed to have the same length (as 1 and 2 here). Any help would be appreciated!