prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Logger is not passed to translator
  When building the translator, there is a logger created but not passed to the translator:
  https://github.com/OpenNMT/OpenNMT-py/blob/35cf4f0ae774a4aa500318879a1a4d53408ac129/onmt/bin/translate.py#L18
  This results in a log file that only contains a single entry:
  https://github.com/OpenNMT/OpenNMT-py/blob/35cf4f0ae774a4aa500318879a1a4d53408ac129/onmt/bin/translate.py#L24
  
  </issue>
  <code>
  [start of onmt/bin/translate.py]
  1 #!/usr/bin/env python
  2 # -*- coding: utf-8 -*-
  3 
  4 from __future__ import unicode_literals
  5 
  6 from onmt.utils.logging import init_logger
  7 from onmt.utils.misc import split_corpus
  8 from onmt.translate.translator import build_translator
  9 
  10 import onmt.opts as opts
  11 from onmt.utils.parse import ArgumentParser
  12 
  13 
  14 def translate(opt):
  15     ArgumentParser.validate_translate_opts(opt)
  16     logger = init_logger(opt.log_file)
  17 
  18     translator = build_translator(opt, report_score=True)
  19     src_shards = split_corpus(opt.src, opt.shard_size)
  20     tgt_shards = split_corpus(opt.tgt, opt.shard_size)
  21     shard_pairs = zip(src_shards, tgt_shards)
  22 
  23     for i, (src_shard, tgt_shard) in enumerate(shard_pairs):
  24         logger.info("Translating shard %d." % i)
  25         translator.translate(
  26             src=src_shard,
  27             tgt=tgt_shard,
  28             src_dir=opt.src_dir,
  29             batch_size=opt.batch_size,
  30             batch_type=opt.batch_type,
  31             attn_debug=opt.attn_debug,
  32             align_debug=opt.align_debug
  33             )
  34 
  35 
  36 def _get_parser():
  37     parser = ArgumentParser(description='translate.py')
  38 
  39     opts.config_opts(parser)
  40     opts.translate_opts(parser)
  41     return parser
  42 
  43 
  44 def main():
  45     parser = _get_parser()
  46 
  47     opt = parser.parse_args()
  48     translate(opt)
  49 
  50 
  51 if __name__ == "__main__":
  52     main()
  53
  [end of onmt/bin/translate.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/onmt/bin/translate.py b/onmt/bin/translate.py
  --- a/onmt/bin/translate.py
  +++ b/onmt/bin/translate.py
  @@ -15,7 +15,7 @@
       ArgumentParser.validate_translate_opts(opt)
       logger = init_logger(opt.log_file)
   
  -    translator = build_translator(opt, report_score=True)
  +    translator = build_translator(opt, logger=logger, report_score=True)
       src_shards = split_corpus(opt.src, opt.shard_size)
       tgt_shards = split_corpus(opt.tgt, opt.shard_size)
       shard_pairs = zip(src_shards, tgt_shards)
  
verification_info: {"golden_diff": "diff --git a/onmt/bin/translate.py b/onmt/bin/translate.py\n--- a/onmt/bin/translate.py\n+++ b/onmt/bin/translate.py\n@@ -15,7 +15,7 @@\n     ArgumentParser.validate_translate_opts(opt)\n     logger = init_logger(opt.log_file)\n \n-    translator = build_translator(opt, report_score=True)\n+    translator = build_translator(opt, logger=logger, report_score=True)\n     src_shards = split_corpus(opt.src, opt.shard_size)\n     tgt_shards = split_corpus(opt.tgt, opt.shard_size)\n     shard_pairs = zip(src_shards, tgt_shards)\n", "issue": "Logger is not passed to translator\nWhen building the translator, there is a logger created but not passed to the translator:\r\nhttps://github.com/OpenNMT/OpenNMT-py/blob/35cf4f0ae774a4aa500318879a1a4d53408ac129/onmt/bin/translate.py#L18\r\nThis results in a log file that only contains a single entry:\r\nhttps://github.com/OpenNMT/OpenNMT-py/blob/35cf4f0ae774a4aa500318879a1a4d53408ac129/onmt/bin/translate.py#L24\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import unicode_literals\n\nfrom onmt.utils.logging import init_logger\nfrom onmt.utils.misc import split_corpus\nfrom onmt.translate.translator import build_translator\n\nimport onmt.opts as opts\nfrom onmt.utils.parse import ArgumentParser\n\n\ndef translate(opt):\n    ArgumentParser.validate_translate_opts(opt)\n    logger = init_logger(opt.log_file)\n\n    translator = build_translator(opt, report_score=True)\n    src_shards = split_corpus(opt.src, opt.shard_size)\n    tgt_shards = split_corpus(opt.tgt, opt.shard_size)\n    shard_pairs = zip(src_shards, tgt_shards)\n\n    for i, (src_shard, tgt_shard) in enumerate(shard_pairs):\n        logger.info(\"Translating shard %d.\" % i)\n        translator.translate(\n            src=src_shard,\n            tgt=tgt_shard,\n            src_dir=opt.src_dir,\n            batch_size=opt.batch_size,\n            batch_type=opt.batch_type,\n            attn_debug=opt.attn_debug,\n            align_debug=opt.align_debug\n            )\n\n\ndef _get_parser():\n    parser = ArgumentParser(description='translate.py')\n\n    opts.config_opts(parser)\n    opts.translate_opts(parser)\n    return parser\n\n\ndef main():\n    parser = _get_parser()\n\n    opt = parser.parse_args()\n    translate(opt)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "onmt/bin/translate.py"}]}