prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  What is "'Chainer' object has no attribute 'infer'
  2018-03-04 14:09:23,638 (util.py:64 WorkerThread2) ERROR - TeleBot: "AttributeError occurred, args=("'Chainer' object has no attribute 'infer'",)
  Traceback (most recent call last):
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py", line 58, in run
      task(*args, **kwargs)
    File "/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py", line 48, in handle_inference
      pred = model.infer(context)
  AttributeError: 'Chainer' object has no attribute 'infer'
  "
  2018-03-04 14:09:23.638 ERROR in 'TeleBot'['util'] at line 64: AttributeError occurred, args=("'Chainer' object has no attribute 'infer'",)
  Traceback (most recent call last):
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py", line 58, in run
      task(*args, **kwargs)
    File "/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py", line 48, in handle_inference
      pred = model.infer(context)
  AttributeError: 'Chainer' object has no attribute 'infer'
  
  Traceback (most recent call last):
    File "deep.py", line 60, in <module>
      main()
    File "deep.py", line 56, in main
      interact_model_by_telegram(pipeline_config_path, token)
    File "/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py", line 58, in interact_model_by_telegram
      init_bot_for_model(token, model)
    File "/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py", line 52, in init_bot_for_model
      bot.polling()
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/__init__.py", line 264, in polling
      self.__threaded_polling(none_stop, interval, timeout)
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/__init__.py", line 288, in __threaded_polling
      self.worker_pool.raise_exceptions()
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py", line 107, in raise_exceptions
      six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/six.py", line 693, in reraise
      raise value
    File "/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py", line 58, in run
      task(*args, **kwargs)
    File "/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py", line 48, in handle_inference
      pred = model.infer(context)
  AttributeError: 'Chainer' object has no attribute 'infer'
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `telegram_utils/telegram_ui.py`
  Content:
  ```
  1 """
  2 Copyright 2017 Neural Networks and Deep Learning lab, MIPT
  3 
  4 Licensed under the Apache License, Version 2.0 (the "License");
  5 you may not use this file except in compliance with the License.
  6 You may obtain a copy of the License at
  7 
  8     http://www.apache.org/licenses/LICENSE-2.0
  9 
  10 Unless required by applicable law or agreed to in writing, software
  11 distributed under the License is distributed on an "AS IS" BASIS,
  12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 See the License for the specific language governing permissions and
  14 limitations under the License.
  15 """
  16 import telebot
  17 
  18 from deeppavlov.core.common.file import read_json
  19 from deeppavlov.core.commands.infer import build_model_from_config
  20 
  21 
  22 def init_bot_for_model(token, model):
  23     bot = telebot.TeleBot(token)
  24 
  25     model_name = type(model).__name__
  26     models_info = read_json('../telegram_utils/models_info.json')
  27     model_info = models_info[model_name] if model_name in models_info else models_info['@default']
  28 
  29     @bot.message_handler(commands=['start'])
  30     def send_start_message(message):
  31         chat_id = message.chat.id
  32         out_message = model_info['start_message']
  33         if hasattr(model, 'reset'):
  34             model.reset()
  35         bot.send_message(chat_id, out_message)
  36 
  37     @bot.message_handler(commands=['help'])
  38     def send_help_message(message):
  39         chat_id = message.chat.id
  40         out_message = model_info['help_message']
  41         bot.send_message(chat_id, out_message)
  42 
  43     @bot.message_handler()
  44     def handle_inference(message):
  45         chat_id = message.chat.id
  46         context = message.text
  47 
  48         pred = model.infer(context)
  49         reply_message = str(pred)
  50         bot.send_message(chat_id, reply_message)
  51 
  52     bot.polling()
  53 
  54 
  55 def interact_model_by_telegram(config_path, token):
  56     config = read_json(config_path)
  57     model = build_model_from_config(config)
  58     init_bot_for_model(token, model)
  59
  ```
  --- 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/telegram_utils/telegram_ui.py b/telegram_utils/telegram_ui.py
  --- a/telegram_utils/telegram_ui.py
  +++ b/telegram_utils/telegram_ui.py
  @@ -45,7 +45,7 @@
           chat_id = message.chat.id
           context = message.text
   
  -        pred = model.infer(context)
  +        pred = model(context)
           reply_message = str(pred)
           bot.send_message(chat_id, reply_message)
  
