If Unsqueeze the tensor as follows :
train_inputs = train_seq.clone().detach().unsqueeze(-1)
train_labels = train_labels.clone().detach()

test_inputs = test_seq.clone().detach().unsqueeze(-1)
test_labels = test_labels.clone().detach()


My error changed and the network expected to have a 3-dimensional tensor :
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<timed exec> in <module>

<ipython-input-44-ea284297e260> in train(model, device, federated_train_loader, optimizer, epoch)
     13         print('seq shape : {}'.format(seq.shape))
     14         print('labels shape : {}'.format(labels.shape))
---> 15         output = model(seq)
     16         # Calculate huber loss for regression problems
     17         #labels =labels.view(-1)

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    491             result = self._slow_forward(*input, **kwargs)
    492         else:
--> 493             result = self.forward(*input, **kwargs)
    494         for hook in self._forward_hooks.values():
    495             hook_result = hook(self, input, result)

<ipython-input-38-499b4cb2002e> in forward(self, input)
     26 
     27         # Propagate input through LSTM
---> 28         ula, (output, _) = self.lstm(input, (hidden_state, cell_state))
     29         output = output.view(-1, self.hidden_size)
     30 

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    491             result = self._slow_forward(*input, **kwargs)
    492         else:
--> 493             result = self.forward(*input, **kwargs)
    494         for hook in self._forward_hooks.values():
    495             hook_result = hook(self, input, result)

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/rnn.py in forward(self, input, hx)
    557             return self.forward_packed(input, hx)
    558         else:
--> 559             return self.forward_tensor(input, hx)
    560 
    561 

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/rnn.py in forward_tensor(self, input, hx)
    537         unsorted_indices = None
    538 
--> 539         output, hidden = self.forward_impl(input, hx, batch_sizes, max_batch_size, sorted_indices)
    540 
    541         return output, self.permute_hidden(hidden, unsorted_indices)

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/rnn.py in forward_impl(self, input, hx, batch_sizes, max_batch_size, sorted_indices)
    517             hx = self.permute_hidden(hx, sorted_indices)
    518 
--> 519         self.check_forward_args(input, hx, batch_sizes)
    520         if batch_sizes is None:
    521             result = _VF.lstm(input, hx, self._get_flat_weights(), self.bias, self.num_layers,

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/rnn.py in check_forward_args(self, input, hidden, batch_sizes)
    488     def check_forward_args(self, input, hidden, batch_sizes):
    489         # type: (Tensor, Tuple[Tensor, Tensor], Optional[Tensor]) -> None
--> 490         self.check_input(input, batch_sizes)
    491         expected_hidden_size = self.get_expected_hidden_size(input, batch_sizes)
    492 

~/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/rnn.py in check_input(self, input, batch_sizes)
    147             raise RuntimeError(
    148                 'input must have {} dimensions, got {}'.format(
--> 149                     expected_input_dim, input.dim()))
    150         if self.input_size != input.size(-1):
    151             raise RuntimeError(

RuntimeError: input must have 3 dimensions, got 2