prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ProgressMonitor (Trainer plugin) prints incorrect progress value and percentage
  Code to replicate behaviour, extract of [jupyter notebook](https://github.com/recastrodiaz/courses/blob/master/deeplearning1/nbs/lesson1-pytorch.ipynb) In [9]:
  
  ```PYTHON
  t = trainer.Trainer(model, criterion, optimizer, train_loader)
  t.register_plugin(trainer.plugins.ProgressMonitor())
  t.register_plugin(trainer.plugins.AccuracyMonitor())
  t.register_plugin(trainer.plugins.LossMonitor())
  t.register_plugin(trainer.plugins.TimeMonitor())
  t.register_plugin(trainer.plugins.Logger(['progress', 'accuracy', 'loss', 'time']))
  
  epochs = 1
  t.run(epochs)
  ```
  
  Prints:
  ```LOG
  progress: 23000/360 (6388.89%)	accuracy: 100.00%  (99.31%)	loss: 0.0058  (0.0368)	time: 705ms    (1249ms)
  ```
  
  Should print instead:
  ```
  progress: 360/360 (100.00%)	accuracy: 100.00%  (99.31%)	loss: 0.0058  (0.0368)	time: 705ms    (1249ms)
  ```
  
  I'll send over a PR for this.
  
  </issue>
  <code>
  [start of torch/utils/trainer/plugins/progress.py]
  1 from .plugin import Plugin
  2 
  3 
  4 class ProgressMonitor(Plugin):
  5     stat_name = 'progress'
  6 
  7     def __init__(self):
  8         super(ProgressMonitor, self).__init__([(1, 'iteration'), (1, 'epoch')])
  9 
  10     def register(self, trainer):
  11         self.trainer = trainer
  12         stats = self.trainer.stats.setdefault(self.stat_name, {})
  13         stats['samples_used'] = 0
  14         stats['epoch_size'] = len(trainer.dataset)
  15         stats['log_iter_fields'] = [
  16             '{samples_used}/{epoch_size}',
  17             '({percent:.2f}%)'
  18         ]
  19 
  20     def iteration(self, iteration, input, *args):
  21         stats = self.trainer.stats.setdefault(self.stat_name, {})
  22         stats['samples_used'] += input.size(0)
  23         stats['percent'] = 100. * stats['samples_used'] / stats['epoch_size']
  24 
  25     def epoch(self, *args):
  26         stats = self.trainer.stats.setdefault(self.stat_name, {})
  27         stats['samples_used'] = 0
  28         stats['percent'] = 0
  29
  [end of torch/utils/trainer/plugins/progress.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/torch/utils/trainer/plugins/progress.py b/torch/utils/trainer/plugins/progress.py
  --- a/torch/utils/trainer/plugins/progress.py
  +++ b/torch/utils/trainer/plugins/progress.py
  @@ -19,7 +19,7 @@
   
       def iteration(self, iteration, input, *args):
           stats = self.trainer.stats.setdefault(self.stat_name, {})
  -        stats['samples_used'] += input.size(0)
  +        stats['samples_used'] += 1
           stats['percent'] = 100. * stats['samples_used'] / stats['epoch_size']
   
       def epoch(self, *args):
  
verification_info: {"golden_diff": "diff --git a/torch/utils/trainer/plugins/progress.py b/torch/utils/trainer/plugins/progress.py\n--- a/torch/utils/trainer/plugins/progress.py\n+++ b/torch/utils/trainer/plugins/progress.py\n@@ -19,7 +19,7 @@\n \n     def iteration(self, iteration, input, *args):\n         stats = self.trainer.stats.setdefault(self.stat_name, {})\n-        stats['samples_used'] += input.size(0)\n+        stats['samples_used'] += 1\n         stats['percent'] = 100. * stats['samples_used'] / stats['epoch_size']\n \n     def epoch(self, *args):\n", "issue": "ProgressMonitor (Trainer plugin) prints incorrect progress value and percentage\nCode to replicate behaviour, extract of [jupyter notebook](https://github.com/recastrodiaz/courses/blob/master/deeplearning1/nbs/lesson1-pytorch.ipynb) In [9]:\r\n\r\n```PYTHON\r\nt = trainer.Trainer(model, criterion, optimizer, train_loader)\r\nt.register_plugin(trainer.plugins.ProgressMonitor())\r\nt.register_plugin(trainer.plugins.AccuracyMonitor())\r\nt.register_plugin(trainer.plugins.LossMonitor())\r\nt.register_plugin(trainer.plugins.TimeMonitor())\r\nt.register_plugin(trainer.plugins.Logger(['progress', 'accuracy', 'loss', 'time']))\r\n\r\nepochs = 1\r\nt.run(epochs)\r\n```\r\n\r\nPrints:\r\n```LOG\r\nprogress: 23000/360 (6388.89%)\taccuracy: 100.00%  (99.31%)\tloss: 0.0058  (0.0368)\ttime: 705ms    (1249ms)\r\n```\r\n\r\nShould print instead:\r\n```\r\nprogress: 360/360 (100.00%)\taccuracy: 100.00%  (99.31%)\tloss: 0.0058  (0.0368)\ttime: 705ms    (1249ms)\r\n```\r\n\r\nI'll send over a PR for this.\n", "before_files": [{"content": "from .plugin import Plugin\n\n\nclass ProgressMonitor(Plugin):\n    stat_name = 'progress'\n\n    def __init__(self):\n        super(ProgressMonitor, self).__init__([(1, 'iteration'), (1, 'epoch')])\n\n    def register(self, trainer):\n        self.trainer = trainer\n        stats = self.trainer.stats.setdefault(self.stat_name, {})\n        stats['samples_used'] = 0\n        stats['epoch_size'] = len(trainer.dataset)\n        stats['log_iter_fields'] = [\n            '{samples_used}/{epoch_size}',\n            '({percent:.2f}%)'\n        ]\n\n    def iteration(self, iteration, input, *args):\n        stats = self.trainer.stats.setdefault(self.stat_name, {})\n        stats['samples_used'] += input.size(0)\n        stats['percent'] = 100. * stats['samples_used'] / stats['epoch_size']\n\n    def epoch(self, *args):\n        stats = self.trainer.stats.setdefault(self.stat_name, {})\n        stats['samples_used'] = 0\n        stats['percent'] = 0\n", "path": "torch/utils/trainer/plugins/progress.py"}]}