Turning a function into an nn.Module

I see that there are no modules in nn to e.g. add a constant. I understand that it is easy to do in an imperative way, but it feels like there should also be a way to do simple arithmetics within nn.Sequential.
In LuaTorch, there were nn.Add/nn.Mul, etc. Do I miss some obvious way to define a state-less nn.Module in one line? Something like

nn.Sequential(
    ...,
    nn.ModuleFromFunction(lambda x : x + 2),
)

to add a constant 2 to the result of the previous operation, where the function passed to nn.ModuleFromFunction implements nn.Module.forward(). Or is it not a common use case?

https://pytorch.org/tutorials/beginner/nn_tutorial.html

Yes, class Lambda from the nn.Sequential example is exactly what I was describing. Is it / should it be included in Pytorch?

That might be a good feature request. Since it’s quite easy to implement, I’m unsure if it’ll land in the core, but I still think it’s worth discussing it.
Would you mind creating this request on GitHub and describing your use case etc.?