code: def _get_bin_weights(
      boundaries: np.ndarray, cum_bin_weights: np.ndarray
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """Returns bin weights from cumulative bin weights.
  
      Args:
        boundaries: A numpy array of bin boundaries. May not be unique.
        cum_bin_weights: A cumulative sum of bin weights aligned with boundaries.
  
      Returns:
        A tuple of numpy arrays consisting of bin lower bounds, bin upper bounds,
        and the weight falling in each bin. Weight of duplicated bins is spread
        evenly across duplicates.
      """
      cum_bin_weights = cum_bin_weights.astype(np.float64)
      low_bounds = boundaries[:-1]
      high_bounds = boundaries[1:]
      bin_counts = np.diff(cum_bin_weights)
      i = 0
      # First distribute each count across bins with the same upper bound.
      while i < low_bounds.size:
          for j in range(i + 1, low_bounds.size + 1):
              if j == low_bounds.size:
                  break
              if high_bounds[i] != high_bounds[j]:
                  break
          if j > i + 1:
              distributed_weight = bin_counts[i:j].sum() / (j - i)
              bin_counts[i:j] = distributed_weight
          i = j
      # Now distribute the min element count across all identical bins.
      for i in range(low_bounds.size + 1):
          if i == low_bounds.size:
              break
          if (
              low_bounds[0] != low_bounds[i]
              or high_bounds[0] != high_bounds[i]
          ):
              break
      if i > 0:
          bin_counts[0:i] += cum_bin_weights[0] / (i)
      return low_bounds, high_bounds, bin_counts
  
file_path: data-validation/tensorflow_data_validation/utils/quantiles_util.py
imports: from typing import Tuple
  import numpy
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: _get_bin_weights(boundaries, cum_bin_weights) and returns: low_bounds,  high_bounds,  bin_counts