-- linear layer with multple copies of parameters
-- which parameters to use is set by model_ids
function linear_multi(sz_in, sz_out, model_ids, input)
    if g_opts.nmodels == 1 then
        return nn.Linear(sz_in, sz_out)(input)
    end
    local weight_lut = nn.LookupTable(g_opts.nmodels, sz_in * sz_out)(model_ids)
    weight_lut.data.module.updateGradInput = function(self, input) return input end
    local bias_lut = nn.LookupTable(g_opts.nmodels, sz_out)(model_ids)
    bias_lut.data.module.updateGradInput = function(self, input) return input end
    local weight_view = nn.View(sz_out, sz_in):setNumInputDims(1)(weight_lut)
    input = nn.View(-1, 1):setNumInputDims(1)(input)
    local out = nn.MM(false, false)({weight_view, input})
    out = nn.View(-1):setNumInputDims(2)(out)
    out = nn.CAddTable()({out, bias_lut})
    out.weight_lut = weight_lut
    out.bias_lut = bias_lut
    return out
end

The above code implements a simple matrix multiplication in Torch. I am trying to translate this into PyTorch. Since LookupTable is deprecated. How do you approach this?
Thanks in advance.