vdw:

Any need for something like x.view(batch_size, ...) should not be needed and only does the right thing by chance.


You are right. There is no need for reshaping in this model (ModelLSTMFSM_TRAINS).
trains:
before torch.Size([64, 21, 8])
after torch.Size([64, 21, 8])

not trains:
before torch.Size([64, 21, 8])
after torch.Size([21, 64, 8])

batch_size=64
x is a matrix, with 21 rows. The size of each row is 8. Each row value can be 0 or 1 and padded with 2. Padded binary strings.
tensor([[0., 2., 2., 2., 2., 2., 2., 2.],
        [0., 0., 0., 1., 0., 0., 0., 0.],
        [0., 0., 0., 1., 1., 2., 2., 2.],
        [0., 0., 1., 1., 0., 1., 0., 0.], ....

The output is 3 by 2 matrix. In my case it is Finite-state machine:
[[0, 1], [2, 1], [2, 1]]