We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ideally the bins in histogram equalization is variable rather than limited to 256 
https://github.com/tensorflow/addons/blob/d26e2ed5f68092aed57016a7005ce534b1be3dce/tensorflow_addons/image/color_ops.py#L36

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tensorflow_addons/image/color_ops.py`
Content:
```
1 # Copyright 2020 The TensorFlow Authors. All Rights Reserved.
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 """Color operations.
16     equalize: Equalizes image histogram
17     sharpness: Sharpen image
18 """
19 
20 import tensorflow as tf
21 
22 from tensorflow_addons.utils.types import TensorLike, Number
23 from tensorflow_addons.image.utils import to_4D_image, from_4D_image
24 from tensorflow_addons.image.compose_ops import blend
25 
26 from typing import Optional
27 from functools import partial
28 
29 
30 def _scale_channel(image: TensorLike, channel: int) -> tf.Tensor:
31     """Scale the data in the channel to implement equalize."""
32     image_dtype = image.dtype
33     image = tf.cast(image[:, :, channel], tf.int32)
34 
35     # Compute the histogram of the image channel.
36     histo = tf.histogram_fixed_width(image, [0, 255], nbins=256)
37 
38     # For the purposes of computing the step, filter out the nonzeros.
39     nonzero_histo = tf.boolean_mask(histo, histo != 0)
40     step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255
41 
42     # If step is zero, return the original image.  Otherwise, build
43     # lut from the full histogram and step and then index from it.
44     if step == 0:
45         result = image
46     else:
47         lut_values = (tf.cumsum(histo, exclusive=True) + (step // 2)) // step
48         lut_values = tf.clip_by_value(lut_values, 0, 255)
49         result = tf.gather(lut_values, image)
50 
51     return tf.cast(result, image_dtype)
52 
53 
54 def _equalize_image(image: TensorLike) -> tf.Tensor:
55     """Implements Equalize function from PIL using TF ops."""
56     image = tf.stack([_scale_channel(image, c) for c in range(image.shape[-1])], -1)
57     return image
58 
59 
60 @tf.function
61 def equalize(image: TensorLike, name: Optional[str] = None) -> tf.Tensor:
62     """Equalize image(s)
63 
64     Args:
65       images: A tensor of shape
66           `(num_images, num_rows, num_columns, num_channels)` (NHWC), or
67           `(num_rows, num_columns, num_channels)` (HWC), or
68           `(num_rows, num_columns)` (HW). The rank must be statically known (the
69           shape is not `TensorShape(None)`).
70       name: The name of the op.
71     Returns:
72       Image(s) with the same type and shape as `images`, equalized.
73     """
74     with tf.name_scope(name or "equalize"):
75         image_dims = tf.rank(image)
76         image = to_4D_image(image)
77         fn = partial(_equalize_image)
78         image = tf.map_fn(fn, image)
79         return from_4D_image(image, image_dims)
80 
81 
82 def _sharpness_image(image: TensorLike, factor: Number) -> tf.Tensor:
83     """Implements Sharpness function from PIL using TF ops."""
84     orig_image = image
85     image_dtype = image.dtype
86     image_channels = image.shape[-1]
87     image = tf.cast(image, tf.float32)
88 
89     # SMOOTH PIL Kernel.
90     kernel = (
91         tf.constant(
92             [[1, 1, 1], [1, 5, 1], [1, 1, 1]], dtype=tf.float32, shape=[3, 3, 1, 1]
93         )
94         / 13.0
95     )
96     kernel = tf.tile(kernel, [1, 1, image_channels, 1])
97 
98     # Apply kernel channel-wise.
99     degenerate = tf.nn.depthwise_conv2d(
100         image, kernel, strides=[1, 1, 1, 1], padding="VALID", dilations=[1, 1]
101     )
102     degenerate = tf.cast(degenerate, image_dtype)
103 
104     # For the borders of the resulting image, fill in the values of the original image.
105     mask = tf.ones_like(degenerate)
106     padded_mask = tf.pad(mask, [[0, 0], [1, 1], [1, 1], [0, 0]])
107     padded_degenerate = tf.pad(degenerate, [[0, 0], [1, 1], [1, 1], [0, 0]])
108     result = tf.where(tf.equal(padded_mask, 1), padded_degenerate, orig_image)
109 
110     # Blend the final result.
111     blended = blend(result, orig_image, factor)
112     return tf.cast(blended, image_dtype)
113 
114 
115 @tf.function
116 def sharpness(
117     image: TensorLike, factor: Number, name: Optional[str] = None
118 ) -> tf.Tensor:
119     """Change sharpness of image(s).
120 
121     Args:
122       image: A tensor of shape
123           `(num_images, num_rows, num_columns, num_channels)` (NHWC), or
124           `(num_rows, num_columns, num_channels)` (HWC)
125       factor: A floating point value or Tensor above 0.0.
126       name: The name of the op.
127     Returns:
128       Image(s) with the same type and shape as `images`, sharper.
129     """
130     with tf.name_scope(name or "sharpness"):
131         image_dims = tf.rank(image)
132         image = to_4D_image(image)
133         image = _sharpness_image(image, factor=factor)
134         return from_4D_image(image, image_dims)
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/tensorflow_addons/image/color_ops.py b/tensorflow_addons/image/color_ops.py
--- a/tensorflow_addons/image/color_ops.py
+++ b/tensorflow_addons/image/color_ops.py
@@ -27,17 +27,17 @@
 from functools import partial
 
 
-def _scale_channel(image: TensorLike, channel: int) -> tf.Tensor:
+def _scale_channel(image: TensorLike, channel: int, bins: int = 256) -> tf.Tensor:
     """Scale the data in the channel to implement equalize."""
     image_dtype = image.dtype
     image = tf.cast(image[:, :, channel], tf.int32)
 
     # Compute the histogram of the image channel.
-    histo = tf.histogram_fixed_width(image, [0, 255], nbins=256)
+    histo = tf.histogram_fixed_width(image, [0, bins - 1], nbins=bins)
 
     # For the purposes of computing the step, filter out the nonzeros.
     nonzero_histo = tf.boolean_mask(histo, histo != 0)
-    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255
+    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // (bins - 1)
 
     # If step is zero, return the original image.  Otherwise, build
     # lut from the full histogram and step and then index from it.
@@ -45,20 +45,24 @@
         result = image
     else:
         lut_values = (tf.cumsum(histo, exclusive=True) + (step // 2)) // step
-        lut_values = tf.clip_by_value(lut_values, 0, 255)
+        lut_values = tf.clip_by_value(lut_values, 0, bins - 1)
         result = tf.gather(lut_values, image)
 
     return tf.cast(result, image_dtype)
 
 
-def _equalize_image(image: TensorLike) -> tf.Tensor:
+def _equalize_image(image: TensorLike, bins: int = 256) -> tf.Tensor:
     """Implements Equalize function from PIL using TF ops."""
-    image = tf.stack([_scale_channel(image, c) for c in range(image.shape[-1])], -1)
+    image = tf.stack(
+        [_scale_channel(image, c, bins) for c in range(image.shape[-1])], -1
+    )
     return image
 
 
 @tf.function
-def equalize(image: TensorLike, name: Optional[str] = None) -> tf.Tensor:
+def equalize(
+    image: TensorLike, bins: int = 256, name: Optional[str] = None
+) -> tf.Tensor:
     """Equalize image(s)
 
     Args:
@@ -67,6 +71,7 @@
           `(num_rows, num_columns, num_channels)` (HWC), or
           `(num_rows, num_columns)` (HW). The rank must be statically known (the
           shape is not `TensorShape(None)`).
+      bins: The number of bins in the histogram.
       name: The name of the op.
     Returns:
       Image(s) with the same type and shape as `images`, equalized.
@@ -75,7 +80,7 @@
         image_dims = tf.rank(image)
         image = to_4D_image(image)
         fn = partial(_equalize_image)
-        image = tf.map_fn(fn, image)
+        image = tf.map_fn(lambda x: fn(x, bins), image)
         return from_4D_image(image, image_dims)

{"golden_diff": "diff --git a/tensorflow_addons/image/color_ops.py b/tensorflow_addons/image/color_ops.py\n--- a/tensorflow_addons/image/color_ops.py\n+++ b/tensorflow_addons/image/color_ops.py\n@@ -27,17 +27,17 @@\n from functools import partial\n \n \n-def _scale_channel(image: TensorLike, channel: int) -> tf.Tensor:\n+def _scale_channel(image: TensorLike, channel: int, bins: int = 256) -> tf.Tensor:\n     \"\"\"Scale the data in the channel to implement equalize.\"\"\"\n     image_dtype = image.dtype\n     image = tf.cast(image[:, :, channel], tf.int32)\n \n     # Compute the histogram of the image channel.\n-    histo = tf.histogram_fixed_width(image, [0, 255], nbins=256)\n+    histo = tf.histogram_fixed_width(image, [0, bins - 1], nbins=bins)\n \n     # For the purposes of computing the step, filter out the nonzeros.\n     nonzero_histo = tf.boolean_mask(histo, histo != 0)\n-    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255\n+    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // (bins - 1)\n \n     # If step is zero, return the original image.  Otherwise, build\n     # lut from the full histogram and step and then index from it.\n@@ -45,20 +45,24 @@\n         result = image\n     else:\n         lut_values = (tf.cumsum(histo, exclusive=True) + (step // 2)) // step\n-        lut_values = tf.clip_by_value(lut_values, 0, 255)\n+        lut_values = tf.clip_by_value(lut_values, 0, bins - 1)\n         result = tf.gather(lut_values, image)\n \n     return tf.cast(result, image_dtype)\n \n \n-def _equalize_image(image: TensorLike) -> tf.Tensor:\n+def _equalize_image(image: TensorLike, bins: int = 256) -> tf.Tensor:\n     \"\"\"Implements Equalize function from PIL using TF ops.\"\"\"\n-    image = tf.stack([_scale_channel(image, c) for c in range(image.shape[-1])], -1)\n+    image = tf.stack(\n+        [_scale_channel(image, c, bins) for c in range(image.shape[-1])], -1\n+    )\n     return image\n \n \n @tf.function\n-def equalize(image: TensorLike, name: Optional[str] = None) -> tf.Tensor:\n+def equalize(\n+    image: TensorLike, bins: int = 256, name: Optional[str] = None\n+) -> tf.Tensor:\n     \"\"\"Equalize image(s)\n \n     Args:\n@@ -67,6 +71,7 @@\n           `(num_rows, num_columns, num_channels)` (HWC), or\n           `(num_rows, num_columns)` (HW). The rank must be statically known (the\n           shape is not `TensorShape(None)`).\n+      bins: The number of bins in the histogram.\n       name: The name of the op.\n     Returns:\n       Image(s) with the same type and shape as `images`, equalized.\n@@ -75,7 +80,7 @@\n         image_dims = tf.rank(image)\n         image = to_4D_image(image)\n         fn = partial(_equalize_image)\n-        image = tf.map_fn(fn, image)\n+        image = tf.map_fn(lambda x: fn(x, bins), image)\n         return from_4D_image(image, image_dims)\n", "issue": "Ideally the bins in histogram equalization is variable rather than limited to 256 \nhttps://github.com/tensorflow/addons/blob/d26e2ed5f68092aed57016a7005ce534b1be3dce/tensorflow_addons/image/color_ops.py#L36\n", "before_files": [{"content": "# Copyright 2020 The TensorFlow Authors. All Rights Reserved.\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# ==============================================================================\n\"\"\"Color operations.\n    equalize: Equalizes image histogram\n    sharpness: Sharpen image\n\"\"\"\n\nimport tensorflow as tf\n\nfrom tensorflow_addons.utils.types import TensorLike, Number\nfrom tensorflow_addons.image.utils import to_4D_image, from_4D_image\nfrom tensorflow_addons.image.compose_ops import blend\n\nfrom typing import Optional\nfrom functools import partial\n\n\ndef _scale_channel(image: TensorLike, channel: int) -> tf.Tensor:\n    \"\"\"Scale the data in the channel to implement equalize.\"\"\"\n    image_dtype = image.dtype\n    image = tf.cast(image[:, :, channel], tf.int32)\n\n    # Compute the histogram of the image channel.\n    histo = tf.histogram_fixed_width(image, [0, 255], nbins=256)\n\n    # For the purposes of computing the step, filter out the nonzeros.\n    nonzero_histo = tf.boolean_mask(histo, histo != 0)\n    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // 255\n\n    # If step is zero, return the original image.  Otherwise, build\n    # lut from the full histogram and step and then index from it.\n    if step == 0:\n        result = image\n    else:\n        lut_values = (tf.cumsum(histo, exclusive=True) + (step // 2)) // step\n        lut_values = tf.clip_by_value(lut_values, 0, 255)\n        result = tf.gather(lut_values, image)\n\n    return tf.cast(result, image_dtype)\n\n\ndef _equalize_image(image: TensorLike) -> tf.Tensor:\n    \"\"\"Implements Equalize function from PIL using TF ops.\"\"\"\n    image = tf.stack([_scale_channel(image, c) for c in range(image.shape[-1])], -1)\n    return image\n\n\n@tf.function\ndef equalize(image: TensorLike, name: Optional[str] = None) -> tf.Tensor:\n    \"\"\"Equalize image(s)\n\n    Args:\n      images: A tensor of shape\n          `(num_images, num_rows, num_columns, num_channels)` (NHWC), or\n          `(num_rows, num_columns, num_channels)` (HWC), or\n          `(num_rows, num_columns)` (HW). The rank must be statically known (the\n          shape is not `TensorShape(None)`).\n      name: The name of the op.\n    Returns:\n      Image(s) with the same type and shape as `images`, equalized.\n    \"\"\"\n    with tf.name_scope(name or \"equalize\"):\n        image_dims = tf.rank(image)\n        image = to_4D_image(image)\n        fn = partial(_equalize_image)\n        image = tf.map_fn(fn, image)\n        return from_4D_image(image, image_dims)\n\n\ndef _sharpness_image(image: TensorLike, factor: Number) -> tf.Tensor:\n    \"\"\"Implements Sharpness function from PIL using TF ops.\"\"\"\n    orig_image = image\n    image_dtype = image.dtype\n    image_channels = image.shape[-1]\n    image = tf.cast(image, tf.float32)\n\n    # SMOOTH PIL Kernel.\n    kernel = (\n        tf.constant(\n            [[1, 1, 1], [1, 5, 1], [1, 1, 1]], dtype=tf.float32, shape=[3, 3, 1, 1]\n        )\n        / 13.0\n    )\n    kernel = tf.tile(kernel, [1, 1, image_channels, 1])\n\n    # Apply kernel channel-wise.\n    degenerate = tf.nn.depthwise_conv2d(\n        image, kernel, strides=[1, 1, 1, 1], padding=\"VALID\", dilations=[1, 1]\n    )\n    degenerate = tf.cast(degenerate, image_dtype)\n\n    # For the borders of the resulting image, fill in the values of the original image.\n    mask = tf.ones_like(degenerate)\n    padded_mask = tf.pad(mask, [[0, 0], [1, 1], [1, 1], [0, 0]])\n    padded_degenerate = tf.pad(degenerate, [[0, 0], [1, 1], [1, 1], [0, 0]])\n    result = tf.where(tf.equal(padded_mask, 1), padded_degenerate, orig_image)\n\n    # Blend the final result.\n    blended = blend(result, orig_image, factor)\n    return tf.cast(blended, image_dtype)\n\n\n@tf.function\ndef sharpness(\n    image: TensorLike, factor: Number, name: Optional[str] = None\n) -> tf.Tensor:\n    \"\"\"Change sharpness of image(s).\n\n    Args:\n      image: A tensor of shape\n          `(num_images, num_rows, num_columns, num_channels)` (NHWC), or\n          `(num_rows, num_columns, num_channels)` (HWC)\n      factor: A floating point value or Tensor above 0.0.\n      name: The name of the op.\n    Returns:\n      Image(s) with the same type and shape as `images`, sharper.\n    \"\"\"\n    with tf.name_scope(name or \"sharpness\"):\n        image_dims = tf.rank(image)\n        image = to_4D_image(image)\n        image = _sharpness_image(image, factor=factor)\n        return from_4D_image(image, image_dims)\n", "path": "tensorflow_addons/image/color_ops.py"}], "after_files": [{"content": "# Copyright 2020 The TensorFlow Authors. All Rights Reserved.\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# ==============================================================================\n\"\"\"Color operations.\n    equalize: Equalizes image histogram\n    sharpness: Sharpen image\n\"\"\"\n\nimport tensorflow as tf\n\nfrom tensorflow_addons.utils.types import TensorLike, Number\nfrom tensorflow_addons.image.utils import to_4D_image, from_4D_image\nfrom tensorflow_addons.image.compose_ops import blend\n\nfrom typing import Optional\nfrom functools import partial\n\n\ndef _scale_channel(image: TensorLike, channel: int, bins: int = 256) -> tf.Tensor:\n    \"\"\"Scale the data in the channel to implement equalize.\"\"\"\n    image_dtype = image.dtype\n    image = tf.cast(image[:, :, channel], tf.int32)\n\n    # Compute the histogram of the image channel.\n    histo = tf.histogram_fixed_width(image, [0, bins - 1], nbins=bins)\n\n    # For the purposes of computing the step, filter out the nonzeros.\n    nonzero_histo = tf.boolean_mask(histo, histo != 0)\n    step = (tf.reduce_sum(nonzero_histo) - nonzero_histo[-1]) // (bins - 1)\n\n    # If step is zero, return the original image.  Otherwise, build\n    # lut from the full histogram and step and then index from it.\n    if step == 0:\n        result = image\n    else:\n        lut_values = (tf.cumsum(histo, exclusive=True) + (step // 2)) // step\n        lut_values = tf.clip_by_value(lut_values, 0, bins - 1)\n        result = tf.gather(lut_values, image)\n\n    return tf.cast(result, image_dtype)\n\n\ndef _equalize_image(image: TensorLike, bins: int = 256) -> tf.Tensor:\n    \"\"\"Implements Equalize function from PIL using TF ops.\"\"\"\n    image = tf.stack(\n        [_scale_channel(image, c, bins) for c in range(image.shape[-1])], -1\n    )\n    return image\n\n\n@tf.function\ndef equalize(\n    image: TensorLike, bins: int = 256, name: Optional[str] = None\n) -> tf.Tensor:\n    \"\"\"Equalize image(s)\n\n    Args:\n      images: A tensor of shape\n          `(num_images, num_rows, num_columns, num_channels)` (NHWC), or\n          `(num_rows, num_columns, num_channels)` (HWC), or\n          `(num_rows, num_columns)` (HW). The rank must be statically known (the\n          shape is not `TensorShape(None)`).\n      bins: The number of bins in the histogram.\n      name: The name of the op.\n    Returns:\n      Image(s) with the same type and shape as `images`, equalized.\n    \"\"\"\n    with tf.name_scope(name or \"equalize\"):\n        image_dims = tf.rank(image)\n        image = to_4D_image(image)\n        fn = partial(_equalize_image)\n        image = tf.map_fn(lambda x: fn(x, bins), image)\n        return from_4D_image(image, image_dims)\n\n\ndef _sharpness_image(image: TensorLike, factor: Number) -> tf.Tensor:\n    \"\"\"Implements Sharpness function from PIL using TF ops.\"\"\"\n    orig_image = image\n    image_dtype = image.dtype\n    image_channels = image.shape[-1]\n    image = tf.cast(image, tf.float32)\n\n    # SMOOTH PIL Kernel.\n    kernel = (\n        tf.constant(\n            [[1, 1, 1], [1, 5, 1], [1, 1, 1]], dtype=tf.float32, shape=[3, 3, 1, 1]\n        )\n        / 13.0\n    )\n    kernel = tf.tile(kernel, [1, 1, image_channels, 1])\n\n    # Apply kernel channel-wise.\n    degenerate = tf.nn.depthwise_conv2d(\n        image, kernel, strides=[1, 1, 1, 1], padding=\"VALID\", dilations=[1, 1]\n    )\n    degenerate = tf.cast(degenerate, image_dtype)\n\n    # For the borders of the resulting image, fill in the values of the original image.\n    mask = tf.ones_like(degenerate)\n    padded_mask = tf.pad(mask, [[0, 0], [1, 1], [1, 1], [0, 0]])\n    padded_degenerate = tf.pad(degenerate, [[0, 0], [1, 1], [1, 1], [0, 0]])\n    result = tf.where(tf.equal(padded_mask, 1), padded_degenerate, orig_image)\n\n    # Blend the final result.\n    blended = blend(result, orig_image, factor)\n    return tf.cast(blended, image_dtype)\n\n\n@tf.function\ndef sharpness(\n    image: TensorLike, factor: Number, name: Optional[str] = None\n) -> tf.Tensor:\n    \"\"\"Change sharpness of image(s).\n\n    Args:\n      image: A tensor of shape\n          `(num_images, num_rows, num_columns, num_channels)` (NHWC), or\n          `(num_rows, num_columns, num_channels)` (HWC)\n      factor: A floating point value or Tensor above 0.0.\n      name: The name of the op.\n    Returns:\n      Image(s) with the same type and shape as `images`, sharper.\n    \"\"\"\n    with tf.name_scope(name or \"sharpness\"):\n        image_dims = tf.rank(image)\n        image = to_4D_image(image)\n        image = _sharpness_image(image, factor=factor)\n        return from_4D_image(image, image_dims)\n", "path": "tensorflow_addons/image/color_ops.py"}]}