It could be wrong as I’m not a programmer, just occasionally “juggle” scripts and not sure to interpret your question correctly, but I think it works as in the example linked below by @AkiR.
If you know the source of the module (PyQt5.QtWidgets, PyQt5.QtGui, PyQt5.QtCore, whatever), then it should “import” into your code that way, and you should then be able to use it. However, if you don’t know the source/origin, then I don’t know to say where you can find it. However, I may be completely wrong.
The example from AkiR:
If you don’t use it anyway, I recommend the plugin “Krita-PythonPluginDeveloperTools” by @KnowZero:
Also, the links (first, second and last) in this topic might be helpful if you don’t know anything about it:
The “Krita Scripting School” should be known to you, I guess?
https://scripting.krita.org/lessons/introduction
Michelist