We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
File reading unicode error
When trying the quickstart example, I faced an error which is regarding file opening in
`utils\misc.py`
It got resolved once I changed
```python
line 40: with open(filename) as f:
to
line 40:  with open(filename, encoding="utf8") as f:
``` 
I'll open a pull request with the fix.
**Windows, py3.6, tf1.4**
`python -m bin.main train --model config/models/nmt_small.
py --config config/opennmt-defaults.yml config/data/toy-ende.yml`

```bash
INFO:tensorflow:Using config: {'_model_dir': 'toy-ende', '_tf_random_seed': None, '_save_sum
mary_steps': 50, '_save_checkpoints_steps': 5000, '_save_checkpoints_secs': None, '_session_
config': gpu_options {
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps
': 50, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec
 object at 0x000002213F038F60>, '_task_type': 'worker', '_task_id': 0, '_master': '', '_is_c
hief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Running training and evaluation locally (non-distributed).
INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after 18000 secs (ev
al_spec.throttle_secs) or training is finished.
Traceback (most recent call last):
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _r
un_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _ru
n_code
    exec(code, run_globals)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\bin\main.py", line 308, in <module>
    main()
  File "C:\Users\Ayush\Projects\OpenNMT-tf\bin\main.py", line 290, in main
    train(estimator, model, config)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\bin\main.py", line 135, in train
    tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\training.py", line 430, in train_and_evaluate
    executor.run_local()
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\training.py", line 609, in run_local
    hooks=train_hooks)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\estimator.py", line 302, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\estimator.py", line 708, in _train_model
    input_fn, model_fn_lib.ModeKeys.TRAIN)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\estimator.py", line 577, in _get_features_and_labels_from_input_fn
    result = self._call_input_fn(input_fn, mode)
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\p
ython\estimator\estimator.py", line 663, in _call_input_fn
    return input_fn(**kwargs)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\opennmt\models\model.py", line 515, in <lambda>
    maximum_labels_length=maximum_labels_length)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\opennmt\models\model.py", line 374, in _input_fn_
impl
    self._initialize(metadata)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\opennmt\models\sequence_to_sequence.py", line 93,
 in _initialize
    self.source_inputter.initialize(metadata)
  File "C:\Users\Ayush\Projects\OpenNMT-tf\opennmt\inputters\text_inputter.py", line 304, in
 initialize
    self.vocabulary_size = count_lines(self.vocabulary_file) + self.num_oov_buckets
  File "C:\Users\Ayush\Projects\OpenNMT-tf\opennmt\utils\misc.py", line 42, in count_lines
    for i, _ in enumerate(f):
  File "C:\Users\Ayush\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py", line
 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5597: character maps
to <undefined>```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `opennmt/utils/misc.py`
Content:
```
1 """Various utility functions to use throughout the project."""
2 
3 from __future__ import print_function
4 
5 import sys
6 import inspect
7 
8 import tensorflow as tf
9 
10 
11 def print_bytes(str_as_bytes, stream=None):
12   """Prints a string viewed as bytes.
13 
14   This function calls ``decode()`` depending on the output stream encoding.
15 
16   Args:
17     str_as_bytes: The bytes to print.
18     stream: The stream to print to (``sys.stdout`` if not set).
19   """
20   encoding = None
21   if stream is not None:
22     encoding = stream.encoding
23   if encoding is None:
24     encoding = sys.getdefaultencoding()
25   text = str_as_bytes.decode(encoding) if encoding != "ascii" else str_as_bytes
26   print(text, file=stream)
27   if stream is not None:
28     stream.flush()
29 
30 def item_or_tuple(x):
31   """Returns :obj:`x` as a tuple or its single element."""
32   x = tuple(x)
33   if len(x) == 1:
34     return x[0]
35   else:
36     return x
37 
38 def count_lines(filename):
39   """Returns the number of lines of the file :obj:`filename`."""
40   with open(filename) as f:
41     i = 0
42     for i, _ in enumerate(f):
43       pass
44     return i + 1
45 
46 def get_classnames_in_module(module):
47   """Returns a list of classnames exposed by a module."""
48   names = []
49   for symbol in dir(module):
50     if inspect.isclass(getattr(module, symbol)):
51       names.append(symbol)
52   return names
53 
54 def count_parameters():
55   """Returns the total number of trainable parameters."""
56   total = 0
57   for variable in tf.trainable_variables():
58     shape = variable.get_shape()
59     count = 1
60     for dim in shape:
61       count *= dim.value
62     total += count
63   return total
64 
65 def extract_prefixed_keys(dictionary, prefix):
66   """Returns a dictionary with all keys from :obj:`dictionary` that are prefixed
67   with :obj:`prefix`.
68   """
69   sub_dict = {}
70   for key, value in dictionary.items():
71     if key.startswith(prefix):
72       original_key = key[len(prefix):]
73       sub_dict[original_key] = value
74   return sub_dict
75 
76 def extract_batches(tensors):
77   """Returns a generator to iterate on each batch of a Numpy array or dict of
78   Numpy arrays."""
79   if not isinstance(tensors, dict):
80     for tensor in tensors:
81       yield tensor
82   else:
83     batch_size = None
84     for _, value in tensors.items():
85       batch_size = batch_size or value.shape[0]
86     for b in range(batch_size):
87       yield {
88           key: value[b] for key, value in tensors.items()
89       }
90 
91 
92 # The next 2 functions come with the following license and copyright:
93 
94 # Copyright 2017 Google Inc.
95 #
96 # Licensed under the Apache License, Version 2.0 (the "License");
97 # you may not use this file except in compliance with the License.
98 # You may obtain a copy of the License at
99 #
100 #      http://www.apache.org/licenses/LICENSE-2.0
101 #
102 # Unless required by applicable law or agreed to in writing, software
103 # distributed under the License is distributed on an "AS IS" BASIS,
104 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105 # See the License for the specific language governing permissions and
106 # limitations under the License.
107 
108 def add_dict_to_collection(collection_name, dict_):
109   """Adds a dictionary to a graph collection.
110 
111   Args:
112     collection_name: The name of the collection to add the dictionary to
113     dict_: A dictionary of string keys to tensor values
114   """
115   key_collection = collection_name + "_keys"
116   value_collection = collection_name + "_values"
117   for key, value in dict_.items():
118     tf.add_to_collection(key_collection, key)
119     tf.add_to_collection(value_collection, value)
120 
121 def get_dict_from_collection(collection_name):
122   """Gets a dictionary from a graph collection.
123 
124   Args:
125     collection_name: A collection name to read a dictionary from
126 
127   Returns:
128     A dictionary with string keys and tensor values
129   """
130   key_collection = collection_name + "_keys"
131   value_collection = collection_name + "_values"
132   keys = tf.get_collection(key_collection)
133   values = tf.get_collection(value_collection)
134   return dict(zip(keys, values))
135
```
--- 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/opennmt/utils/misc.py b/opennmt/utils/misc.py
--- a/opennmt/utils/misc.py
+++ b/opennmt/utils/misc.py
@@ -37,7 +37,7 @@
 
 def count_lines(filename):
   """Returns the number of lines of the file :obj:`filename`."""
