I think it is here since if I comment this part out, the training finishes without problem.
For the training of first model there is no error. It is only when we come to train the second model with the adjusted data point weights that the error comes. I wondered if that is because the re-weighted loss is attached to the previous model.
Thanks