Electron spin resonance of Nd3+ and Gd3+ in d-band intermetallic compounds