-  with open(filename) as f:
+  with open(filename, "rb") as f:
     i = 0
     for i, _ in enumerate(f):
       pass

{"golden_diff": "diff --git a/opennmt/utils/misc.py b/opennmt/utils/misc.py\n--- a/opennmt/utils/misc.py\n+++ b/opennmt/utils/misc.py\n@@ -37,7 +37,7 @@\n \n def count_lines(filename):\n   \"\"\"Returns the number of lines of the file :obj:`filename`.\"\"\"\n-  with open(filename) as f:\n+  with open(filename, \"rb\") as f:\n     i = 0\n     for i, _ in enumerate(f):\n       pass\n", "issue": "File reading unicode error\nWhen trying the quickstart example, I faced an error which is regarding file opening in\r\n`utils\\misc.py`\r\nIt got resolved once I changed\r\n```python\r\nline 40: with open(filename) as f:\r\nto\r\nline 40:  with open(filename, encoding=\"utf8\") as f:\r\n``` \r\nI'll open a pull request with the fix.\r\n**Windows, py3.6, tf1.4**\r\n`python -m bin.main train --model config/models/nmt_small.\r\npy --config config/opennmt-defaults.yml config/data/toy-ende.yml`\r\n\r\n```bash\r\nINFO:tensorflow:Using config: {'_model_dir': 'toy-ende', '_tf_random_seed': None, '_save_sum\r\nmary_steps': 50, '_save_checkpoints_steps': 5000, '_save_checkpoints_secs': None, '_session_\r\nconfig': gpu_options {\r\n}\r\n, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps\r\n': 50, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec\r\n object at 0x000002213F038F60>, '_task_type': 'worker', '_task_id': 0, '_master': '', '_is_c\r\nhief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}\r\nINFO:tensorflow:Running training and evaluation locally (non-distributed).\r\nINFO:tensorflow:Start train and evaluate loop. The evaluate will happen after 18000 secs (ev\r\nal_spec.throttle_secs) or training is finished.\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\runpy.py\", line 193, in _r\r\nun_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\runpy.py\", line 85, in _ru\r\nn_code\r\n    exec(code, run_globals)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\bin\\main.py\", line 308, in <module>\r\n    main()\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\bin\\main.py\", line 290, in main\r\n    train(estimator, model, config)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\bin\\main.py\", line 135, in train\r\n    tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\training.py\", line 430, in train_and_evaluate\r\n    executor.run_local()\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\training.py\", line 609, in run_local\r\n    hooks=train_hooks)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\estimator.py\", line 302, in train\r\n    loss = self._train_model(input_fn, hooks, saving_listeners)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\estimator.py\", line 708, in _train_model\r\n    input_fn, model_fn_lib.ModeKeys.TRAIN)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\estimator.py\", line 577, in _get_features_and_labels_from_input_fn\r\n    result = self._call_input_fn(input_fn, mode)\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\tensorflow\\p\r\nython\\estimator\\estimator.py\", line 663, in _call_input_fn\r\n    return input_fn(**kwargs)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\opennmt\\models\\model.py\", line 515, in <lambda>\r\n    maximum_labels_length=maximum_labels_length)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\opennmt\\models\\model.py\", line 374, in _input_fn_\r\nimpl\r\n    self._initialize(metadata)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\opennmt\\models\\sequence_to_sequence.py\", line 93,\r\n in _initialize\r\n    self.source_inputter.initialize(metadata)\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\opennmt\\inputters\\text_inputter.py\", line 304, in\r\n initialize\r\n    self.vocabulary_size = count_lines(self.vocabulary_file) + self.num_oov_buckets\r\n  File \"C:\\Users\\Ayush\\Projects\\OpenNMT-tf\\opennmt\\utils\\misc.py\", line 42, in count_lines\r\n    for i, _ in enumerate(f):\r\n  File \"C:\\Users\\Ayush\\AppData\\Local\\Programs\\Python\\Python36\\lib\\encodings\\cp1252.py\", line\r\n 23, in decode\r\n    return codecs.charmap_decode(input,self.errors,decoding_table)[0]\r\nUnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5597: character maps\r\nto <undefined>```\n", "before_files": [{"content": "\"\"\"Various utility functions to use throughout the project.\"\"\"\n\nfrom __future__ import print_function\n\nimport sys\nimport inspect\n\nimport tensorflow as tf\n\n\ndef print_bytes(str_as_bytes, stream=None):\n  \"\"\"Prints a string viewed as bytes.\n\n  This function calls ``decode()`` depending on the output stream encoding.\n\n  Args:\n    str_as_bytes: The bytes to print.\n    stream: The stream to print to (``sys.stdout`` if not set).\n  \"\"\"\n  encoding = None\n  if stream is not None:\n    encoding = stream.encoding\n  if encoding is None:\n    encoding = sys.getdefaultencoding()\n  text = str_as_bytes.decode(encoding) if encoding != \"ascii\" else str_as_bytes\n  print(text, file=stream)\n  if stream is not None:\n    stream.flush()\n\ndef item_or_tuple(x):\n  \"\"\"Returns :obj:`x` as a tuple or its single element.\"\"\"\n  x = tuple(x)\n  if len(x) == 1:\n    return x[0]\n  else:\n    return x\n\ndef count_lines(filename):\n  \"\"\"Returns the number of lines of the file :obj:`filename`.\"\"\"\n  with open(filename) as f:\n    i = 0\n    for i, _ in enumerate(f):\n      pass\n    return i + 1\n\ndef get_classnames_in_module(module):\n  \"\"\"Returns a list of classnames exposed by a module.\"\"\"\n  names = []\n  for symbol in dir(module):\n    if inspect.isclass(getattr(module, symbol)):\n      names.append(symbol)\n  return names\n\ndef count_parameters():\n  \"\"\"Returns the total number of trainable parameters.\"\"\"\n  total = 0\n  for variable in tf.trainable_variables():\n    shape = variable.get_shape()\n    count = 1\n    for dim in shape:\n      count *= dim.value\n    total += count\n  return total\n\ndef extract_prefixed_keys(dictionary, prefix):\n  \"\"\"Returns a dictionary with all keys from :obj:`dictionary` that are prefixed\n  with :obj:`prefix`.\n  \"\"\"\n  sub_dict = {}\n  for key, value in dictionary.items():\n    if key.startswith(prefix):\n      original_key = key[len(prefix):]\n      sub_dict[original_key] = value\n  return sub_dict\n\ndef extract_batches(tensors):\n  \"\"\"Returns a generator to iterate on each batch of a Numpy array or dict of\n  Numpy arrays.\"\"\"\n  if not isinstance(tensors, dict):\n    for tensor in tensors:\n      yield tensor\n  else:\n    batch_size = None\n    for _, value in tensors.items():\n      batch_size = batch_size or value.shape[0]\n    for b in range(batch_size):\n      yield {\n          key: value[b] for key, value in tensors.items()\n      }\n\n\n# The next 2 functions come with the following license and copyright:\n\n# Copyright 2017 Google Inc.\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\ndef add_dict_to_collection(collection_name, dict_):\n  \"\"\"Adds a dictionary to a graph collection.\n\n  Args:\n    collection_name: The name of the collection to add the dictionary to\n    dict_: A dictionary of string keys to tensor values\n  \"\"\"\n  key_collection = collection_name + \"_keys\"\n  value_collection = collection_name + \"_values\"\n  for key, value in dict_.items():\n    tf.add_to_collection(key_collection, key)\n    tf.add_to_collection(value_collection, value)\n\ndef get_dict_from_collection(collection_name):\n  \"\"\"Gets a dictionary from a graph collection.\n\n  Args:\n    collection_name: A collection name to read a dictionary from\n\n  Returns:\n    A dictionary with string keys and tensor values\n  \"\"\"\n  key_collection = collection_name + \"_keys\"\n  value_collection = collection_name + \"_values\"\n  keys = tf.get_collection(key_collection)\n  values = tf.get_collection(value_collection)\n  return dict(zip(keys, values))\n", "path": "opennmt/utils/misc.py"}], "after_files": [{"content": "\"\"\"Various utility functions to use throughout the project.\"\"\"\n\nfrom __future__ import print_function\n\nimport sys\nimport inspect\n\nimport tensorflow as tf\n\n\ndef print_bytes(str_as_bytes, stream=None):\n  \"\"\"Prints a string viewed as bytes.\n\n  This function calls ``decode()`` depending on the output stream encoding.\n\n  Args:\n    str_as_bytes: The bytes to print.\n    stream: The stream to print to (``sys.stdout`` if not set).\n  \"\"\"\n  encoding = None\n  if stream is not None:\n    encoding = stream.encoding\n  if encoding is None:\n    encoding = sys.getdefaultencoding()\n  text = str_as_bytes.decode(encoding) if encoding != \"ascii\" else str_as_bytes\n  print(text, file=stream)\n  if stream is not None:\n    stream.flush()\n\ndef item_or_tuple(x):\n  \"\"\"Returns :obj:`x` as a tuple or its single element.\"\"\"\n  x = tuple(x)\n  if len(x) == 1:\n    return x[0]\n  else:\n    return x\n\ndef count_lines(filename):\n  \"\"\"Returns the number of lines of the file :obj:`filename`.\"\"\"\n  with open(filename, \"rb\") as f:\n    i = 0\n    for i, _ in enumerate(f):\n      pass\n    return i + 1\n\ndef get_classnames_in_module(module):\n  \"\"\"Returns a list of classnames exposed by a module.\"\"\"\n  names = []\n  for symbol in dir(module):\n    if inspect.isclass(getattr(module, symbol)):\n      names.append(symbol)\n  return names\n\ndef count_parameters():\n  \"\"\"Returns the total number of trainable parameters.\"\"\"\n  total = 0\n  for variable in tf.trainable_variables():\n    shape = variable.get_shape()\n    count = 1\n    for dim in shape:\n      count *= dim.value\n    total += count\n  return total\n\ndef extract_prefixed_keys(dictionary, prefix):\n  \"\"\"Returns a dictionary with all keys from :obj:`dictionary` that are prefixed\n  with :obj:`prefix`.\n  \"\"\"\n  sub_dict = {}\n  for key, value in dictionary.items():\n    if key.startswith(prefix):\n      original_key = key[len(prefix):]\n      sub_dict[original_key] = value\n  return sub_dict\n\ndef extract_batches(tensors):\n  \"\"\"Returns a generator to iterate on each batch of a Numpy array or dict of\n  Numpy arrays.\"\"\"\n  if not isinstance(tensors, dict):\n    for tensor in tensors:\n      yield tensor\n  else:\n    batch_size = None\n    for _, value in tensors.items():\n      batch_size = batch_size or value.shape[0]\n    for b in range(batch_size):\n      yield {\n          key: value[b] for key, value in tensors.items()\n      }\n\n\n# The next 2 functions come with the following license and copyright:\n\n# Copyright 2017 Google Inc.\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\ndef add_dict_to_collection(collection_name, dict_):\n  \"\"\"Adds a dictionary to a graph collection.\n\n  Args:\n    collection_name: The name of the collection to add the dictionary to\n    dict_: A dictionary of string keys to tensor values\n  \"\"\"\n  key_collection = collection_name + \"_keys\"\n  value_collection = collection_name + \"_values\"\n  for key, value in dict_.items():\n    tf.add_to_collection(key_collection, key)\n    tf.add_to_collection(value_collection, value)\n\ndef get_dict_from_collection(collection_name):\n  \"\"\"Gets a dictionary from a graph collection.\n\n  Args:\n    collection_name: A collection name to read a dictionary from\n\n  Returns:\n    A dictionary with string keys and tensor values\n  \"\"\"\n  key_collection = collection_name + \"_keys\"\n  value_collection = collection_name + \"_values\"\n  keys = tf.get_collection(key_collection)\n  values = tf.get_collection(value_collection)\n  return dict(zip(keys, values))\n", "path": "opennmt/utils/misc.py"}]}