We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Failed generating cifar10 dataset when building dev image


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `elasticdl/recordio_ds_gen/cifar10/show_data.py`
Content:
```
1 from recordio import File
2 from elasticdl.recordio_ds_gen.mnist import record
3 import sys
4 import argparse
5 
6 # TODO: share code with MNIST dataset.
7 def main(argv):
8     print(argv)
9     parser = argparse.ArgumentParser(
10         description="Show same data from CIFAR10 recordio"
11     )
12     parser.add_argument("file", help="RecordIo file to read")
13     parser.add_argument(
14         "--start", default=0, type=int, help="Start record number"
15     )
16     parser.add_argument("--step", default=1, type=int, help="Step")
17     parser.add_argument(
18         "--n", default=20, type=int, help="How many record to show"
19     )
20     args = parser.parse_args(argv)
21 
22     with File(args.file, "r") as f:
23         for i in range(
24             args.start, args.start + (args.n * args.step), args.step
25         ):
26             print("-" * 10)
27             print("record:", i)
28             record.show(*record.decode(f.get(i)))
29 
30 
31 if __name__ == "__main__":
32     main(sys.argv[1:])
33
```

Path: `elasticdl/recordio_ds_gen/cifar10/gen_data.py`
Content:
```
1 #!/usr/bin/env python
2 
3 """
4 Download and transform CIFAR10 data to RecordIO format.
5 """
6 
7 import itertools
8 import argparse
9 import os
10 import sys
11 from recordio import File
12 from tensorflow.python.keras import backend
13 from tensorflow.python.keras.datasets import cifar10
14 from elasticdl.recordio_ds_gen.mnist import record
15 
16 # TODO: This function can be shared with MNIST dataset
17 def gen(file_dir, data, label, *, chunk_size, record_per_file):
18     assert len(data) == len(label) and len(data) > 0
19     os.makedirs(file_dir)
20     it = zip(data, label)
21     try:
22         for i in itertools.count():
23             file_name = file_dir + "/data-%04d" % i
24             print("writing:", file_name)
25             with File(file_name, "w", max_chunk_size=chunk_size) as f:
26                 for _ in range(record_per_file):
27                     row = next(it)
28                     f.write(record.encode(row[0], row[1]))
29     except StopIteration:
30         pass
31 
32 
33 def main(argv):
34     parser = argparse.ArgumentParser(
35         description="Generate CIFAR10 datasets in RecordIO format."
36     )
37     parser.add_argument("dir", help="Output directory")
38     parser.add_argument(
39         "--num_record_per_chunk",
40         default=1024,
41         type=int,
42         help="Approximate number of records in a chunk.",
43     )
44     parser.add_argument(
45         "--num_chunk",
46         default=16,
47         type=int,
48         help="Number of chunks in a RecordIO file",
49     )
50     args = parser.parse_args(argv)
51     # one uncompressed record has size 3 * 32 * 32 + 1 bytes.
52     # Also add some slack for safety.
53     chunk_size = args.num_record_per_chunk * (3 * 32 * 32 + 1) + 100
54     record_per_file = args.num_record_per_chunk * args.num_chunk
55     backend.set_image_data_format("channels_first")
56 
57     (x_train, y_train), (x_test, y_test) = cifar10.load_data()
58     gen(
59         args.dir + "/cifar10/train",
60         x_train,
61         y_train,
62         chunk_size=chunk_size,
63         record_per_file=record_per_file,
64     )
65 
66     # Work around a bug in cifar10.load_data() where y_test is not converted
67     # to uint8
68     y_test = y_test.astype("uint8")
69     gen(
70         args.dir + "/cifar10/test",
71         x_test,
72         y_test,
73         chunk_size=chunk_size,
74         record_per_file=record_per_file,
75     )
76 
77 
78 if __name__ == "__main__":
79     main(sys.argv[1:])
80
```
--- 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/elasticdl/recordio_ds_gen/cifar10/gen_data.py b/elasticdl/recordio_ds_gen/cifar10/gen_data.py
--- a/elasticdl/recordio_ds_gen/cifar10/gen_data.py
+++ b/elasticdl/recordio_ds_gen/cifar10/gen_data.py
@@ -11,7 +11,7 @@
 from recordio import File
 from tensorflow.python.keras import backend
 from tensorflow.python.keras.datasets import cifar10
-from elasticdl.recordio_ds_gen.mnist import record
+from elasticdl.recordio_ds_gen.cifar10 import record
 
 # TODO: This function can be shared with MNIST dataset
 def gen(file_dir, data, label, *, chunk_size, record_per_file):
diff --git a/elasticdl/recordio_ds_gen/cifar10/show_data.py b/elasticdl/recordio_ds_gen/cifar10/show_data.py
--- a/elasticdl/recordio_ds_gen/cifar10/show_data.py
+++ b/elasticdl/recordio_ds_gen/cifar10/show_data.py
@@ -1,5 +1,5 @@
 from recordio import File
