The UK Labour Party secured a narrow win in the key by-election constituency of Batley and Spen in Northern England.