We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
keras.utils.visualize_util
line 9: if type(model) == Sequential
Global name Sequential is not defined
line 25 elif type(model) == Graph:
Global name Graph is not defined


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `keras/utils/visualize_util.py`
Content:
```
1 import pydot
2 # old pydot will not work with python3, must use one
3 # that works with python3 such as pydot2 or pydot
4 
5 
6 def plot(model, to_file='model.png'):
7 
8     graph = pydot.Dot(graph_type='digraph')
9     if type(model) == Sequential:
10         previous_node = None
11         written_nodes = []
12         n = 1
13         for node in model.get_config()['layers']:
14             # append number in case layers have same name to differentiate
15             if (node['name'] + str(n)) in written_nodes:
16                 n += 1
17             current_node = pydot.Node(node['name'] + str(n))
18             written_nodes.append(node['name'] + str(n))
19             graph.add_node(current_node)
20             if previous_node:
21                 graph.add_edge(pydot.Edge(previous_node, current_node))
22             previous_node = current_node
23         graph.write_png(to_file)
24 
25     elif type(model) == Graph:
26         # don't need to append number for names since all nodes labeled
27         for input_node in model.input_config:
28             graph.add_node(pydot.Node(input_node['name']))
29 
30         # intermediate and output nodes have input defined
31         for layer_config in [model.node_config, model.output_config]:
32             for node in layer_config:
33                 graph.add_node(pydot.Node(node['name']))
34                 # possible to have multiple 'inputs' vs 1 'input'
35                 if node['inputs']:
36                     for e in node['inputs']:
37                         graph.add_edge(pydot.Edge(e, node['name']))
38                 else:
39                     graph.add_edge(pydot.Edge(node['input'], node['name']))
40 
41         graph.write_png(to_file)
42
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/keras/utils/visualize_util.py b/keras/utils/visualize_util.py
--- a/keras/utils/visualize_util.py
+++ b/keras/utils/visualize_util.py
@@ -1,7 +1,7 @@
 import pydot
 # old pydot will not work with python3, must use one
 # that works with python3 such as pydot2 or pydot
-
+from keras.models import Sequential, Graph
 
 def plot(model, to_file='model.png'):

{"golden_diff": "diff --git a/keras/utils/visualize_util.py b/keras/utils/visualize_util.py\n--- a/keras/utils/visualize_util.py\n+++ b/keras/utils/visualize_util.py\n@@ -1,7 +1,7 @@\n import pydot\n # old pydot will not work with python3, must use one\n # that works with python3 such as pydot2 or pydot\n-\n+from keras.models import Sequential, Graph\n \n def plot(model, to_file='model.png'):\n", "issue": "keras.utils.visualize_util\nline 9: if type(model) == Sequential\nGlobal name Sequential is not defined\nline 25 elif type(model) == Graph:\nGlobal name Graph is not defined\n\n", "before_files": [{"content": "import pydot\n# old pydot will not work with python3, must use one\n# that works with python3 such as pydot2 or pydot\n\n\ndef plot(model, to_file='model.png'):\n\n    graph = pydot.Dot(graph_type='digraph')\n    if type(model) == Sequential:\n        previous_node = None\n        written_nodes = []\n        n = 1\n        for node in model.get_config()['layers']:\n            # append number in case layers have same name to differentiate\n            if (node['name'] + str(n)) in written_nodes:\n                n += 1\n            current_node = pydot.Node(node['name'] + str(n))\n            written_nodes.append(node['name'] + str(n))\n            graph.add_node(current_node)\n            if previous_node:\n                graph.add_edge(pydot.Edge(previous_node, current_node))\n            previous_node = current_node\n        graph.write_png(to_file)\n\n    elif type(model) == Graph:\n        # don't need to append number for names since all nodes labeled\n        for input_node in model.input_config:\n            graph.add_node(pydot.Node(input_node['name']))\n\n        # intermediate and output nodes have input defined\n        for layer_config in [model.node_config, model.output_config]:\n            for node in layer_config:\n                graph.add_node(pydot.Node(node['name']))\n                # possible to have multiple 'inputs' vs 1 'input'\n                if node['inputs']:\n                    for e in node['inputs']:\n                        graph.add_edge(pydot.Edge(e, node['name']))\n                else:\n                    graph.add_edge(pydot.Edge(node['input'], node['name']))\n\n        graph.write_png(to_file)\n", "path": "keras/utils/visualize_util.py"}], "after_files": [{"content": "import pydot\n# old pydot will not work with python3, must use one\n# that works with python3 such as pydot2 or pydot\nfrom keras.models import Sequential, Graph\n\ndef plot(model, to_file='model.png'):\n\n    graph = pydot.Dot(graph_type='digraph')\n    if type(model) == Sequential:\n        previous_node = None\n        written_nodes = []\n        n = 1\n        for node in model.get_config()['layers']:\n            # append number in case layers have same name to differentiate\n            if (node['name'] + str(n)) in written_nodes:\n                n += 1\n            current_node = pydot.Node(node['name'] + str(n))\n            written_nodes.append(node['name'] + str(n))\n            graph.add_node(current_node)\n            if previous_node:\n                graph.add_edge(pydot.Edge(previous_node, current_node))\n            previous_node = current_node\n        graph.write_png(to_file)\n\n    elif type(model) == Graph:\n        # don't need to append number for names since all nodes labeled\n        for input_node in model.input_config:\n            graph.add_node(pydot.Node(input_node['name']))\n\n        # intermediate and output nodes have input defined\n        for layer_config in [model.node_config, model.output_config]:\n            for node in layer_config:\n                graph.add_node(pydot.Node(node['name']))\n                # possible to have multiple 'inputs' vs 1 'input'\n                if node['inputs']:\n                    for e in node['inputs']:\n                        graph.add_edge(pydot.Edge(e, node['name']))\n                else:\n                    graph.add_edge(pydot.Edge(node['input'], node['name']))\n\n        graph.write_png(to_file)\n", "path": "keras/utils/visualize_util.py"}]}