Rojin:

bce = torch.nn.functional.cross_entropy(reconstruction, x.view(-1, input_size))


This line is acting up because the x tensor consists of float (decimal number) instead of a long (whole number).
A tensor can be converted to Long by tensor_name.type(torch.LongTensor).
Side note, If you are using the gpu to train the tensor needs to be put on the gpu with tensor_name.type(torch.cuda.LongTensor)