Set the first N tensor elements to 0

I have a very simple question. Given a tensor T = torch.Tensor([1,2,3,4]) , I need a temporary copy with the first s elements set to 0?
For now, I have the following:
T_tmp = T.clone()
T_tmp [:s] = 0
I am wondering if there are better alternatives because I only need to pass the copy through a function (distribution), and preceding my call with two lines is annoying.


Not the best solution, but at least just one line:

T.clone().index_put_([torch.arange(0, s, out=torch.LongTensor())], torch.tensor([0], dtype=torch.float))

Seems any fixes is not made for the output type of torch.arange ? (