We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error while training model with config "ner_conll2003_pos"
I'm trying to train a NER model using "train_model(configs.ner.ner_conll2003_pos)" on Colab. There are only three things I've changed in original ner_conll2003_pos.json file: number of epochs = 1, DOWNLOADS_PATH and MODELS_PATH. After I start, it terminates with this error:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-5-683c58afa1f4> in <module>()
      1 from deeppavlov import configs, train_model
----> 2 ner_model = train_model(configs.ner.ner_conll2003_pos)

/usr/local/lib/python3.6/dist-packages/deeppavlov/__init__.py in train_model(config, download, recursive)
     29     # TODO: make better
     30     def train_model(config: [str, Path, dict], download: bool = False, recursive: bool = False) -> Chainer:
---> 31         train_evaluate_model_from_config(config, download=download, recursive=recursive)
     32         return build_model(config, load_trained=True)
     33 

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/commands/train.py in train_evaluate_model_from_config(config, iterator, to_train, evaluation_targets, to_validate, download, start_epoch_num, recursive)
    119 
    120     if to_train:
--> 121         trainer.train(iterator)
    122 
    123     res = {}

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in train(self, iterator)
    292         if callable(getattr(self._chainer, 'train_on_batch', None)):
    293             try:
--> 294                 self.train_on_batches(iterator)
    295             except KeyboardInterrupt:
    296                 log.info('Stopped training')

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in train_on_batches(self, iterator)
    232         self.start_time = time.time()
    233         if self.validate_first:
--> 234             self._validate(iterator)
    235 
    236         while True:

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in _validate(self, iterator, tensorboard_tag, tensorboard_index)
    142         self._send_event(event_name='before_validation')
    143         report = self.test(iterator.gen_batches(self.batch_size, data_type='valid', shuffle=False),
--> 144                            start_time=self.start_time)
    145 
    146         report['epochs_done'] = self.epoch

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/fit_trainer.py in test(self, data, metrics, start_time, show_examples)
    204         for x, y_true in data:
    205             examples += len(x)
--> 206             y_predicted = list(self._chainer.compute(list(x), list(y_true), targets=expected_outputs))
    207             if len(expected_outputs) == 1:
    208                 y_predicted = [y_predicted]

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/common/chainer.py in compute(self, x, y, targets)
    141             in_params += self.in_y
    142 
--> 143         return self._compute(*args, pipe=pipe, param_names=in_params, targets=targets)
    144 
    145     def __call__(self, *args):

/usr/local/lib/python3.6/dist-packages/deeppavlov/core/common/chainer.py in _compute(***failed resolving arguments***)
    167                 res = component(**dict(zip(in_keys, x)))
    168             else:
--> 169                 res = component(*x)
    170             if len(out_params) == 1:
    171                 mem[out_params[0]] = res

/usr/local/lib/python3.6/dist-packages/deeppavlov/models/preprocessors/one_hotter.py in __call__(self, batch, **kwargs)
     68                 one_hotted_utt = np.sum(one_hotted_utt, axis=0)
     69 
---> 70             one_hotted_batch.append(one_hotted_utt)
     71 
     72         if self._pad_zeros:

UnboundLocalError: local variable 'one_hotted_utt' referenced before assignment
-----------------------------------------------------------------------------------------------

