That is true if b is an independent variable, but we have b=g(x,y). So, effectively, we have f(x,y,g(x,y)). The question is how to compute df/dg. I guess it’s more of a math question than a Pytorch question. Yet, I wondered if it can answered by writing a piece of Pytorch code. Any ideas?