Tesla is using AI to create potentially lucrative products — autonomous cars and humanoid robots — in a bid by CEO Elon Musk to make it the most valuable company in the world.