The error points to a shape of 0 in dim0, which is really strange.
I.e. you’ll get the same error, if you run the following code:
x = torch.randn(10, 10, 2)
x.view(x.size(0), -1)  # works
x.view(0, -1)  # your error

Could you print the shape of x right before the view operation in your forward method?