Thanks, It worked now using linear operators. However, I would like to note that, if the module is incorporated in the network, it has to add .cuda or to(device) that is a difference with other operators likes conv, softmax, sigmod, batchnorm…It means we have to change nn.Linear(4, 1) to nn.Linear(4, 1).cuda() in the __init__ function alothugh I have used learn_vector().cuda() before. I am using pythorch version 1.0.
import torch
import torch.nn as nn
class learn_vector(nn.Module):
    def __init__(self, in_channels, out_channels):
        super(learn_vector, self).__init__()
        lins = [nn.Linear(4, 1).cuda() for _ in range(8)]
    def forward(self, x):
        print(x.size())
        outputs = torch.stack([lin(x[:, idx]) for idx, lin in enumerate(lins)], 1)
        return outputs