but i did post it completely.
I tried doing model.to(device) after  hidden = model.init_hidden(batch_size), but got the same error:
call to PrepareDatasetAsNetworkInput
Myparams=NetworkParams(batch_size = 1,
                   input_length = 20, #input_length to the LSM, EmbededDim#TrainDatabase.size(1),

                   output_size = 10000,#1

                   layers = 2,

                   decay = 2,

                   hidden_units = 200, #rnn_size 

                   dropout = 0.5,

                   init_weight = 0.1,

                   lr = 1,

                   vocab_size = 1000,

                   max_epoch = 4,

                   max_max_epoch = 13,

                   max_grad_norm = 5)

print(“Test LSTM model on dummy inputs\n”)
test the LSTM forward feed with 1 batch, this test the Network model
model = LSTM(Myparams.vocab_size,Myparams.input_length, Myparams.output_size, Myparams.hidden_units, Myparams.layers, Myparams.dropout,Myparams.init_weight)
# test the LSTM forward feed with 2 batch, on dummy input

# if input is  batch_size x seq_len

Input = torch.LongTensor([[1,2,3,4,5],[6,5,5,4,6]]) 

batch_size=len(Input)

model.apply(model.init_weights_uniform) # init weights

hidden = model.init_hidden(batch_size) # init first hidden stage

print(len(hidden))

for e in hidden:

  print(e.data.size())

print("------")

#hidden = torch.LongTensor([e.data for e in hidden])

Input.to(device)

model.to(device)

print("Input size " + str(Input.size(0)) + " x " + str(Input.size(1)))

out, hidden=model(Input,hidden)

print(out.size()) #has no real value, since this untrained network

print(out[0,0,]) #has no real value, since this untrained network

and the output:
Test LSTM model on dummy inputs

2
torch.Size([2, 2, 200])
torch.Size([2, 2, 200])
------
Input size 2 x 5
hidden_at_time_0 size :  torch.Size([2, 2, 200])
---------------------------------------------------------------------------


RuntimeError                              Traceback (most recent call last)
<ipython-input-14-847ac0cf6c23> in <module>()
     40 
     41 print("Input size " + str(Input.size(0)) + " x " + str(Input.size(1)))
---> 42 out, hidden=model(Input,hidden)
     43 print(out.size()) #has no real value, since this untrain network
     44 print(out[0,0,]) #has no real value, since this untrain network

4 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

<ipython-input-12-ef9fdf59add0> in forward(self, x, hidden)
     43     x = x.long()
     44 
---> 45     embeds = self.embedding(x)
     46 
     47     # embeds size :[batch_size ,seq_len , input_length]

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/sparse.py in forward(self, input)
    112         return F.embedding(
    113             input, self.weight, self.padding_idx, self.max_norm,
--> 114             self.norm_type, self.scale_grad_by_freq, self.sparse)
    115 
    116     def extra_repr(self):

/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
   1722         # remove once script supports set_grad_enabled
   1723         _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1724     return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
   1725 
   1726 

RuntimeError: Expected object of device type cuda but got device type cpu for argument #3 'index' in call to _th_index_select