How can I fix this? 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `deeppavlov/models/preprocessors/one_hotter.py`
Content:
```
1 # Copyright 2017 Neural Networks and Deep Learning lab, MIPT
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from typing import List, Union
16 
17 import numpy as np
18 
19 from deeppavlov.core.common.errors import ConfigError
20 from deeppavlov.core.common.registry import register
21 from deeppavlov.core.data.utils import zero_pad
22 from deeppavlov.core.models.component import Component
23 
24 
25 @register('one_hotter')
26 class OneHotter(Component):
27     """
28     One-hot featurizer with zero-padding.
29     If ``single_vector``, return the only vector per sample which can have several elements equal to ``1``.
30 
31     Parameters:
32         depth: the depth for one-hotting
33         pad_zeros: whether to pad elements of batch with zeros
34         single_vector: whether to return one vector for the sample (sum of each one-hotted vectors)
35     """
36     def __init__(self, depth: int, pad_zeros: bool = False,
37                  single_vector=False, *args, **kwargs):
38         self._depth = depth
39         self._pad_zeros = pad_zeros
40         self.single_vector = single_vector
41         if self._pad_zeros and self.single_vector:
42             raise ConfigError("Cannot perform ``single_vector`` with zero padding for OneHotter")
43 
44     def __call__(self, batch: List[List[int]], **kwargs) -> Union[List[List[np.ndarray]], List[np.ndarray]]:
45         """
46         Convert given batch of list of labels to one-hot representation of the batch.
47 
48         Args:
49             batch: list of samples, where each sample is a list of integer labels.
50             **kwargs: additional arguments
51 
52         Returns:
53             if ``single_vector``, list of one-hot representations of each sample,
54             otherwise, list of lists of one-hot representations of each label in a sample
55         """
56         one_hotted_batch = []
57 
58         for utt in batch:
59             if isinstance(utt, list):
60                 one_hotted_utt = self._to_one_hot(utt, self._depth)
61             elif isinstance(utt, int):
62                 if self._pad_zeros or self.single_vector:
63                     one_hotted_utt = self._to_one_hot([utt], self._depth)
64                 else:
65                     one_hotted_utt = self._to_one_hot([utt], self._depth).reshape(-1)
66 
67             if self.single_vector:
68                 one_hotted_utt = np.sum(one_hotted_utt, axis=0)
69 
70             one_hotted_batch.append(one_hotted_utt)
71 
72         if self._pad_zeros:
73             one_hotted_batch = zero_pad(one_hotted_batch)
74         return one_hotted_batch
75 
76     @staticmethod
77     def _to_one_hot(x, n):
78         b = np.zeros([len(x), n], dtype=np.float32)
79         for q, tok in enumerate(x):
80             b[q, tok] = 1
81         return b
82
```
--- 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()

