attaching the LM to the instance instead of the class - works but is slow for both fork and spawn since each process rebuilds the LM
adding the language model as an optional parameter if a spawn context is found and rebuilding the model container - also works, but again is slow since each process needs its own copy
As far as I can tell this is often going to be faster than the multiprocessing options that I've tried and also allows for just not using a pool at all (new feature for these functions)
This PR also does a bit of refactoring and improving some type hints.
Summary: Other things I've tried include
This PR also does a bit of refactoring and improving some type hints.