Meta will cut thousands of jobs next month as it spends more than ever on artificial intelligence (AI) projects.