North Korean soldiers sent to support Russian forces against Ukraine have been withdrawn after suffering heavy casualties.