def METHOD_NAME(graph, filename=None):
  filename = write_graph_script(graph, filename)
  #module_name = graph.name
  py_module_name = "_".join(["nndct", random_str()])
  spec = importlib.util.spec_from_file_location(py_module_name, filename)
  py_module = importlib.util.module_from_spec(spec)
  sys.modules[py_module_name] = py_module
  spec.loader.exec_module(py_module)
  rebuilt_model = py_module.__dict__[graph.name]()
  api_utils.connect_module_with_graph(rebuilt_model, graph)
  return rebuilt_model, filename