def METHOD_NAME(values):
    """Convert values into a histogram proto using logic from histogram.cc."""
    limits = _MakeHistogramBuckets()
    counts = [0] * len(limits)
    for v in values:
        idx = bisect.bisect_left(limits, v)
        counts[idx] += 1
    limit_counts = [
        (limits[i], counts[i]) for i in range(len(limits)) if counts[i]
    ]
    bucket_limit = [lc[0] for lc in limit_counts]
    bucket = [lc[1] for lc in limit_counts]
    sum_sq = sum(v * v for v in values)
    return tf.compat.v1.HistogramProto(
        min=min(values),
        max=max(values),
        num=len(values),
        sum=sum(values),
        sum_squares=sum_sq,
        bucket_limit=bucket_limit,
        bucket=bucket,
    )