Move module imports that are not absolutely required into a function instead of at the top level so that we don't spew the diagnostic message in scenarios like `--help` or usage errors.