Hi,
So the problem comes from the fact that you perform some computations with your parameters in the __init__ method and then use these results at every forward. This means that the part of the computations you do in __init__ is shared for every forward and thus the error because you backward in the part of the graph multiple times.
I think the problem is that you perform computations in the __init__ that should be in the forward.
Indeed, the biases for each section will change when you learnt slope will change. So you cannot precompute them.