This error comes from your loss nn.CrossEntropyLoss(), which needs the batch_size for the input tensor (here: 1) to be the same as the target tensor (here: 2).
Since you flatten the input tensor with .unsqueeze(0), the input batch_size will always be 1.
What are your targets for one sample?