Reduce the boilerplate needed to bind properties (#81576)
We implement a template and we fill it up via CRTP. This heavily reduces
the ammount of repeated code.
Just testing the waters here. If you like this idea, I can easily extend
this idea to cover many of the properties that we currently implement.
N.b. It'd be nice to have proper `if constexpr` support for this one,
but here we are.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81576
Approved by: https://github.com/ezyang