We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error while running the exported model 
Hi,

I was trying to run the example given [https://github.com/OpenNMT/OpenNMT-tf/tree/master/examples/serving/python](url).

I am getting the following error.

> Source: I am going.
Traceback (most recent call last):
  File "ende_client.py", line 66, in <module>
    main()
  File "ende_client.py", line 60, in main
    output = translator.translate([text])
  File "ende_client.py", line 22, in translate
    return self._postprocess(outputs)
  File "ende_client.py", line 47, in _postprocess
    texts.append(self._tokenizer.detokenize(tokens))
TypeError: detokenize(): incompatible function arguments. The following argument types are supported:
    1. (self: pyonmttok.Tokenizer, tokens: list, features: object = None) -> str

> Invoked with: <pyonmttok.Tokenizer object at 0x147d10d0d538>, array([b'\xe2\x96\x81Ich', b'\xe2\x96\x81gehe', b'.'], dtype=object)
> WARNING:tensorflow:Unresolved object in checkpoint: (root).examples_inputter.features_inputter.ids_to_tokens._initializer
> WARNING:tensorflow:Unresolved object in checkpoint: (root).examples_inputter.labels_inputter.ids_to_tokens._initializer
> WARNING:tensorflow:A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/alpha/guide/checkpoints#loading_mechanics for details.
> 

I have the updated version of pyonmttok.

Thanks,
Sriram

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/serving/python/ende_client.py`
Content:
```
1 import argparse
2 import os
3 
4 import tensorflow as tf
5 import tensorflow_addons as tfa  # Register TensorFlow Addons kernels.
6 
7 import pyonmttok
8 
9 
10 class EnDeTranslator(object):
11 
12   def __init__(self, export_dir):
13     imported = tf.saved_model.load(export_dir)
14     self._translate_fn = imported.signatures["serving_default"]
15     sp_model_path = os.path.join(export_dir, "assets.extra", "wmtende.model")
16     self._tokenizer = pyonmttok.Tokenizer("none", sp_model_path=sp_model_path)
17 
18   def translate(self, texts):
19     """Translates a batch of texts."""
20     inputs = self._preprocess(texts)
21     outputs = self._translate_fn(**inputs)
22     return self._postprocess(outputs)
23 
24   def _preprocess(self, texts):
25     all_tokens = []
26     lengths = []
27     max_length = 0
28     for text in texts:
29       tokens, _ = self._tokenizer.tokenize(text)
30       length = len(tokens)
31       all_tokens.append(tokens)
32       lengths.append(length)
33       max_length = max(max_length, length)
34     for tokens, length in zip(all_tokens, lengths):
35       if length < max_length:
36         tokens += [""] * (max_length - length)
37 
38     inputs = {
39         "tokens": tf.constant(all_tokens, dtype=tf.string),
40         "length": tf.constant(lengths, dtype=tf.int32)}
41     return inputs
42 
43   def _postprocess(self, outputs):
44     texts = []
45     for tokens, length in zip(outputs["tokens"].numpy(), outputs["length"].numpy()):
46       tokens = tokens[0][:length[0]]
47       texts.append(self._tokenizer.detokenize(tokens))
48     return texts
49 
50 
51 def main():
52   parser = argparse.ArgumentParser(description="Translation client example")
53   parser.add_argument("export_dir", help="Saved model directory")
54   args = parser.parse_args()
55 
56   translator = EnDeTranslator(args.export_dir)
57 
58   while True:
59     text = input("Source: ")
60     output = translator.translate([text])
61     print("Target: %s" % output[0])
62     print("")
63 
64 
65 if __name__ == "__main__":
66   main()
67
```
--- 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/examples/serving/python/ende_client.py b/examples/serving/python/ende_client.py
--- a/examples/serving/python/ende_client.py
+++ b/examples/serving/python/ende_client.py
@@ -43,7 +43,7 @@
   def _postprocess(self, outputs):
     texts = []
     for tokens, length in zip(outputs["tokens"].numpy(), outputs["length"].numpy()):
-      tokens = tokens[0][:length[0]]
+      tokens = tokens[0][:length[0]].tolist()
       texts.append(self._tokenizer.detokenize(tokens))
     return texts

{"golden_diff": "diff --git a/examples/serving/python/ende_client.py b/examples/serving/python/ende_client.py\n--- a/examples/serving/python/ende_client.py\n+++ b/examples/serving/python/ende_client.py\n@@ -43,7 +43,7 @@\n   def _postprocess(self, outputs):\n     texts = []\n     for tokens, length in zip(outputs[\"tokens\"].numpy(), outputs[\"length\"].numpy()):\n-      tokens = tokens[0][:length[0]]\n+      tokens = tokens[0][:length[0]].tolist()\n       texts.append(self._tokenizer.detokenize(tokens))\n     return texts\n", "issue": "Error while running the exported model \nHi,\r\n\r\nI was trying to run the example given [https://github.com/OpenNMT/OpenNMT-tf/tree/master/examples/serving/python](url).\r\n\r\nI am getting the following error.\r\n\r\n> Source: I am going.\r\nTraceback (most recent call last):\r\n  File \"ende_client.py\", line 66, in <module>\r\n    main()\r\n  File \"ende_client.py\", line 60, in main\r\n    output = translator.translate([text])\r\n  File \"ende_client.py\", line 22, in translate\r\n    return self._postprocess(outputs)\r\n  File \"ende_client.py\", line 47, in _postprocess\r\n    texts.append(self._tokenizer.detokenize(tokens))\r\nTypeError: detokenize(): incompatible function arguments. The following argument types are supported:\r\n    1. (self: pyonmttok.Tokenizer, tokens: list, features: object = None) -> str\r\n\r\n> Invoked with: <pyonmttok.Tokenizer object at 0x147d10d0d538>, array([b'\\xe2\\x96\\x81Ich', b'\\xe2\\x96\\x81gehe', b'.'], dtype=object)\r\n> WARNING:tensorflow:Unresolved object in checkpoint: (root).examples_inputter.features_inputter.ids_to_tokens._initializer\r\n> WARNING:tensorflow:Unresolved object in checkpoint: (root).examples_inputter.labels_inputter.ids_to_tokens._initializer\r\n> WARNING:tensorflow:A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/alpha/guide/checkpoints#loading_mechanics for details.\r\n> \r\n\r\nI have the updated version of pyonmttok.\r\n\r\nThanks,\r\nSriram\n", "before_files": [{"content": "import argparse\nimport os\n\nimport tensorflow as tf\nimport tensorflow_addons as tfa  # Register TensorFlow Addons kernels.\n\nimport pyonmttok\n\n\nclass EnDeTranslator(object):\n\n  def __init__(self, export_dir):\n    imported = tf.saved_model.load(export_dir)\n    self._translate_fn = imported.signatures[\"serving_default\"]\n    sp_model_path = os.path.join(export_dir, \"assets.extra\", \"wmtende.model\")\n    self._tokenizer = pyonmttok.Tokenizer(\"none\", sp_model_path=sp_model_path)\n\n  def translate(self, texts):\n    \"\"\"Translates a batch of texts.\"\"\"\n    inputs = self._preprocess(texts)\n    outputs = self._translate_fn(**inputs)\n    return self._postprocess(outputs)\n\n  def _preprocess(self, texts):\n    all_tokens = []\n    lengths = []\n    max_length = 0\n    for text in texts:\n      tokens, _ = self._tokenizer.tokenize(text)\n      length = len(tokens)\n      all_tokens.append(tokens)\n      lengths.append(length)\n      max_length = max(max_length, length)\n    for tokens, length in zip(all_tokens, lengths):\n      if length < max_length:\n        tokens += [\"\"] * (max_length - length)\n\n    inputs = {\n        \"tokens\": tf.constant(all_tokens, dtype=tf.string),\n        \"length\": tf.constant(lengths, dtype=tf.int32)}\n    return inputs\n\n  def _postprocess(self, outputs):\n    texts = []\n    for tokens, length in zip(outputs[\"tokens\"].numpy(), outputs[\"length\"].numpy()):\n      tokens = tokens[0][:length[0]]\n      texts.append(self._tokenizer.detokenize(tokens))\n    return texts\n\n\ndef main():\n  parser = argparse.ArgumentParser(description=\"Translation client example\")\n  parser.add_argument(\"export_dir\", help=\"Saved model directory\")\n  args = parser.parse_args()\n\n  translator = EnDeTranslator(args.export_dir)\n\n  while True:\n    text = input(\"Source: \")\n    output = translator.translate([text])\n    print(\"Target: %s\" % output[0])\n    print(\"\")\n\n\nif __name__ == \"__main__\":\n  main()\n", "path": "examples/serving/python/ende_client.py"}], "after_files": [{"content": "import argparse\nimport os\n\nimport tensorflow as tf\nimport tensorflow_addons as tfa  # Register TensorFlow Addons kernels.\n\nimport pyonmttok\n\n\nclass EnDeTranslator(object):\n\n  def __init__(self, export_dir):\n    imported = tf.saved_model.load(export_dir)\n    self._translate_fn = imported.signatures[\"serving_default\"]\n    sp_model_path = os.path.join(export_dir, \"assets.extra\", \"wmtende.model\")\n    self._tokenizer = pyonmttok.Tokenizer(\"none\", sp_model_path=sp_model_path)\n\n  def translate(self, texts):\n    \"\"\"Translates a batch of texts.\"\"\"\n    inputs = self._preprocess(texts)\n    outputs = self._translate_fn(**inputs)\n    return self._postprocess(outputs)\n\n  def _preprocess(self, texts):\n    all_tokens = []\n    lengths = []\n    max_length = 0\n    for text in texts:\n      tokens, _ = self._tokenizer.tokenize(text)\n      length = len(tokens)\n      all_tokens.append(tokens)\n      lengths.append(length)\n      max_length = max(max_length, length)\n    for tokens, length in zip(all_tokens, lengths):\n      if length < max_length:\n        tokens += [\"\"] * (max_length - length)\n\n    inputs = {\n        \"tokens\": tf.constant(all_tokens, dtype=tf.string),\n        \"length\": tf.constant(lengths, dtype=tf.int32)}\n    return inputs\n\n  def _postprocess(self, outputs):\n    texts = []\n    for tokens, length in zip(outputs[\"tokens\"].numpy(), outputs[\"length\"].numpy()):\n      tokens = tokens[0][:length[0]].tolist()\n      texts.append(self._tokenizer.detokenize(tokens))\n    return texts\n\n\ndef main():\n  parser = argparse.ArgumentParser(description=\"Translation client example\")\n  parser.add_argument(\"export_dir\", help=\"Saved model directory\")\n  args = parser.parse_args()\n\n  translator = EnDeTranslator(args.export_dir)\n\n  while True:\n    text = input(\"Source: \")\n    output = translator.translate([text])\n    print(\"Target: %s\" % output[0])\n    print(\"\")\n\n\nif __name__ == \"__main__\":\n  main()\n", "path": "examples/serving/python/ende_client.py"}]}