code: def calculate_pareto_metrics(df_subset: pd.DataFrame) -> pd.DataFrame:
      """Calculates cumulative sums for a subset of a dataframe.
  
      Args:
        df_subset: A dataframe subset of one task.
  
      Returns:
        The same dataframe subset with some additional columns.
      """
      # These are the same for all regions in the same task, for the scatter plot:
      df_subset["task total runtime"] = df_subset["total runtime"].sum()
      df_subset["Runtime for task"] = df_subset[
          "task total runtime"
      ].apply(format_runtime_string)
      df_subset["task num examples"] = df_subset["num examples"].sum()
      # These are cumulative sums for the pareto curves:
      df_subset["task cumsum fraction"] = (
          df_subset["total runtime"].cumsum()
          / df_subset["total runtime"].sum()
      )
      n = len(df_subset)
      df_subset["task cumsum order"] = list(
          map(lambda x: x / n, range(0, n))
      )
      df_subset["tooltip"] = df_subset.apply(
          pareto_by_task_tooltip, axis=1
      )
      return df_subset
  
imports: from typing import Dict, Sequence, List, Tuple, Text, Union
  from absl import app
  from absl import flags
  import altair
  import pandas
  import tensorflow
  from third_party.nucleus.io import sharded_file_utils
  from deepvariant import dashboard_utils
label_desc: Use image node_id 9 for calling a global function with example usage: calculate_pareto_metrics(df_subset) and returns: df_subset