code: def top_2_format_replacements(df, absolute=False):
      to_format = {}
      for column in df.columns:
          to_format[column] = {}
          col_vals = df[column].tolist()
          if all(v == "-" or math.isnan(v) for v in col_vals):
              continue
          if absolute:
              col_vals = [abs(v) for v in col_vals]
          col_vals = set(col_vals)
          first, second = list(reversed(sorted(col_vals)[-2:]))
          to_format[column][first] = f"\\textbf{{{first:.3f}}}"
          to_format[column][second] = f"\\underline{{{second:.3f}}}"
          if absolute:
              neg_first = -1 * first
              neg_second = -1 * second
              to_format[column][
                  neg_first
              ] = f"\\textbf{{{neg_first:.3f}}}"
              to_format[column][
                  neg_second
              ] = f"\\underline{{{neg_second:.3f}}}"
      return to_format
  
file_path: ParlAI/projects/roscoe/meta_evaluation/table_file_writing.py
imports: import copy
  import csv
  import math
  import os
  import pandas
  from typing import Dict, List, Union
  from projects.roscoe.score import FAITHFUL_SENT, FAITHFUL_WORD, INFORM_STEP, REPETITION_WORD, INFORM_CHAIN, REPETITION_SENT, COHERENCE_STEP_VS_STEP, DISCOURSE_REPRESENTATION, GRAMMAR_STEP, PPL_STEP, PPL_CHAIN
label_desc: Use image node_id 4 for calling a global function with example usage: top_2_format_replacements(df, absolute) and returns: to_format