I cannot reproduce the issue using your code snippet and get a valid output with a batch size of 4, which should be expected.
I’m using this code snippet based on the posted code:
# init
num_classes = 2  
num_epochs = 10
batch_size = 4
learning_rate = 0.001

# input size and sequence length are the Image dimension
input_size = 128 # tried both ways same error
sequence_length = 64
hidden_size = 128
num_layers = 2

class RNN(nn.Module):
    def __init__(self, input_size, hidden_size, num_layers, num_classes):
        super(RNN, self).__init__()
        self.num_layers = num_layers
        self.hidden_size = hidden_size
        self.rnn = nn.RNN(input_size, hidden_size, num_layers, batch_first=True)
        # -> x : (batch_size, seq, input_size)

        self.fc = nn.Linear(hidden_size, num_classes)


    def forward(self, x):
        h0 = torch.zeros(self.num_layers, x.size(0), self.hidden_size)
        print(x.size(0)) # outputs: 12

        # Forward propagate RNN
        out, _ = self.rnn(x, h0)
       

        # out: tensor of shape (batch_size, seq_length, hidden_size)
        print(x.shape) # outputs: torch.Size([12, 64, 128])

        out = out[:, -1, :]

        out = self.fc(out)
        return out

net = RNN(input_size, hidden_size, num_layers, num_classes)
# origin shape: [N, 1, 64, 128]
# resized: [N, 64, 128]
images = torch.randn(batch_size, 1, 64, 128)
images = images.reshape(-1, sequence_length, input_size)
print(images.shape)
> torch.Size([4, 64, 128])

outputs = net(images)
print(outputs.shape)
> torch.Size([4, 2])