code: def compute_aggregate_row_win_rates(
      table: Table, aggregation: str = "mean"
  ) -> List[Optional[float]]:
      """
      Computes the aggregate win rate of each row across columns. For a given row r1 and column c1, the win rate of r1 wrt
      to c1 corresponds to: if we pick another row r2 uniformly at random, what is the probability that r1c1 is better
      that r2c1?
      `aggregation` determines how we aggregate win rates across columns, currently can be "mean" or "median".
      We skip columns where "better" is ambiguous or less than 2 values are non-null.
      Returns a list of aggregate win rates, one per row, with None if a row was never meaningfully comparable (i.e., all
      non-null values of the row are in columns we skip).
      """
      assert aggregation in ["mean", "median"]
      win_rates_per_row: List[List[float]] = [[] for _ in table.rows]
      for i, header_cell in enumerate(table.header):
          lower_is_better = header_cell.lower_is_better
          if (
              lower_is_better is None
          ):  # column does not have a meaningful ordering
              continue
  
          # sort row indices by cell value and then compute the number of wins as the index in the sorted list
          def is_cell_valid(
              cell: Cell,
          ) -> (
              bool
          ):  # ignore cells which are strongly contaminated or have no value
              if cell.value is None:
                  return False
              if (
                  cell.contamination_level
                  and cell.contamination_level
                  == CONTAMINATION_LEVEL_STRONG
              ):
                  return False
              return True
  
          values = [
              (row[i].value, j)
              for j, row in enumerate(table.rows)
              if is_cell_valid(row[i])
          ]
          if len(values) < 2:  # don't rank a single model
              continue
          for wins, (v, j) in enumerate(
              sorted(values, reverse=lower_is_better)
          ):
              win_rate = wins / (len(values) - 1)  # normalize to [0, 1]
              win_rates_per_row[j].append(win_rate)
  
      # Note: the logic up to here is somewhat general as it simply computes win rates across columns for each row.
      # Here, we simply average these win rates but we might want some more involved later (e.g., weighted average).
      aggregate_win_rates: List[Optional[float]] = []
      for win_rates in win_rates_per_row:
          if len(win_rates) == 0:
              aggregate_win_rates.append(None)
          else:
              aggregate = (
                  mean(win_rates)
                  if aggregation == "mean"
                  else median(win_rates)
              )
              aggregate_win_rates.append(aggregate)
  
      return aggregate_win_rates
  
imports: import argparse
  import os
  import datetime
  import urllib.parse
  import dacite
  import json
  from collections import defaultdict
  from dataclasses import dataclass, replace
  from statistics import mean, median
  from typing import List, Optional, Dict, Any, Tuple, Set
  from tqdm import tqdm
  from helm.common.general import write, ensure_directory_exists, asdict_without_nones, parallel_map, singleton, unique_simplification
  from helm.common.hierarchical_logger import hlog, htrack, htrack_block
  from helm.benchmark.scenarios.scenario import ScenarioSpec
  from helm.benchmark.adaptation.adapter_spec import AdapterSpec
  from helm.benchmark.metrics.metric_name import MetricName
  from helm.benchmark.metrics.metric import get_all_stats_by_name
  from helm.benchmark.metrics.statistic import Stat, merge_stat
  from helm.benchmark.runner import RunSpec, LATEST_SYMLINK
  from .table import Cell, HeaderCell, Table, Hyperlink, table_to_latex
  from .schema import MetricNameMatcher, RunGroup, read_schema, SCHEMA_YAML_FILENAME, BY_GROUP, THIS_GROUP_ONLY, NO_GROUPS
  from .contamination import read_contamination, validate_contamination, CONTAMINATION_SYMBOLS, CONTAMINATION_STYLES, CONTAMINATION_LEVEL_STRONG
  from .run_display import write_run_display_json
label_desc: Use image node_id 7 for calling a global function with example usage: compute_aggregate_row_win_rates(table, aggregation) and returns: aggregate_win_rates, True, False, False