prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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
  
  
  </issue>
  <code>
  [start of keras/utils/visualize_util.py]
  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 of keras/utils/visualize_util.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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'):
  
verification_info: {"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"}]}