Sure, the -1 just means that PyTorch should automatically fill up this dimension, so that the number of elements stay the same.
You could of course specify is manually:
x = torch.arange(10)
y = x.view(2, 1, 5)