code: def table_to_latex(
      table: Table, table_name: str, skip_blank_columns=True
  ) -> str:
      """Return a string representing the latex version of the table."""
      columns_shown = list(range(len(table.header)))
      if skip_blank_columns:
          columns_shown = [
              i
              for i in columns_shown
              if not all(row[i].value is None for row in table.rows)
          ]
  
      lines = []
      lines.append("\\begin{table*}[htp]")
      lines.append("\\resizebox{\\textwidth}{!}{")
      lines.append(
          "\\begin{tabular}{l" + "r" * (len(columns_shown) - 1) + "}"
      )
      lines.append("\\toprule")
      lines.append(
          " & ".join(str(table.header[i].value) for i in columns_shown)
          + " \\\\"
      )
      lines.append("\\midrule")
      for row in table.rows:
          lines.append(
              " & ".join(
                  str(row[i].display_value or row[i].value or "")
                  for i in columns_shown
              )
              + " \\\\"
          )
      lines.append("\\bottomrule")
      lines.append("\\end{tabular}}")
      lines.append("\\caption{Results for " + table_name + "}")
      lines.append("\\label{fig:" + table_name + "}")
      lines.append("\\end{table*}")
  
      latex = "\n".join(lines).replace("%", "\\%")
      return latex
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/presentation/table.py
imports: from dataclasses import dataclass, field
  from typing import Any, Optional, List, Dict
label_desc: Use image node_id 1 for calling a global function with example usage: table_to_latex(table, table_name, skip_blank_columns) and returns: latex