You can check the doc, .retain_grad() means that it will save the .grad field when doing backward. So you have to call it before the .backward() for it to be useful.

prints tensor(1.) may be this is right.

Yes this is expected.
b is the output so its gradient is the default backward value we use for scalar: 1.