prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Reproducibility using seeds
  Been running some experiments, and it seems I cannot get the same reproducible result even when setting numpy and tensorflow seeds at the top of the script like
  
  ```
  np.random.seed(72)
  tf.set_random_seed(72)
  ```
  
  Naturally, either I'm setting them wrong or I'm missing a RNG. I call Param.randomize() and Model.optimize(), and they seem to be the only sources of randomness at the moment (and I'm not even sure about the latter) so one of them is likely the culprit. Is there any way to either set the seed appropriately without messing with the source code or maybe adding an option allowing seeds to be set in the future?
  
  </issue>
  <code>
  [start of gpflow/training/optimizer.py]
  1 # Copyright 2017 Artem Artemev @awav
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 # http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 # pylint: disable=no-self-use
  16 # pylint: disable=too-few-public-methods
  17 
  18 import abc
  19 
  20 
  21 class Optimizer:
  22     @abc.abstractmethod
  23     def make_optimize_tensor(self, model, session=None, var_list=None, **kwargs):
  24         """
  25         Make optimization tensor.
  26         The `make_optimize_tensor` method builds optimization tensor and initializes
  27         all necessary variables created by optimizer.
  28 
  29             :param model: GPflow model.
  30             :param session: Tensorflow session.
  31             :param var_list: List of variables for training.
  32             :param kwargs: Dictionary of extra parameters necessary for building
  33                 optimizer tensor.
  34             :return: Tensorflow optimization tensor or operation.
  35         """
  36         pass
  37 
  38     @abc.abstractmethod
  39     def minimize(self, model, session=None, var_list=None, feed_dict=None,
  40                  maxiter=1000, initialize=True, anchor=True, **kwargs):
  41         raise NotImplementedError()
  42 
  43     @staticmethod
  44     def _gen_var_list(model, var_list):
  45         var_list = var_list or []
  46         return list(set(model.trainable_tensors).union(var_list))
  47 
  48     @staticmethod
  49     def _gen_feed_dict(model, feed_dict):
  50         feed_dict = feed_dict or {}
  51         model_feeds = {} if model.feeds is None else model.feeds
  52         feed_dict.update(model_feeds)
  53         if feed_dict == {}:
  54             return None
  55         return feed_dict
  56
  [end of gpflow/training/optimizer.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/gpflow/training/optimizer.py b/gpflow/training/optimizer.py
  --- a/gpflow/training/optimizer.py
  +++ b/gpflow/training/optimizer.py
  @@ -43,7 +43,8 @@
       @staticmethod
       def _gen_var_list(model, var_list):
           var_list = var_list or []
  -        return list(set(model.trainable_tensors).union(var_list))
  +        all_vars = list(set(model.trainable_tensors).union(var_list))
  +        return sorted(all_vars, key=lambda x: x.name)
   
       @staticmethod
       def _gen_feed_dict(model, feed_dict):
  
verification_info: {"golden_diff": "diff --git a/gpflow/training/optimizer.py b/gpflow/training/optimizer.py\n--- a/gpflow/training/optimizer.py\n+++ b/gpflow/training/optimizer.py\n@@ -43,7 +43,8 @@\n     @staticmethod\n     def _gen_var_list(model, var_list):\n         var_list = var_list or []\n-        return list(set(model.trainable_tensors).union(var_list))\n+        all_vars = list(set(model.trainable_tensors).union(var_list))\n+        return sorted(all_vars, key=lambda x: x.name)\n \n     @staticmethod\n     def _gen_feed_dict(model, feed_dict):\n", "issue": "Reproducibility using seeds\nBeen running some experiments, and it seems I cannot get the same reproducible result even when setting numpy and tensorflow seeds at the top of the script like\r\n\r\n```\r\nnp.random.seed(72)\r\ntf.set_random_seed(72)\r\n```\r\n\r\nNaturally, either I'm setting them wrong or I'm missing a RNG. I call Param.randomize() and Model.optimize(), and they seem to be the only sources of randomness at the moment (and I'm not even sure about the latter) so one of them is likely the culprit. Is there any way to either set the seed appropriately without messing with the source code or maybe adding an option allowing seeds to be set in the future?\n", "before_files": [{"content": "# Copyright 2017 Artem Artemev @awav\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n# pylint: disable=no-self-use\n# pylint: disable=too-few-public-methods\n\nimport abc\n\n\nclass Optimizer:\n    @abc.abstractmethod\n    def make_optimize_tensor(self, model, session=None, var_list=None, **kwargs):\n        \"\"\"\n        Make optimization tensor.\n        The `make_optimize_tensor` method builds optimization tensor and initializes\n        all necessary variables created by optimizer.\n\n            :param model: GPflow model.\n            :param session: Tensorflow session.\n            :param var_list: List of variables for training.\n            :param kwargs: Dictionary of extra parameters necessary for building\n                optimizer tensor.\n            :return: Tensorflow optimization tensor or operation.\n        \"\"\"\n        pass\n\n    @abc.abstractmethod\n    def minimize(self, model, session=None, var_list=None, feed_dict=None,\n                 maxiter=1000, initialize=True, anchor=True, **kwargs):\n        raise NotImplementedError()\n\n    @staticmethod\n    def _gen_var_list(model, var_list):\n        var_list = var_list or []\n        return list(set(model.trainable_tensors).union(var_list))\n\n    @staticmethod\n    def _gen_feed_dict(model, feed_dict):\n        feed_dict = feed_dict or {}\n        model_feeds = {} if model.feeds is None else model.feeds\n        feed_dict.update(model_feeds)\n        if feed_dict == {}:\n            return None\n        return feed_dict\n", "path": "gpflow/training/optimizer.py"}]}