Software-defined nanophotonic devices and systems empowered by machine learning