code: 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, 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]) // (
          bins - 1
      )
  
      # If step is zero, return the original image.  Otherwise, build
      # lut from the full histogram and step and then index from it.
      if step == 0:
          result = image
      else:
          lut_values = (
              tf.cumsum(histo, exclusive=True) + (step // 2)
          ) // step
          lut_values = tf.clip_by_value(lut_values, 0, bins - 1)
          result = tf.gather(lut_values, image)
  
      return tf.cast(result, image_dtype)
  
file_path: addons/tensorflow_addons/image/color_ops.py
imports: import tensorflow
  from tensorflow_addons.utils.types import TensorLike, Number
  from tensorflow_addons.image.utils import to_4D_image, from_4D_image
  from tensorflow_addons.image.compose_ops import blend
  from typing import Optional
  from functools import partial
label_desc: Use image node_id 1 for calling a global function with example usage: _scale_channel(image, channel, bins) and returns: tf