index out of range at

Traceback (most recent call last):
File “train_2.py”, line 46, in
trainer.run()
File “train_2.py”, line 28, in run
outputs = self.model(inputs)
File “/home/lili/anaconda3/envs/python3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/lili/workspace/chinese_sentiment-master/qa_code/lstm.py”, line 25, in forward
x = self.embedding(x[0]) # 经过embedding,x的维度为(batch_size, time_step, input_size=embedding_dim)
File “/home/lili/anaconda3/envs/python3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/lili/anaconda3/envs/python3/lib/python3.6/site-packages/torch/nn/modules/sparse.py”, line 118, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File “/home/lili/anaconda3/envs/python3/lib/python3.6/site-packages/torch/nn/functional.py”, line 1454, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range at /opt/conda/conda-bld/pytorch_1550780889552/work/aten/src/TH/generic/THTensorEvenMoreMath.cpp:191

When embedding, It comes this problem.I don’t know why.

What’s the shape of embedding layer and what is the content of x? Note that embedding layer input should be 0-based indices.