torch.nn.embedding has run time error
I want to use torch.nn.Embedding. I have followed the codes in the documentation of embedding command.
here is the code:

# an Embedding module containing 10 tensors of size 3
embedding = nn.Embedding(10, 3)
# a batch of 2 samples of 4 indices each
input = torch.LongTensor([[1,2,4,5],[4,3,2,9]])
embedding(input)


The documentation says that you will receive this output:

tensor([[[-0.0251, -1.6902,  0.7172],
         [-0.6431,  0.0748,  0.6969],
         [ 1.4970,  1.3448, -0.9685],
         [-0.3677, -2.7265, -0.1685]],

        [[ 1.4970,  1.3448, -0.9685],
         [ 0.4362, -0.4004,  0.9400],
         [-0.6431,  0.0748,  0.6969],
         [ 0.9124, -2.3616,  1.1151]]])


but I don't receive this output. instead I receive this error:

Traceback (most recent call last):
  File "/home/mahsa/PycharmProjects/PyTorch_env_project/PyTorchZeroToAll-master/temporary.py", line 12, in &lt;module&gt;
    embedding(input)
  File "/home/mahsa/anaconda3/envs/pytorch_env/lib/python3.5/site-packages/torch/nn/modules/module.py", line 224, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/mahsa/anaconda3/envs/pytorch_env/lib/python3.5/site-packages/torch/nn/modules/sparse.py", line 94, in forward
    self.scale_grad_by_freq, self.sparse
RuntimeError: save_for_backward can only save input or output tensors, but argument 0 doesn't satisfy this condition


Can anybody guide me about this error? and about the work of torch.nn.Embedding?

if we change this line:

input = torch.LongTensor([[1,2,4,5],[4,3,2,9]])


with this:

input = autograd.Variable(torch.LongTensor([[1,2,4,5],[4,3,2,9]]))


the problem is solved!
