prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  ERROR: 'BaseTrainer' object has no attribute 'args'
  I followed the instructions on the https://learnpythia.readthedocs.io/ to setup. I seem to have everything installed, and I could run the collab notebook locally. 
  
  However, when I am trying to run the below command to try out inferences:
  
  python tools/run.py --tasks vqa --datasets textvqa --model lorra --config configs/vqa/textvqa/lorra.yml \
  --run_type val --evalai_inference 1 --resume_file data/models/lorra_best.pth
  
  I am getting below error:
  
  
  }
  2019-05-29T20:25:41 INFO: Loading tasks and data
  2019-05-29T20:25:44 INFO: CUDA Device 0 is: GeForce GTX 1080 Ti
  2019-05-29T20:25:46 INFO: Torch version is: 1.0.0
  2019-05-29T20:25:46 ERROR: 'BaseTrainer' object has no attribute 'args'
  Traceback (most recent call last):
    File "tools/run.py", line 94, in <module>
      run()
    File "tools/run.py", line 82, in run
      trainer.load()
    File "/root/pythia/pythia/trainers/base_trainer.py", line 46, in load
      self.load_extras()
    File "/root/pythia/pythia/trainers/base_trainer.py", line 139, in load_extras
      self.checkpoint = Checkpoint(self)
    File "/root/pythia/pythia/utils/checkpoint.py", line 28, in __init__
      self.ckpt_foldername += foldername_from_config_override(self.trainer.args)
  AttributeError: 'BaseTrainer' object has no attribute 'args'
  
  
  I seem to be doing something wrong, any help would be great. I didn't change any code or config yet.
  
  </issue>
  <code>
  [start of pythia/utils/build_utils.py]
  1 # Copyright (c) Facebook, Inc. and its affiliates.
  2 import torch
  3 import warnings
  4 
  5 from pythia.utils.configuration import Configuration
  6 from pythia.common.registry import registry
  7 from pythia.utils.general import get_optimizer_parameters
  8 
  9 
  10 def build_trainer(args, *rest, **kwargs):
  11     configuration = Configuration(args.config)
  12 
  13     # Update with the config override if passed
  14     configuration.override_with_cmd_config(args.config_override)
  15 
  16     # Now, update with opts args that were passed
  17     configuration.override_with_cmd_opts(args.opts)
  18 
  19     # Finally, update with args that were specifically passed
  20     # as arguments
  21     configuration.update_with_args(args)
  22     configuration.freeze()
  23 
  24     config = configuration.get_config()
  25     registry.register("config", config)
  26     registry.register("configuration", configuration)
  27 
  28     trainer_type = config.training_parameters.trainer
  29     trainer_cls = registry.get_trainer_class(trainer_type)
  30     return trainer_cls(config)
  31 
  32 
  33 def build_model(config):
  34     model_name = config.model
  35 
  36     model_class = registry.get_model_class(model_name)
  37 
  38     if model_class is None:
  39         registry.get("writer").write("No model registered for name: %s" % model_name)
  40     model = model_class(config)
  41 
  42     if hasattr(model, "build"):
  43         model.build()
  44         model.init_losses_and_metrics()
  45 
  46     return model
  47 
  48 
  49 def build_optimizer(model, config):
  50     optimizer_config = config.optimizer_attributes
  51     if not hasattr(optimizer_config, "type"):
  52         raise ValueError(
  53             "Optimizer attributes must have a 'type' key "
  54             "specifying the type of optimizer. "
  55             "(Custom or PyTorch)"
  56         )
  57     optimizer_type = optimizer_config.type
  58 
  59     if not hasattr(optimizer_config, "params"):
  60         warnings.warn(
  61             "optimizer attributes has no params defined, defaulting to {}."
  62         )
  63 
  64     params = getattr(optimizer_config, "params", {})
  65 
  66     if hasattr(torch.optim, optimizer_type):
  67         optimizer_class = getattr(torch.optim, optimizer_type)
  68     else:
  69         optimizer_class = registry.get_optimizer_class(optimizer_type)
  70         if optimizer_class is None:
  71             raise ValueError(
  72                 "No optimizer class of type {} present in "
  73                 "either torch or registered to registry"
  74             )
  75 
  76     parameters = get_optimizer_parameters(model, config)
  77     optimizer = optimizer_class(parameters, **params)
  78     return optimizer
  79
  [end of pythia/utils/build_utils.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/pythia/utils/build_utils.py b/pythia/utils/build_utils.py
  --- a/pythia/utils/build_utils.py
  +++ b/pythia/utils/build_utils.py
  @@ -27,7 +27,12 @@
   
       trainer_type = config.training_parameters.trainer
       trainer_cls = registry.get_trainer_class(trainer_type)
  -    return trainer_cls(config)
  +    trainer_obj = trainer_cls(config)
  +
  +    # Set args as an attribute for future use
  +    setattr(trainer_obj, 'args', args)
  +
  +    return trainer_obj
   
   
   def build_model(config):
  
verification_info: {"golden_diff": "diff --git a/pythia/utils/build_utils.py b/pythia/utils/build_utils.py\n--- a/pythia/utils/build_utils.py\n+++ b/pythia/utils/build_utils.py\n@@ -27,7 +27,12 @@\n \n     trainer_type = config.training_parameters.trainer\n     trainer_cls = registry.get_trainer_class(trainer_type)\n-    return trainer_cls(config)\n+    trainer_obj = trainer_cls(config)\n+\n+    # Set args as an attribute for future use\n+    setattr(trainer_obj, 'args', args)\n+\n+    return trainer_obj\n \n \n def build_model(config):\n", "issue": "ERROR: 'BaseTrainer' object has no attribute 'args'\nI followed the instructions on the https://learnpythia.readthedocs.io/ to setup. I seem to have everything installed, and I could run the collab notebook locally. \r\n\r\nHowever, when I am trying to run the below command to try out inferences:\r\n\r\npython tools/run.py --tasks vqa --datasets textvqa --model lorra --config configs/vqa/textvqa/lorra.yml \\\r\n--run_type val --evalai_inference 1 --resume_file data/models/lorra_best.pth\r\n\r\nI am getting below error:\r\n\r\n\r\n}\r\n2019-05-29T20:25:41 INFO: Loading tasks and data\r\n2019-05-29T20:25:44 INFO: CUDA Device 0 is: GeForce GTX 1080 Ti\r\n2019-05-29T20:25:46 INFO: Torch version is: 1.0.0\r\n2019-05-29T20:25:46 ERROR: 'BaseTrainer' object has no attribute 'args'\r\nTraceback (most recent call last):\r\n  File \"tools/run.py\", line 94, in <module>\r\n    run()\r\n  File \"tools/run.py\", line 82, in run\r\n    trainer.load()\r\n  File \"/root/pythia/pythia/trainers/base_trainer.py\", line 46, in load\r\n    self.load_extras()\r\n  File \"/root/pythia/pythia/trainers/base_trainer.py\", line 139, in load_extras\r\n    self.checkpoint = Checkpoint(self)\r\n  File \"/root/pythia/pythia/utils/checkpoint.py\", line 28, in __init__\r\n    self.ckpt_foldername += foldername_from_config_override(self.trainer.args)\r\nAttributeError: 'BaseTrainer' object has no attribute 'args'\r\n\r\n\r\nI seem to be doing something wrong, any help would be great. I didn't change any code or config yet.\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates.\nimport torch\nimport warnings\n\nfrom pythia.utils.configuration import Configuration\nfrom pythia.common.registry import registry\nfrom pythia.utils.general import get_optimizer_parameters\n\n\ndef build_trainer(args, *rest, **kwargs):\n    configuration = Configuration(args.config)\n\n    # Update with the config override if passed\n    configuration.override_with_cmd_config(args.config_override)\n\n    # Now, update with opts args that were passed\n    configuration.override_with_cmd_opts(args.opts)\n\n    # Finally, update with args that were specifically passed\n    # as arguments\n    configuration.update_with_args(args)\n    configuration.freeze()\n\n    config = configuration.get_config()\n    registry.register(\"config\", config)\n    registry.register(\"configuration\", configuration)\n\n    trainer_type = config.training_parameters.trainer\n    trainer_cls = registry.get_trainer_class(trainer_type)\n    return trainer_cls(config)\n\n\ndef build_model(config):\n    model_name = config.model\n\n    model_class = registry.get_model_class(model_name)\n\n    if model_class is None:\n        registry.get(\"writer\").write(\"No model registered for name: %s\" % model_name)\n    model = model_class(config)\n\n    if hasattr(model, \"build\"):\n        model.build()\n        model.init_losses_and_metrics()\n\n    return model\n\n\ndef build_optimizer(model, config):\n    optimizer_config = config.optimizer_attributes\n    if not hasattr(optimizer_config, \"type\"):\n        raise ValueError(\n            \"Optimizer attributes must have a 'type' key \"\n            \"specifying the type of optimizer. \"\n            \"(Custom or PyTorch)\"\n        )\n    optimizer_type = optimizer_config.type\n\n    if not hasattr(optimizer_config, \"params\"):\n        warnings.warn(\n            \"optimizer attributes has no params defined, defaulting to {}.\"\n        )\n\n    params = getattr(optimizer_config, \"params\", {})\n\n    if hasattr(torch.optim, optimizer_type):\n        optimizer_class = getattr(torch.optim, optimizer_type)\n    else:\n        optimizer_class = registry.get_optimizer_class(optimizer_type)\n        if optimizer_class is None:\n            raise ValueError(\n                \"No optimizer class of type {} present in \"\n                \"either torch or registered to registry\"\n            )\n\n    parameters = get_optimizer_parameters(model, config)\n    optimizer = optimizer_class(parameters, **params)\n    return optimizer\n", "path": "pythia/utils/build_utils.py"}]}