Imported from https://github.com/rickyHong/tfoptflow-repl