Check if variable is part of graph

I’m trying to debug my code. I predict two variables A, B and compute losses L1(A) and L2(B) on them. However, the way the network currently behaves is as if L2 is affecting A, even though it shouldn’t according to my code. I want to make absolutely sure that during backpropagation, A is not affected by L2. I thought one easy way of doing this is to check if A is part of the graph which produces L2.

How would one proceed to check this?

I’m still having this problem. Can anyone help?