Let's move these imports to the top of the function, seems to be [preferred](https://stackoverflow.com/questions/1024049/is-it-pythonic-to-import-inside-functions)

Another good reason is that it makes clear any circular import errors, which should be refactored