This code is from a larger research codebase I have that hasn't been released. I just recently decided to break this chunk off, as I haven't seen something similar out there which retrofits existing Pytorch modules to make them directly loadable from a config file.