The error is raised in loss function (either nn.CrossEntropyLoss or nn.NLLLoss) due to a shape mismatch.
I assume you are working on a multi-class classification and the target contains class indices.
Your current model output has the shape [32, 256, 3], which corresponds to [batch_size, nb_classes, seq_len], while the target is expected to have the shape [batch_size, seq_len] containing the class indices in the range [0, nb_classes-1]. Currently the target has the shape [batch_size=32], so it contains a target index for each sample while targets for each time step are also expected.