Yes, it should be (batch_size, seqlen) i.e. (3,9). Then you can pass it to nn.Embedding() layer.



 zamannafi:

Could you explain this part. I didn’t really understand this.


Sure, so basically when you pass a tensor of shape (batch_size, seqlen, embedding_dim) into a Bidirectional LSTM / RNN, then its shape becomes (batch_size, seqlen, 2*hidden_dim) in the output.
So you can either average all the inner tensors along the dimension of sequence length to get a single vector (i.e. by using AvgPool1D) & then use linear transformation to convert the representation into number of classes.
In place of Average Pooling, you can also use the output generated at last time step of RNN as it stores sequential information of current time step as well as information from previous time steps.