Tesla has laid off thousands of employees to refocus its operations on AI-driven self-driving technology.