```

diff --git a/deeppavlov/models/preprocessors/one_hotter.py b/deeppavlov/models/preprocessors/one_hotter.py
--- a/deeppavlov/models/preprocessors/one_hotter.py
+++ b/deeppavlov/models/preprocessors/one_hotter.py
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import List, Union
+from typing import List, Union, Iterable
 
 import numpy as np
 
@@ -56,7 +56,7 @@
         one_hotted_batch = []
 
         for utt in batch:
-            if isinstance(utt, list):
+            if isinstance(utt, Iterable):
                 one_hotted_utt = self._to_one_hot(utt, self._depth)
             elif isinstance(utt, int):
                 if self._pad_zeros or self.single_vector:
@@ -77,5 +77,5 @@
     def _to_one_hot(x, n):
         b = np.zeros([len(x), n], dtype=np.float32)
         for q, tok in enumerate(x):
-            b[q, tok] = 1
+            b[q, int(tok)] = 1
         return b

{"golden_diff": "diff --git a/deeppavlov/models/preprocessors/one_hotter.py b/deeppavlov/models/preprocessors/one_hotter.py\n--- a/deeppavlov/models/preprocessors/one_hotter.py\n+++ b/deeppavlov/models/preprocessors/one_hotter.py\n@@ -12,7 +12,7 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n-from typing import List, Union\n+from typing import List, Union, Iterable\n \n import numpy as np\n \n@@ -56,7 +56,7 @@\n         one_hotted_batch = []\n \n         for utt in batch:\n-            if isinstance(utt, list):\n+            if isinstance(utt, Iterable):\n                 one_hotted_utt = self._to_one_hot(utt, self._depth)\n             elif isinstance(utt, int):\n                 if self._pad_zeros or self.single_vector:\n@@ -77,5 +77,5 @@\n     def _to_one_hot(x, n):\n         b = np.zeros([len(x), n], dtype=np.float32)\n         for q, tok in enumerate(x):\n-            b[q, tok] = 1\n+            b[q, int(tok)] = 1\n         return b\n", "issue": "Error while training model with config \"ner_conll2003_pos\"\nI'm trying to train a NER model using \"train_model(configs.ner.ner_conll2003_pos)\" on Colab. There are only three things I've changed in original ner_conll2003_pos.json file: number of epochs = 1, DOWNLOADS_PATH and MODELS_PATH. After I start, it terminates with this error:\r\n\r\n---------------------------------------------------------------------------\r\nUnboundLocalError                         Traceback (most recent call last)\r\n<ipython-input-5-683c58afa1f4> in <module>()\r\n      1 from deeppavlov import configs, train_model\r\n----> 2 ner_model = train_model(configs.ner.ner_conll2003_pos)\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/__init__.py in train_model(config, download, recursive)\r\n     29     # TODO: make better\r\n     30     def train_model(config: [str, Path, dict], download: bool = False, recursive: bool = False) -> Chainer:\r\n---> 31         train_evaluate_model_from_config(config, download=download, recursive=recursive)\r\n     32         return build_model(config, load_trained=True)\r\n     33 \r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/commands/train.py in train_evaluate_model_from_config(config, iterator, to_train, evaluation_targets, to_validate, download, start_epoch_num, recursive)\r\n    119 \r\n    120     if to_train:\r\n--> 121         trainer.train(iterator)\r\n    122 \r\n    123     res = {}\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in train(self, iterator)\r\n    292         if callable(getattr(self._chainer, 'train_on_batch', None)):\r\n    293             try:\r\n--> 294                 self.train_on_batches(iterator)\r\n    295             except KeyboardInterrupt:\r\n    296                 log.info('Stopped training')\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in train_on_batches(self, iterator)\r\n    232         self.start_time = time.time()\r\n    233         if self.validate_first:\r\n--> 234             self._validate(iterator)\r\n    235 \r\n    236         while True:\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/nn_trainer.py in _validate(self, iterator, tensorboard_tag, tensorboard_index)\r\n    142         self._send_event(event_name='before_validation')\r\n    143         report = self.test(iterator.gen_batches(self.batch_size, data_type='valid', shuffle=False),\r\n--> 144                            start_time=self.start_time)\r\n    145 \r\n    146         report['epochs_done'] = self.epoch\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/trainers/fit_trainer.py in test(self, data, metrics, start_time, show_examples)\r\n    204         for x, y_true in data:\r\n    205             examples += len(x)\r\n--> 206             y_predicted = list(self._chainer.compute(list(x), list(y_true), targets=expected_outputs))\r\n    207             if len(expected_outputs) == 1:\r\n    208                 y_predicted = [y_predicted]\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/common/chainer.py in compute(self, x, y, targets)\r\n    141             in_params += self.in_y\r\n    142 \r\n--> 143         return self._compute(*args, pipe=pipe, param_names=in_params, targets=targets)\r\n    144 \r\n    145     def __call__(self, *args):\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/core/common/chainer.py in _compute(***failed resolving arguments***)\r\n    167                 res = component(**dict(zip(in_keys, x)))\r\n    168             else:\r\n--> 169                 res = component(*x)\r\n    170             if len(out_params) == 1:\r\n    171                 mem[out_params[0]] = res\r\n\r\n/usr/local/lib/python3.6/dist-packages/deeppavlov/models/preprocessors/one_hotter.py in __call__(self, batch, **kwargs)\r\n     68                 one_hotted_utt = np.sum(one_hotted_utt, axis=0)\r\n     69 \r\n---> 70             one_hotted_batch.append(one_hotted_utt)\r\n     71 \r\n     72         if self._pad_zeros:\r\n\r\nUnboundLocalError: local variable 'one_hotted_utt' referenced before assignment\r\n-----------------------------------------------------------------------------------------------\r\n\r\nHow can I fix this? \n", "before_files": [{"content": "# Copyright 2017 Neural Networks and Deep Learning lab, MIPT\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import List, Union\n\nimport numpy as np\n\nfrom deeppavlov.core.common.errors import ConfigError\nfrom deeppavlov.core.common.registry import register\nfrom deeppavlov.core.data.utils import zero_pad\nfrom deeppavlov.core.models.component import Component\n\n\n@register('one_hotter')\nclass OneHotter(Component):\n    \"\"\"\n    One-hot featurizer with zero-padding.\n    If ``single_vector``, return the only vector per sample which can have several elements equal to ``1``.\n\n    Parameters:\n        depth: the depth for one-hotting\n        pad_zeros: whether to pad elements of batch with zeros\n        single_vector: whether to return one vector for the sample (sum of each one-hotted vectors)\n    \"\"\"\n    def __init__(self, depth: int, pad_zeros: bool = False,\n                 single_vector=False, *args, **kwargs):\n        self._depth = depth\n        self._pad_zeros = pad_zeros\n        self.single_vector = single_vector\n        if self._pad_zeros and self.single_vector:\n            raise ConfigError(\"Cannot perform ``single_vector`` with zero padding for OneHotter\")\n\n    def __call__(self, batch: List[List[int]], **kwargs) -> Union[List[List[np.ndarray]], List[np.ndarray]]:\n        \"\"\"\n        Convert given batch of list of labels to one-hot representation of the batch.\n\n        Args:\n            batch: list of samples, where each sample is a list of integer labels.\n            **kwargs: additional arguments\n\n        Returns:\n            if ``single_vector``, list of one-hot representations of each sample,\n            otherwise, list of lists of one-hot representations of each label in a sample\n        \"\"\"\n        one_hotted_batch = []\n\n        for utt in batch:\n            if isinstance(utt, list):\n                one_hotted_utt = self._to_one_hot(utt, self._depth)\n            elif isinstance(utt, int):\n                if self._pad_zeros or self.single_vector:\n                    one_hotted_utt = self._to_one_hot([utt], self._depth)\n                else:\n                    one_hotted_utt = self._to_one_hot([utt], self._depth).reshape(-1)\n\n            if self.single_vector:\n                one_hotted_utt = np.sum(one_hotted_utt, axis=0)\n\n            one_hotted_batch.append(one_hotted_utt)\n\n        if self._pad_zeros:\n            one_hotted_batch = zero_pad(one_hotted_batch)\n        return one_hotted_batch\n\n    @staticmethod\n    def _to_one_hot(x, n):\n        b = np.zeros([len(x), n], dtype=np.float32)\n        for q, tok in enumerate(x):\n            b[q, tok] = 1\n        return b\n", "path": "deeppavlov/models/preprocessors/one_hotter.py"}], "after_files": [{"content": "# Copyright 2017 Neural Networks and Deep Learning lab, MIPT\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import List, Union, Iterable\n\nimport numpy as np\n\nfrom deeppavlov.core.common.errors import ConfigError\nfrom deeppavlov.core.common.registry import register\nfrom deeppavlov.core.data.utils import zero_pad\nfrom deeppavlov.core.models.component import Component\n\n\n@register('one_hotter')\nclass OneHotter(Component):\n    \"\"\"\n    One-hot featurizer with zero-padding.\n    If ``single_vector``, return the only vector per sample which can have several elements equal to ``1``.\n\n    Parameters:\n        depth: the depth for one-hotting\n        pad_zeros: whether to pad elements of batch with zeros\n        single_vector: whether to return one vector for the sample (sum of each one-hotted vectors)\n    \"\"\"\n    def __init__(self, depth: int, pad_zeros: bool = False,\n                 single_vector=False, *args, **kwargs):\n        self._depth = depth\n        self._pad_zeros = pad_zeros\n        self.single_vector = single_vector\n        if self._pad_zeros and self.single_vector:\n            raise ConfigError(\"Cannot perform ``single_vector`` with zero padding for OneHotter\")\n\n    def __call__(self, batch: List[List[int]], **kwargs) -> Union[List[List[np.ndarray]], List[np.ndarray]]:\n        \"\"\"\n        Convert given batch of list of labels to one-hot representation of the batch.\n\n        Args:\n            batch: list of samples, where each sample is a list of integer labels.\n            **kwargs: additional arguments\n\n        Returns:\n            if ``single_vector``, list of one-hot representations of each sample,\n            otherwise, list of lists of one-hot representations of each label in a sample\n        \"\"\"\n        one_hotted_batch = []\n\n        for utt in batch:\n            if isinstance(utt, Iterable):\n                one_hotted_utt = self._to_one_hot(utt, self._depth)\n            elif isinstance(utt, int):\n                if self._pad_zeros or self.single_vector:\n                    one_hotted_utt = self._to_one_hot([utt], self._depth)\n                else:\n                    one_hotted_utt = self._to_one_hot([utt], self._depth).reshape(-1)\n\n            if self.single_vector:\n                one_hotted_utt = np.sum(one_hotted_utt, axis=0)\n\n            one_hotted_batch.append(one_hotted_utt)\n\n        if self._pad_zeros:\n            one_hotted_batch = zero_pad(one_hotted_batch)\n        return one_hotted_batch\n\n    @staticmethod\n    def _to_one_hot(x, n):\n        b = np.zeros([len(x), n], dtype=np.float32)\n        for q, tok in enumerate(x):\n            b[q, int(tok)] = 1\n        return b\n", "path": "deeppavlov/models/preprocessors/one_hotter.py"}]}