prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Quickstart AttributeError: 'HogwildWorld' object has no attribute 'acts'
  **Bug description**
  When going through the ParlAI [quickstart](https://parl.ai/docs/tutorial_quick.html#install), I got the following error:
  
  ``` python
  Traceback (most recent call last):
    File "examples/interactive.py", line 18, in <module>
      interactive(opt, print_parser=parser)
    File "/root/ParlAI/parlai/scripts/interactive.py", line 68, in interactive
      agent = create_agent(opt, requireModelExists=True)
    File "/root/ParlAI/parlai/core/agents.py", line 683, in create_agent
      model = load_agent_module(opt)
    File "/root/ParlAI/parlai/core/agents.py", line 548, in load_agent_module
      return model_class(new_opt)
    File "/root/ParlAI/parlai/agents/memnn/memnn.py", line 86, in __init__
      super().__init__(opt, shared)
    File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 135, in __init__
      super().__init__(opt, shared)
    File "/root/ParlAI/parlai/core/torch_agent.py", line 737, in __init__
      self.set_interactive_mode(opt['interactive_mode'], shared)
    File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 206, in set_interactive_mode
      path = self.get_task_candidates_path()
    File "/root/ParlAI/parlai/core/torch_ranker_agent.py", line 230, in get_task_candidates_path
      build_cands(opt)
    File "/root/ParlAI/parlai/scripts/build_candidates.py", line 47, in build_cands
      acts = world.get_acts()[0]
    File "/root/ParlAI/parlai/core/worlds.py", line 162, in get_acts
      return self.acts
  AttributeError: 'HogwildWorld' object has no attribute 'acts'
  ```
  
  **While running**
  ```python
  python examples/interactive.py -mf /tmp/babi_memnn -ecands vocab
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `parlai/scripts/build_candidates.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 
  3 # Copyright (c) Facebook, Inc. and its affiliates.
  4 # This source code is licensed under the MIT license found in the
  5 # LICENSE file in the root directory of this source tree.
  6 """Build the candidate responses for a retrieval model.
  7 
  8 Examples
  9 --------
  10 
  11 .. code-block:: shell
  12 
  13   python build_candidates.py -t convai2 --outfile /tmp/cands.txt
  14 """
  15 
  16 from parlai.core.params import ParlaiParser
  17 from parlai.agents.repeat_label.repeat_label import RepeatLabelAgent
  18 from parlai.core.worlds import create_task
  19 from parlai.core.utils import TimeLogger
  20 import random
  21 import tempfile
  22 
  23 
  24 def build_cands(opt):
  25     # create repeat label agent and assign it to the specified task
  26     agent = RepeatLabelAgent(opt)
  27     world = create_task(opt, agent)
  28     if opt['outfile'] is None:
  29         outfile = tempfile.mkstemp(
  30             prefix='{}_{}_'.format(opt['task'], opt['datatype']), suffix='.txt'
  31         )[1]
  32     else:
  33         outfile = opt['outfile']
  34 
  35     if opt.get('num_examples', -1) == -1:
  36         num_examples = world.num_examples()
  37     else:
  38         num_examples = opt['num_examples']
  39     log_timer = TimeLogger()
  40 
  41     print('[ starting to build candidates from task.. (ex:' + str(num_examples) + ')]')
  42     print('[ saving output to {} ]'.format(outfile))
  43     cands = []
  44     for _ in range(num_examples):
  45         world.parley()
  46         # We get the acts of the first agent, which is the teacher.
  47         acts = world.get_acts()[0]
  48         if isinstance(acts, dict):
  49             # We turn into a batch of 1 example, in case batching is being used.
  50             acts = [acts]
  51         for a in acts:
  52             candidate = a.get('labels', a.get('eval_labels', None))
  53             if candidate is not None:
  54                 candidate = candidate[0]
  55                 cands.append(candidate)
  56         if log_timer.time() > opt['log_every_n_secs']:
  57             text, _log = log_timer.log(world.total_parleys, world.num_examples())
  58             print(text)
  59         if world.epoch_done():
  60             print('EPOCH DONE')
  61             break
  62     fw = open(outfile, 'w')
  63     fw.write('\n'.join(cands))
  64     fw.close()
  65 
  66 
  67 def main():
  68     random.seed(42)
  69     # Get command line arguments
  70     parser = ParlaiParser()
  71     parser.add_argument(
  72         '-n',
  73         '--num-examples',
  74         default=-1,
  75         type=int,
  76         help='Total number of exs to convert, -1 to convert all examples',
  77     )
  78     parser.add_argument(
  79         '-of',
  80         '--outfile',
  81         default=None,
  82         type=str,
  83         help='Output file where to save, by default will be created in /tmp',
  84     )
  85     parser.add_argument('-ltim', '--log-every-n-secs', type=float, default=2)
  86     parser.set_defaults(datatype='train:evalmode')
  87     opt = parser.parse_args()
  88     build_cands(opt)
  89 
  90 
  91 if __name__ == '__main__':
  92     main()
  93
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/parlai/scripts/build_candidates.py b/parlai/scripts/build_candidates.py
  --- a/parlai/scripts/build_candidates.py
  +++ b/parlai/scripts/build_candidates.py
  @@ -23,6 +23,9 @@
   
   def build_cands(opt):
       # create repeat label agent and assign it to the specified task
  +    if opt['numthreads'] > 1:
  +        # Broken in hogwild mode. Just fall back to single processing mode
  +        opt['numthreads'] = 1
       agent = RepeatLabelAgent(opt)
       world = create_task(opt, agent)
       if opt['outfile'] is None:
  
verification_info: {"golden_diff": "diff --git a/parlai/scripts/build_candidates.py b/parlai/scripts/build_candidates.py\n--- a/parlai/scripts/build_candidates.py\n+++ b/parlai/scripts/build_candidates.py\n@@ -23,6 +23,9 @@\n \n def build_cands(opt):\n     # create repeat label agent and assign it to the specified task\n+    if opt['numthreads'] > 1:\n+        # Broken in hogwild mode. Just fall back to single processing mode\n+        opt['numthreads'] = 1\n     agent = RepeatLabelAgent(opt)\n     world = create_task(opt, agent)\n     if opt['outfile'] is None:\n", "issue": "Quickstart AttributeError: 'HogwildWorld' object has no attribute 'acts'\n**Bug description**\r\nWhen going through the ParlAI [quickstart](https://parl.ai/docs/tutorial_quick.html#install), I got the following error:\r\n\r\n``` python\r\nTraceback (most recent call last):\r\n  File \"examples/interactive.py\", line 18, in <module>\r\n    interactive(opt, print_parser=parser)\r\n  File \"/root/ParlAI/parlai/scripts/interactive.py\", line 68, in interactive\r\n    agent = create_agent(opt, requireModelExists=True)\r\n  File \"/root/ParlAI/parlai/core/agents.py\", line 683, in create_agent\r\n    model = load_agent_module(opt)\r\n  File \"/root/ParlAI/parlai/core/agents.py\", line 548, in load_agent_module\r\n    return model_class(new_opt)\r\n  File \"/root/ParlAI/parlai/agents/memnn/memnn.py\", line 86, in __init__\r\n    super().__init__(opt, shared)\r\n  File \"/root/ParlAI/parlai/core/torch_ranker_agent.py\", line 135, in __init__\r\n    super().__init__(opt, shared)\r\n  File \"/root/ParlAI/parlai/core/torch_agent.py\", line 737, in __init__\r\n    self.set_interactive_mode(opt['interactive_mode'], shared)\r\n  File \"/root/ParlAI/parlai/core/torch_ranker_agent.py\", line 206, in set_interactive_mode\r\n    path = self.get_task_candidates_path()\r\n  File \"/root/ParlAI/parlai/core/torch_ranker_agent.py\", line 230, in get_task_candidates_path\r\n    build_cands(opt)\r\n  File \"/root/ParlAI/parlai/scripts/build_candidates.py\", line 47, in build_cands\r\n    acts = world.get_acts()[0]\r\n  File \"/root/ParlAI/parlai/core/worlds.py\", line 162, in get_acts\r\n    return self.acts\r\nAttributeError: 'HogwildWorld' object has no attribute 'acts'\r\n```\r\n\r\n**While running**\r\n```python\r\npython examples/interactive.py -mf /tmp/babi_memnn -ecands vocab\r\n```\r\n\n", "before_files": [{"content": "#!/usr/bin/env python3\n\n# Copyright (c) Facebook, Inc. and its affiliates.\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"Build the candidate responses for a retrieval model.\n\nExamples\n--------\n\n.. code-block:: shell\n\n  python build_candidates.py -t convai2 --outfile /tmp/cands.txt\n\"\"\"\n\nfrom parlai.core.params import ParlaiParser\nfrom parlai.agents.repeat_label.repeat_label import RepeatLabelAgent\nfrom parlai.core.worlds import create_task\nfrom parlai.core.utils import TimeLogger\nimport random\nimport tempfile\n\n\ndef build_cands(opt):\n    # create repeat label agent and assign it to the specified task\n    agent = RepeatLabelAgent(opt)\n    world = create_task(opt, agent)\n    if opt['outfile'] is None:\n        outfile = tempfile.mkstemp(\n            prefix='{}_{}_'.format(opt['task'], opt['datatype']), suffix='.txt'\n        )[1]\n    else:\n        outfile = opt['outfile']\n\n    if opt.get('num_examples', -1) == -1:\n        num_examples = world.num_examples()\n    else:\n        num_examples = opt['num_examples']\n    log_timer = TimeLogger()\n\n    print('[ starting to build candidates from task.. (ex:' + str(num_examples) + ')]')\n    print('[ saving output to {} ]'.format(outfile))\n    cands = []\n    for _ in range(num_examples):\n        world.parley()\n        # We get the acts of the first agent, which is the teacher.\n        acts = world.get_acts()[0]\n        if isinstance(acts, dict):\n            # We turn into a batch of 1 example, in case batching is being used.\n            acts = [acts]\n        for a in acts:\n            candidate = a.get('labels', a.get('eval_labels', None))\n            if candidate is not None:\n                candidate = candidate[0]\n                cands.append(candidate)\n        if log_timer.time() > opt['log_every_n_secs']:\n            text, _log = log_timer.log(world.total_parleys, world.num_examples())\n            print(text)\n        if world.epoch_done():\n            print('EPOCH DONE')\n            break\n    fw = open(outfile, 'w')\n    fw.write('\\n'.join(cands))\n    fw.close()\n\n\ndef main():\n    random.seed(42)\n    # Get command line arguments\n    parser = ParlaiParser()\n    parser.add_argument(\n        '-n',\n        '--num-examples',\n        default=-1,\n        type=int,\n        help='Total number of exs to convert, -1 to convert all examples',\n    )\n    parser.add_argument(\n        '-of',\n        '--outfile',\n        default=None,\n        type=str,\n        help='Output file where to save, by default will be created in /tmp',\n    )\n    parser.add_argument('-ltim', '--log-every-n-secs', type=float, default=2)\n    parser.set_defaults(datatype='train:evalmode')\n    opt = parser.parse_args()\n    build_cands(opt)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "parlai/scripts/build_candidates.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\n# Copyright (c) Facebook, Inc. and its affiliates.\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"Build the candidate responses for a retrieval model.\n\nExamples\n--------\n\n.. code-block:: shell\n\n  python build_candidates.py -t convai2 --outfile /tmp/cands.txt\n\"\"\"\n\nfrom parlai.core.params import ParlaiParser\nfrom parlai.agents.repeat_label.repeat_label import RepeatLabelAgent\nfrom parlai.core.worlds import create_task\nfrom parlai.core.utils import TimeLogger\nimport random\nimport tempfile\n\n\ndef build_cands(opt):\n    # create repeat label agent and assign it to the specified task\n    if opt['numthreads'] > 1:\n        # Broken in hogwild mode. Just fall back to single processing mode\n        opt['numthreads'] = 1\n    agent = RepeatLabelAgent(opt)\n    world = create_task(opt, agent)\n    if opt['outfile'] is None:\n        outfile = tempfile.mkstemp(\n            prefix='{}_{}_'.format(opt['task'], opt['datatype']), suffix='.txt'\n        )[1]\n    else:\n        outfile = opt['outfile']\n\n    if opt.get('num_examples', -1) == -1:\n        num_examples = world.num_examples()\n    else:\n        num_examples = opt['num_examples']\n    log_timer = TimeLogger()\n\n    print('[ starting to build candidates from task.. (ex:' + str(num_examples) + ')]')\n    print('[ saving output to {} ]'.format(outfile))\n    cands = []\n    for _ in range(num_examples):\n        world.parley()\n        # We get the acts of the first agent, which is the teacher.\n        acts = world.get_acts()[0]\n        if isinstance(acts, dict):\n            # We turn into a batch of 1 example, in case batching is being used.\n            acts = [acts]\n        for a in acts:\n            candidate = a.get('labels', a.get('eval_labels', None))\n            if candidate is not None:\n                candidate = candidate[0]\n                cands.append(candidate)\n        if log_timer.time() > opt['log_every_n_secs']:\n            text, _log = log_timer.log(world.total_parleys, world.num_examples())\n            print(text)\n        if world.epoch_done():\n            print('EPOCH DONE')\n            break\n    fw = open(outfile, 'w')\n    fw.write('\\n'.join(cands))\n    fw.close()\n\n\ndef main():\n    random.seed(42)\n    # Get command line arguments\n    parser = ParlaiParser()\n    parser.add_argument(\n        '-n',\n        '--num-examples',\n        default=-1,\n        type=int,\n        help='Total number of exs to convert, -1 to convert all examples',\n    )\n    parser.add_argument(\n        '-of',\n        '--outfile',\n        default=None,\n        type=str,\n        help='Output file where to save, by default will be created in /tmp',\n    )\n    parser.add_argument('-ltim', '--log-every-n-secs', type=float, default=2)\n    parser.set_defaults(datatype='train:evalmode')\n    opt = parser.parse_args()\n    build_cands(opt)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "parlai/scripts/build_candidates.py"}]}