It’s not an automatic approach and I’m not sure if auto-correct changed the phrasing back in 2018 or what I meant back then.
In any case, you would have these approaches:

calculate the output activation shapes and set the right values
run a dummy forward pass, print the activation shapes, and set the expected values
use the Lazy* layers to avoid setting the in_features manually

Your approach would have the same shortcomings described before. I.e. be careful when to pass the parameters to the optimizer and make sure the parameters are moved to the right device.