def METHOD_NAME(self, image, channel_index):
    """equalize_channel performs histogram equalization on a single channel.
    Args:
        image: int Tensor with pixels in range [0, 255], RGB format,
            with channels last
        channel_index: channel to equalize
    """
    image = image[..., channel_index]
    # Compute the histogram of the image channel.
    histogram = tf.histogram_fixed_width(image, [0, 255], nbins=self.bins)
    # For the purposes of computing the step, filter out the non-zeros.
    # Zeroes are replaced by a big number while calculating min to keep
    # shape constant across input sizes for compatibility with
    # vectorized_map
    big_number = 1410065408
    histogram_without_zeroes = tf.where(
        tf.equal(histogram, 0),
        big_number,
        histogram,
    )
    step = (
        tf.reduce_sum(histogram) - tf.reduce_min(histogram_without_zeroes)
    ) // (self.bins - 1)
    def build_mapping(histogram, step):
        # Compute the cumulative sum, shifting by step // 2
        # and then normalization by step.
        lookup_table = (tf.cumsum(histogram) + (step // 2)) // step
        # Shift lookup_table, prepending with 0.
        lookup_table = tf.concat([[0], lookup_table[:-1]], 0)
        # Clip the counts to be in range. This is done
        # in the C code for image.point.
        return tf.clip_by_value(lookup_table, 0, 255)
    # If step is zero, return the original image. Otherwise, build
    # lookup table from the full histogram and step and then index from it.
    result = tf.cond(
        tf.equal(step, 0),
        lambda: image,
        lambda: tf.gather(build_mapping(histogram, step), image),
    )
    return result