Repeat Tensor Values Along an axis in Groups of 3 (n)

Hi,

I wanted to do an operation like this:

[ 1 2 3 4 5 6 7 8 9 ] --> [1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9]

How can I do this in torch?

lets, assume the given tensor, t = torch.tensor([ 1 2 3 4 5 6 7 8 9 ])

Use repeat_interleave e.g. if d has shape [1, 3] use torch.repeat_interleave(d, 3, dim=1)