Actually it fixed the error but this didn’t fix the real problem.
The real problem is from the embedding layer because there is words from valid dataset that has no embedding vector because I didn’t use the vocabs of the vaild dataset.
you are right if I build the vocabs using train and vaild, it will work but
when I predict a piece of text that contains a word that has no embedding vector I will get the same problem so the complete solution is:
pad_token = TEXT.vocab.stoi[TEXT.pad_token] # {'<pad>': 1}
unk_token = TEXT.vocab.stoi[TEXT.unk_token] # {'<unk>': 0}
model.embedding.weight.data[pad_token] = torch.zeros(embedding_dim) # vector for pad_token that will be given to any pad token as its embedding weight
model.embedding.weight.data[unk_token] = torch.zeros(embedding_dim) # vector for unk_token that will be given to any unkown word as its embedding weight

this code will append vectors for pad_token and unk_token with zero weight.