Thank you for your quick reply.
I tried and it works. But another problem occurs. After I copied the gradient from A to B, how can I apply the gradient to B so it will be updated with the gradient? I tried opt_B.step() but it doesn’t work.