@PremalMatalia: you’re right. I couldn’t identify the source of error (perhaps a memory limit on Colab?).
BTW, I reworked the notebook because it had some sub-optimal stuff (for example, preprocessing the whole dataset for each fork). Also, I added some explanations. Now it works ok and it’s faster than before, and I hope it’s more readable.
Check it back:

  
      

      colab.research.google.com
  

  
    

Google Colaboratory 203