verification_info: {"golden_diff": "diff --git a/telegram_utils/telegram_ui.py b/telegram_utils/telegram_ui.py\n--- a/telegram_utils/telegram_ui.py\n+++ b/telegram_utils/telegram_ui.py\n@@ -45,7 +45,7 @@\n         chat_id = message.chat.id\n         context = message.text\n \n-        pred = model.infer(context)\n+        pred = model(context)\n         reply_message = str(pred)\n         bot.send_message(chat_id, reply_message)\n", "issue": "What is \"'Chainer' object has no attribute 'infer'\n2018-03-04 14:09:23,638 (util.py:64 WorkerThread2) ERROR - TeleBot: \"AttributeError occurred, args=(\"'Chainer' object has no attribute 'infer'\",)\r\nTraceback (most recent call last):\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py\", line 58, in run\r\n    task(*args, **kwargs)\r\n  File \"/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py\", line 48, in handle_inference\r\n    pred = model.infer(context)\r\nAttributeError: 'Chainer' object has no attribute 'infer'\r\n\"\r\n2018-03-04 14:09:23.638 ERROR in 'TeleBot'['util'] at line 64: AttributeError occurred, args=(\"'Chainer' object has no attribute 'infer'\",)\r\nTraceback (most recent call last):\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py\", line 58, in run\r\n    task(*args, **kwargs)\r\n  File \"/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py\", line 48, in handle_inference\r\n    pred = model.infer(context)\r\nAttributeError: 'Chainer' object has no attribute 'infer'\r\n\r\nTraceback (most recent call last):\r\n  File \"deep.py\", line 60, in <module>\r\n    main()\r\n  File \"deep.py\", line 56, in main\r\n    interact_model_by_telegram(pipeline_config_path, token)\r\n  File \"/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py\", line 58, in interact_model_by_telegram\r\n    init_bot_for_model(token, model)\r\n  File \"/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py\", line 52, in init_bot_for_model\r\n    bot.polling()\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/__init__.py\", line 264, in polling\r\n    self.__threaded_polling(none_stop, interval, timeout)\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/__init__.py\", line 288, in __threaded_polling\r\n    self.worker_pool.raise_exceptions()\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py\", line 107, in raise_exceptions\r\n    six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/six.py\", line 693, in reraise\r\n    raise value\r\n  File \"/Users/developer/DeepPavlov/lib/python3.6/site-packages/telebot/util.py\", line 58, in run\r\n    task(*args, **kwargs)\r\n  File \"/Users/developer/Project/DeepPavlov/telegram_utils/telegram_ui.py\", line 48, in handle_inference\r\n    pred = model.infer(context)\r\nAttributeError: 'Chainer' object has no attribute 'infer'\r\n\n", "before_files": [{"content": "\"\"\"\nCopyright 2017 Neural Networks and Deep Learning lab, MIPT\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\"\"\"\nimport telebot\n\nfrom deeppavlov.core.common.file import read_json\nfrom deeppavlov.core.commands.infer import build_model_from_config\n\n\ndef init_bot_for_model(token, model):\n    bot = telebot.TeleBot(token)\n\n    model_name = type(model).__name__\n    models_info = read_json('../telegram_utils/models_info.json')\n    model_info = models_info[model_name] if model_name in models_info else models_info['@default']\n\n    @bot.message_handler(commands=['start'])\n    def send_start_message(message):\n        chat_id = message.chat.id\n        out_message = model_info['start_message']\n        if hasattr(model, 'reset'):\n            model.reset()\n        bot.send_message(chat_id, out_message)\n\n    @bot.message_handler(commands=['help'])\n    def send_help_message(message):\n        chat_id = message.chat.id\n        out_message = model_info['help_message']\n        bot.send_message(chat_id, out_message)\n\n    @bot.message_handler()\n    def handle_inference(message):\n        chat_id = message.chat.id\n        context = message.text\n\n        pred = model.infer(context)\n        reply_message = str(pred)\n        bot.send_message(chat_id, reply_message)\n\n    bot.polling()\n\n\ndef interact_model_by_telegram(config_path, token):\n    config = read_json(config_path)\n    model = build_model_from_config(config)\n    init_bot_for_model(token, model)\n", "path": "telegram_utils/telegram_ui.py"}], "after_files": [{"content": "\"\"\"\nCopyright 2017 Neural Networks and Deep Learning lab, MIPT\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\"\"\"\nimport telebot\n\nfrom deeppavlov.core.common.file import read_json\nfrom deeppavlov.core.commands.infer import build_model_from_config\n\n\ndef init_bot_for_model(token, model):\n    bot = telebot.TeleBot(token)\n\n    model_name = type(model).__name__\n    models_info = read_json('../telegram_utils/models_info.json')\n    model_info = models_info[model_name] if model_name in models_info else models_info['@default']\n\n    @bot.message_handler(commands=['start'])\n    def send_start_message(message):\n        chat_id = message.chat.id\n        out_message = model_info['start_message']\n        if hasattr(model, 'reset'):\n            model.reset()\n        bot.send_message(chat_id, out_message)\n\n    @bot.message_handler(commands=['help'])\n    def send_help_message(message):\n        chat_id = message.chat.id\n        out_message = model_info['help_message']\n        bot.send_message(chat_id, out_message)\n\n    @bot.message_handler()\n    def handle_inference(message):\n        chat_id = message.chat.id\n        context = message.text\n\n        pred = model(context)\n        reply_message = str(pred)\n        bot.send_message(chat_id, reply_message)\n\n    bot.polling()\n\n\ndef interact_model_by_telegram(config_path, token):\n    config = read_json(config_path)\n    model = build_model_from_config(config)\n    init_bot_for_model(token, model)\n", "path": "telegram_utils/telegram_ui.py"}]}