saba:

it is correct to say that if the input size is not correct for training definitely pytorch show the error?


Yes, PyTorch will raise an exception, if you encounter a shape mismatch, so if the code runs fine, the shapes are correct. 
Your calculation is also correct, although I prefer to write x = x.view(x.size(0), -1) just to make sure the batch size is always correct and I will get a shape mismatch in case I use the wrong number of input features.