prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Fix TFExample codec
  
  
  </issue>
  <code>
  [start of record_codec/__init__.py]
  [end of record_codec/__init__.py]
  [start of record_codec/tf_example_codec.py]
  1 from enum import Enum
  2 import tensorflow as tf
  3 
  4 
  5 class TFExampleCodec(object):
  6     def __init__(self, feature_columns):
  7         self._f_name2type = {}
  8         self._example_spec = tf.feature_column.make_parse_example_spec(feature_columns)
  9         for f_col in feature_columns:
  10             self._f_name2type[f_col.key] = f_col.dtype
  11 
  12     def encode(self, example):
  13         f_dict = {}
  14         for f_name, f_value in example:
  15             f_type = self._f_name2type[f_name]
  16             if f_type == tf.string:
  17                 f_dict[f_name] = tf.train.Feature(
  18                     bytes_list=tf.train.BytesList(value=f_value)
  19                 )
  20             elif f_type == tf.float32:
  21                 f_dict[f_name] = tf.train.Feature(
  22                     float_list=tf.train.FloatList(value=f_value.flatten())
  23                 )
  24             elif f_type == tf.int64:
  25                 f_dict[f_name] = tf.train.Feature(
  26                     int64_list=tf.train.Int64List(value=f_value.flatten())
  27                 )
  28             else:
  29                 raise ValueError(
  30                     "not supported tensorflow data type: " + str(f_type)
  31                 )
  32 
  33         example = tf.train.Example(features=tf.train.Features(feature=f_dict))
  34         return example.SerializeToString()
  35 
  36     def decode(self, raw):
  37         return tf.parse_single_example(raw, self._example_spec)
  38
  [end of record_codec/tf_example_codec.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/record_codec/__init__.py b/record_codec/__init__.py
  --- a/record_codec/__init__.py
  +++ b/record_codec/__init__.py
  @@ -0,0 +1,3 @@
  +from record_codec.tf_example_codec import TFExampleCodec
  +
  +__all__=[TFExampleCodec]
  diff --git a/record_codec/tf_example_codec.py b/record_codec/tf_example_codec.py
  --- a/record_codec/tf_example_codec.py
  +++ b/record_codec/tf_example_codec.py
  @@ -4,10 +4,8 @@
   
   class TFExampleCodec(object):
       def __init__(self, feature_columns):
  -        self._f_name2type = {}
           self._example_spec = tf.feature_column.make_parse_example_spec(feature_columns)
  -        for f_col in feature_columns:
  -            self._f_name2type[f_col.key] = f_col.dtype
  +        self._f_name2type = {f_col.key: f_col.dtype for f_col in feature_columns}
   
       def encode(self, example):
           f_dict = {}
  
verification_info: {"golden_diff": "diff --git a/record_codec/__init__.py b/record_codec/__init__.py\n--- a/record_codec/__init__.py\n+++ b/record_codec/__init__.py\n@@ -0,0 +1,3 @@\n+from record_codec.tf_example_codec import TFExampleCodec\n+\n+__all__=[TFExampleCodec]\ndiff --git a/record_codec/tf_example_codec.py b/record_codec/tf_example_codec.py\n--- a/record_codec/tf_example_codec.py\n+++ b/record_codec/tf_example_codec.py\n@@ -4,10 +4,8 @@\n \n class TFExampleCodec(object):\n     def __init__(self, feature_columns):\n-        self._f_name2type = {}\n         self._example_spec = tf.feature_column.make_parse_example_spec(feature_columns)\n-        for f_col in feature_columns:\n-            self._f_name2type[f_col.key] = f_col.dtype\n+        self._f_name2type = {f_col.key: f_col.dtype for f_col in feature_columns}\n \n     def encode(self, example):\n         f_dict = {}\n", "issue": "Fix TFExample codec\n\n", "before_files": [{"content": "", "path": "record_codec/__init__.py"}, {"content": "from enum import Enum\nimport tensorflow as tf\n\n\nclass TFExampleCodec(object):\n    def __init__(self, feature_columns):\n        self._f_name2type = {}\n        self._example_spec = tf.feature_column.make_parse_example_spec(feature_columns)\n        for f_col in feature_columns:\n            self._f_name2type[f_col.key] = f_col.dtype\n\n    def encode(self, example):\n        f_dict = {}\n        for f_name, f_value in example:\n            f_type = self._f_name2type[f_name]\n            if f_type == tf.string:\n                f_dict[f_name] = tf.train.Feature(\n                    bytes_list=tf.train.BytesList(value=f_value)\n                )\n            elif f_type == tf.float32:\n                f_dict[f_name] = tf.train.Feature(\n                    float_list=tf.train.FloatList(value=f_value.flatten())\n                )\n            elif f_type == tf.int64:\n                f_dict[f_name] = tf.train.Feature(\n                    int64_list=tf.train.Int64List(value=f_value.flatten())\n                )\n            else:\n                raise ValueError(\n                    \"not supported tensorflow data type: \" + str(f_type)\n                )\n\n        example = tf.train.Example(features=tf.train.Features(feature=f_dict))\n        return example.SerializeToString()\n\n    def decode(self, raw):\n        return tf.parse_single_example(raw, self._example_spec)\n", "path": "record_codec/tf_example_codec.py"}]}