Does the following work?
class Encoder(nn.Module):
    def __init__(self, in_dim, hidsz):
        super(Encoder, self).__init__()
        self.lut = nn.Embedding(in_dim, hidsz) # in_dim agents, returns (batchsz, x, hidsz)
        self.bias = nn.Parameter(torch.randn(hidsz))

    def forward(self, input):
        x = self.lut(input)
        x = torch.sum(x, 3) # XXX: the original version is sum(2) but lua is 1-indexed
        x = x.add(self.bias) # XXX:
        return x