Bethe free energy and extrinsics in approximate message passing