I've tried to use code regions https://www.jetbrains.com/help/pycharm-edu/code-folding.html#surrounding_with_comments , folded some regions and restarted PyCharm.
When IDE has been restarted, all folded code regions were expanded.
How to save code folding at PyCharm restart?
For example, Visual Studio 2019 saves code folding at IDE restart.