code: def compute_ratio_dropped(
      contribution_histogram: Histogram,
  ) -> Sequence[Tuple[int, float]]:
      """Computes ratio of dropped data for different bounding thresholds.
  
      For each FrequencyBin.lower in contribution_histogram it computes what would
      the ratio of data dropped because of contribution bounding when it is taken
      as bounding threshold (e.g. in case of L0 histogram bounding_threshold it is
      max_partition_contribution). For convenience the (0, 1) is added as 1st
      element.
  
      Args:
          contribution_histogram: histogram of contributions. It can be L0, L1,
            Linf contribution bounding histogram.
  
      Returns:
          A sequence of sorted pairs
          (bounding_threshold:int, ratio_data_draped:float), where
          bounding_thresholds are all lower of histogram.bins and
          contribution_histogram.max_value.
      """
      if not contribution_histogram.bins:
          return []
      dropped = elements_larger = 0
      total_sum = contribution_histogram.total_sum()
      ratio_dropped = []
      bins = contribution_histogram.bins
      previous_value = bins[-1].lower  # lower of the largest bin.
      if contribution_histogram.max_value() != previous_value:
          # Add ratio for max_value when max_value is not lower in bins.
          ratio_dropped.append(
              (contribution_histogram.max_value(), 0.0)
          )
  
      for bin in bins[::-1]:
          current_value = bin.lower
          dropped += elements_larger * (
              previous_value - current_value
          ) + (bin.sum - bin.count * current_value)
          ratio_dropped.append((current_value, dropped / total_sum))
          previous_value = current_value
          elements_larger += bin.count
      ratio_dropped.append((0, 1))
      return ratio_dropped[::-1]
  
file_path: pipelinedp/pipeline_dp/dataset_histograms/histograms.py
imports: from dataclasses import dataclass, field
  import enum
  from typing import List, Sequence, Tuple, Union
label_desc: Use image node_id 1 for calling a global function with example usage: compute_ratio_dropped(contribution_histogram) and returns: ratio_dropped, list