Try this.
>>> import torch
>>> x = torch.tensor([1, 2, 3, 4])
>>> torch.repeat_interleave(x, torch.tensor([3,3,2,1]))
tensor([1, 1, 1, 2, 2, 2, 3, 3, 4])

https://pytorch.org/docs/stable/torch.html#torch.repeat_interleave 14