-from elasticdl.recordio_ds_gen.mnist import record
+from elasticdl.recordio_ds_gen.cifar10 import record
 import sys
 import argparse

{"golden_diff": "diff --git a/elasticdl/recordio_ds_gen/cifar10/gen_data.py b/elasticdl/recordio_ds_gen/cifar10/gen_data.py\n--- a/elasticdl/recordio_ds_gen/cifar10/gen_data.py\n+++ b/elasticdl/recordio_ds_gen/cifar10/gen_data.py\n@@ -11,7 +11,7 @@\n from recordio import File\n from tensorflow.python.keras import backend\n from tensorflow.python.keras.datasets import cifar10\n-from elasticdl.recordio_ds_gen.mnist import record\n+from elasticdl.recordio_ds_gen.cifar10 import record\n \n # TODO: This function can be shared with MNIST dataset\n def gen(file_dir, data, label, *, chunk_size, record_per_file):\ndiff --git a/elasticdl/recordio_ds_gen/cifar10/show_data.py b/elasticdl/recordio_ds_gen/cifar10/show_data.py\n--- a/elasticdl/recordio_ds_gen/cifar10/show_data.py\n+++ b/elasticdl/recordio_ds_gen/cifar10/show_data.py\n@@ -1,5 +1,5 @@\n from recordio import File\n-from elasticdl.recordio_ds_gen.mnist import record\n+from elasticdl.recordio_ds_gen.cifar10 import record\n import sys\n import argparse\n", "issue": "Failed generating cifar10 dataset when building dev image\n\n", "before_files": [{"content": "from recordio import File\nfrom elasticdl.recordio_ds_gen.mnist import record\nimport sys\nimport argparse\n\n# TODO: share code with MNIST dataset.\ndef main(argv):\n    print(argv)\n    parser = argparse.ArgumentParser(\n        description=\"Show same data from CIFAR10 recordio\"\n    )\n    parser.add_argument(\"file\", help=\"RecordIo file to read\")\n    parser.add_argument(\n        \"--start\", default=0, type=int, help=\"Start record number\"\n    )\n    parser.add_argument(\"--step\", default=1, type=int, help=\"Step\")\n    parser.add_argument(\n        \"--n\", default=20, type=int, help=\"How many record to show\"\n    )\n    args = parser.parse_args(argv)\n\n    with File(args.file, \"r\") as f:\n        for i in range(\n            args.start, args.start + (args.n * args.step), args.step\n        ):\n            print(\"-\" * 10)\n            print(\"record:\", i)\n            record.show(*record.decode(f.get(i)))\n\n\nif __name__ == \"__main__\":\n    main(sys.argv[1:])\n", "path": "elasticdl/recordio_ds_gen/cifar10/show_data.py"}, {"content": "#!/usr/bin/env python\n\n\"\"\"\nDownload and transform CIFAR10 data to RecordIO format.\n\"\"\"\n\nimport itertools\nimport argparse\nimport os\nimport sys\nfrom recordio import File\nfrom tensorflow.python.keras import backend\nfrom tensorflow.python.keras.datasets import cifar10\nfrom elasticdl.recordio_ds_gen.mnist import record\n\n# TODO: This function can be shared with MNIST dataset\ndef gen(file_dir, data, label, *, chunk_size, record_per_file):\n    assert len(data) == len(label) and len(data) > 0\n    os.makedirs(file_dir)\n    it = zip(data, label)\n    try:\n        for i in itertools.count():\n            file_name = file_dir + \"/data-%04d\" % i\n            print(\"writing:\", file_name)\n            with File(file_name, \"w\", max_chunk_size=chunk_size) as f:\n                for _ in range(record_per_file):\n                    row = next(it)\n                    f.write(record.encode(row[0], row[1]))\n    except StopIteration:\n        pass\n\n\ndef main(argv):\n    parser = argparse.ArgumentParser(\n        description=\"Generate CIFAR10 datasets in RecordIO format.\"\n    )\n    parser.add_argument(\"dir\", help=\"Output directory\")\n    parser.add_argument(\n        \"--num_record_per_chunk\",\n        default=1024,\n        type=int,\n        help=\"Approximate number of records in a chunk.\",\n    )\n    parser.add_argument(\n        \"--num_chunk\",\n        default=16,\n        type=int,\n        help=\"Number of chunks in a RecordIO file\",\n    )\n    args = parser.parse_args(argv)\n    # one uncompressed record has size 3 * 32 * 32 + 1 bytes.\n    # Also add some slack for safety.\n    chunk_size = args.num_record_per_chunk * (3 * 32 * 32 + 1) + 100\n    record_per_file = args.num_record_per_chunk * args.num_chunk\n    backend.set_image_data_format(\"channels_first\")\n\n    (x_train, y_train), (x_test, y_test) = cifar10.load_data()\n    gen(\n        args.dir + \"/cifar10/train\",\n        x_train,\n        y_train,\n        chunk_size=chunk_size,\n        record_per_file=record_per_file,\n    )\n\n    # Work around a bug in cifar10.load_data() where y_test is not converted\n    # to uint8\n    y_test = y_test.astype(\"uint8\")\n    gen(\n        args.dir + \"/cifar10/test\",\n        x_test,\n        y_test,\n        chunk_size=chunk_size,\n        record_per_file=record_per_file,\n    )\n\n\nif __name__ == \"__main__\":\n    main(sys.argv[1:])\n", "path": "elasticdl/recordio_ds_gen/cifar10/gen_data.py"}], "after_files": [{"content": "from recordio import File\nfrom elasticdl.recordio_ds_gen.cifar10 import record\nimport sys\nimport argparse\n\n# TODO: share code with MNIST dataset.\ndef main(argv):\n    print(argv)\n    parser = argparse.ArgumentParser(\n        description=\"Show same data from CIFAR10 recordio\"\n    )\n    parser.add_argument(\"file\", help=\"RecordIo file to read\")\n    parser.add_argument(\n        \"--start\", default=0, type=int, help=\"Start record number\"\n    )\n    parser.add_argument(\"--step\", default=1, type=int, help=\"Step\")\n    parser.add_argument(\n        \"--n\", default=20, type=int, help=\"How many record to show\"\n    )\n    args = parser.parse_args(argv)\n\n    with File(args.file, \"r\") as f:\n        for i in range(\n            args.start, args.start + (args.n * args.step), args.step\n        ):\n            print(\"-\" * 10)\n            print(\"record:\", i)\n            record.show(*record.decode(f.get(i)))\n\n\nif __name__ == \"__main__\":\n    main(sys.argv[1:])\n", "path": "elasticdl/recordio_ds_gen/cifar10/show_data.py"}, {"content": "#!/usr/bin/env python\n\n\"\"\"\nDownload and transform CIFAR10 data to RecordIO format.\n\"\"\"\n\nimport itertools\nimport argparse\nimport os\nimport sys\nfrom recordio import File\nfrom tensorflow.python.keras import backend\nfrom tensorflow.python.keras.datasets import cifar10\nfrom elasticdl.recordio_ds_gen.cifar10 import record\n\n# TODO: This function can be shared with MNIST dataset\ndef gen(file_dir, data, label, *, chunk_size, record_per_file):\n    assert len(data) == len(label) and len(data) > 0\n    os.makedirs(file_dir)\n    it = zip(data, label)\n    try:\n        for i in itertools.count():\n            file_name = file_dir + \"/data-%04d\" % i\n            print(\"writing:\", file_name)\n            with File(file_name, \"w\", max_chunk_size=chunk_size) as f:\n                for _ in range(record_per_file):\n                    row = next(it)\n                    f.write(record.encode(row[0], row[1]))\n    except StopIteration:\n        pass\n\n\ndef main(argv):\n    parser = argparse.ArgumentParser(\n        description=\"Generate CIFAR10 datasets in RecordIO format.\"\n    )\n    parser.add_argument(\"dir\", help=\"Output directory\")\n    parser.add_argument(\n        \"--num_record_per_chunk\",\n        default=1024,\n        type=int,\n        help=\"Approximate number of records in a chunk.\",\n    )\n    parser.add_argument(\n        \"--num_chunk\",\n        default=16,\n        type=int,\n        help=\"Number of chunks in a RecordIO file\",\n    )\n    args = parser.parse_args(argv)\n    # one uncompressed record has size 3 * 32 * 32 + 1 bytes.\n    # Also add some slack for safety.\n    chunk_size = args.num_record_per_chunk * (3 * 32 * 32 + 1) + 100\n    record_per_file = args.num_record_per_chunk * args.num_chunk\n    backend.set_image_data_format(\"channels_first\")\n\n    (x_train, y_train), (x_test, y_test) = cifar10.load_data()\n    gen(\n        args.dir + \"/cifar10/train\",\n        x_train,\n        y_train,\n        chunk_size=chunk_size,\n        record_per_file=record_per_file,\n    )\n\n    # Work around a bug in cifar10.load_data() where y_test is not converted\n    # to uint8\n    y_test = y_test.astype(\"uint8\")\n    gen(\n        args.dir + \"/cifar10/test\",\n        x_test,\n        y_test,\n        chunk_size=chunk_size,\n        record_per_file=record_per_file,\n    )\n\n\nif __name__ == \"__main__\":\n    main(sys.argv[1:])\n", "path": "elasticdl/recordio_ds_gen/cifar10/gen_data.py"}]}