prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  DictDataset throws an internal error only in Python 3.
  The following code throws an internal error only in Python 3 environment with the latest version of Chainer. (3.0.0b1, 8bcac6f)
  ```py
  from chainer.datasets import DictDataset
  
  def main():
      a = range(10)
      b = range(10, 20)
      dataset = DictDataset(x=a, y=b)
      print(dataset[0:5])
  
  if __name__ == '__main__':
      main()
  ```
  
  In Python 3.6.1,
  ```sh
  $ python --version
   Python 3.6.1
  $ python poc.py
   Traceback (most recent call last):
    File "poc.py", line 12, in <module>
      main()
    File "poc.py", line 8, in main
      print(dataset[0:5])
    File "/home/igarashi/projects/chainer/chainer/datasets/dict_dataset.py", line 34, in __getitem__
      length = len(six.itervalues(batches).next())
  AttributeError: 'dict_valueiterator' object has no attribute 'next'
  ```
  
  In Python 2.7.13, 
  ```sh
  $ python --version
   Python 2.7.13
  $ python poc.py
   [{'y': 10, 'x': 0}, {'y': 11, 'x': 1}, {'y': 12, 'x': 2}, {'y': 13, 'x': 3}, {'y': 14, 'x': 4}]
  ```
  
  It is because an instance of `six.Iterator` doesn't have `next()` method in the Python 3 environment.
  [Reference](http://pythonhosted.org/six/#six.Iterator)
  
  
  </issue>
  <code>
  [start of chainer/datasets/dict_dataset.py]
  1 import six
  2 
  3 
  4 class DictDataset(object):
  5 
  6     """Dataset of a dictionary of datasets.
  7 
  8     It combines multiple datasets into one dataset. Each example is represented
  9     by a dictionary mapping a key to an example of the corresponding dataset.
  10 
  11     Args:
  12         datasets: Underlying datasets. The keys are used as the keys of each
  13             example. All datasets must have the same length.
  14 
  15     """
  16 
  17     def __init__(self, **datasets):
  18         if not datasets:
  19             raise ValueError('no datasets are given')
  20         length = None
  21         for key, dataset in six.iteritems(datasets):
  22             if length is None:
  23                 length = len(dataset)
  24             elif length != len(dataset):
  25                 raise ValueError(
  26                     'dataset length conflicts at "{}"'.format(key))
  27         self._datasets = datasets
  28         self._length = length
  29 
  30     def __getitem__(self, index):
  31         batches = {key: dataset[index]
  32                    for key, dataset in six.iteritems(self._datasets)}
  33         if isinstance(index, slice):
  34             length = len(six.itervalues(batches).next())
  35             return [{key: batch[i] for key, batch in six.iteritems(batches)}
  36                     for i in six.moves.range(length)]
  37         else:
  38             return batches
  39 
  40     def __len__(self):
  41         return self._length
  42
  [end of chainer/datasets/dict_dataset.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/chainer/datasets/dict_dataset.py b/chainer/datasets/dict_dataset.py
  --- a/chainer/datasets/dict_dataset.py
  +++ b/chainer/datasets/dict_dataset.py
  @@ -31,7 +31,7 @@
           batches = {key: dataset[index]
                      for key, dataset in six.iteritems(self._datasets)}
           if isinstance(index, slice):
  -            length = len(six.itervalues(batches).next())
  +            length = len(six.next(six.itervalues(batches)))
               return [{key: batch[i] for key, batch in six.iteritems(batches)}
                       for i in six.moves.range(length)]
           else:
  
verification_info: {"golden_diff": "diff --git a/chainer/datasets/dict_dataset.py b/chainer/datasets/dict_dataset.py\n--- a/chainer/datasets/dict_dataset.py\n+++ b/chainer/datasets/dict_dataset.py\n@@ -31,7 +31,7 @@\n         batches = {key: dataset[index]\n                    for key, dataset in six.iteritems(self._datasets)}\n         if isinstance(index, slice):\n-            length = len(six.itervalues(batches).next())\n+            length = len(six.next(six.itervalues(batches)))\n             return [{key: batch[i] for key, batch in six.iteritems(batches)}\n                     for i in six.moves.range(length)]\n         else:\n", "issue": "DictDataset throws an internal error only in Python 3.\nThe following code throws an internal error only in Python 3 environment with the latest version of Chainer. (3.0.0b1, 8bcac6f)\r\n```py\r\nfrom chainer.datasets import DictDataset\r\n\r\ndef main():\r\n    a = range(10)\r\n    b = range(10, 20)\r\n    dataset = DictDataset(x=a, y=b)\r\n    print(dataset[0:5])\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n\r\nIn Python 3.6.1,\r\n```sh\r\n$ python --version\r\n Python 3.6.1\r\n$ python poc.py\r\n Traceback (most recent call last):\r\n  File \"poc.py\", line 12, in <module>\r\n    main()\r\n  File \"poc.py\", line 8, in main\r\n    print(dataset[0:5])\r\n  File \"/home/igarashi/projects/chainer/chainer/datasets/dict_dataset.py\", line 34, in __getitem__\r\n    length = len(six.itervalues(batches).next())\r\nAttributeError: 'dict_valueiterator' object has no attribute 'next'\r\n```\r\n\r\nIn Python 2.7.13, \r\n```sh\r\n$ python --version\r\n Python 2.7.13\r\n$ python poc.py\r\n [{'y': 10, 'x': 0}, {'y': 11, 'x': 1}, {'y': 12, 'x': 2}, {'y': 13, 'x': 3}, {'y': 14, 'x': 4}]\r\n```\r\n\r\nIt is because an instance of `six.Iterator` doesn't have `next()` method in the Python 3 environment.\r\n[Reference](http://pythonhosted.org/six/#six.Iterator)\r\n\n", "before_files": [{"content": "import six\n\n\nclass DictDataset(object):\n\n    \"\"\"Dataset of a dictionary of datasets.\n\n    It combines multiple datasets into one dataset. Each example is represented\n    by a dictionary mapping a key to an example of the corresponding dataset.\n\n    Args:\n        datasets: Underlying datasets. The keys are used as the keys of each\n            example. All datasets must have the same length.\n\n    \"\"\"\n\n    def __init__(self, **datasets):\n        if not datasets:\n            raise ValueError('no datasets are given')\n        length = None\n        for key, dataset in six.iteritems(datasets):\n            if length is None:\n                length = len(dataset)\n            elif length != len(dataset):\n                raise ValueError(\n                    'dataset length conflicts at \"{}\"'.format(key))\n        self._datasets = datasets\n        self._length = length\n\n    def __getitem__(self, index):\n        batches = {key: dataset[index]\n                   for key, dataset in six.iteritems(self._datasets)}\n        if isinstance(index, slice):\n            length = len(six.itervalues(batches).next())\n            return [{key: batch[i] for key, batch in six.iteritems(batches)}\n                    for i in six.moves.range(length)]\n        else:\n            return batches\n\n    def __len__(self):\n        return self._length\n", "path": "chainer/datasets/dict_dataset.py"}]}