Please read Getting good answers to your questions and follow it as a guide to edit this and for making future posts. A lot of that advice is general for such forums.
Plus, please consider if you are posting in an appropriate forum. I see a lot of Python code and this wouldn’t belong here unless you tried running it directly with Python or IPython, the more traditional way, and it didn’t cause whatever issue you think you are seeing that you didn’t tell us about.
If this were an appropriate post what you provided isn’t useable. Please, also learn about how to post code at such sites as this in useable form. To help you with that see about ‘block code formatting’ here. (Or see about ‘fenced code blocks’ here. They are both the same thing if you look into the details.