An optical chip that can train machine learning hardware