Thank you!
However if I am not mistaken this can only expand the the first (maybe also the last?) dimension but can not expand the dimensions in the middle. I guess a similar work-around might be to use “torch.unsqueeze” to add a singleton dimension before the desired dimension then expand it instead. But then it is not contiguous anymore, and using “view” to get the desired shape directly will raise an error.