The US has transferred thousands of detainees linked to the group from Syria to Iraq.