The last stack trace is most likely pointing to the wrong line of code and the CUDA_LAUNCH_BLOCKING env var is not working properly inside your notebook.
I would generally recommend to export the notebook as a python script and run it via:
CUDA_LAUNCH_BLOCKING=1 python script.py args

to get the proper line of code.
That being said, I don’t quite understand the last statement.
Could you post a code snippet showing when the assert is triggered?