code: def generate_scores_and_correls_for_dataset(
      dataset_name: str,
      out_dir: str,
      reference_option: str,
      include_baselines: bool,
  ) -> Optional[Tuple[Dict, pandas.DataFrame]]:
      """
      Finds correlations between ROSCOE and baseline scores with annotations for one
      dataset.
      """
      config = DATASET_TO_CONFIG[dataset_name]
      baseline_scores_filename = None
      if include_baselines:
          baseline_scores_filename = config["baseline_scores"]
  
      correl_tables = {}
      pval_tables = {}
  
      for alignment_scores_filename in config["alignment_scores"]:
          model_name = alignment_scores_filename.split("/")[-2]
          file_name = dataset_name + "_all_scores_" + model_name
          out_scores = os.path.join(
              out_dir,
              file_name + ".txt",
          )
          values_by_title = read_and_process_data(
              human_annotation_filename=config["human_labels"][
                  "labels"
              ],
              baseline_scores_filename=baseline_scores_filename,
              roscoe_scores_filename=alignment_scores_filename,
              removed_ids=config["human_labels"]["skip_indices"],
              reference_option=reference_option,
              output_filename=out_scores,
          )
          somersd_table, pval_table = make_correlations_table(
              values_by_title=values_by_title
          )
  
          # format for display
          somersd_table[0] = rename_columns_for_display(
              somersd_table[0]
          )
          pval_table[0] = rename_columns_for_display(pval_table[0])
  
          correl_tables[model_name] = somersd_table
          pval_tables[model_name] = pval_table
  
      base_file_name = f"{dataset_name}_all_scores"
      write_correls_and_sizes_tables(
          out_dir=out_dir,
          base_file_name=base_file_name,
          correl_tables=correl_tables,
      )
  
      correl_tables_df = {
          m: labeled_table_rows_to_dataframe(t)
          for m, t in correl_tables.items()
      }
      pval_tables_df = {
          m: labeled_table_rows_to_dataframe(t)
          for m, t in pval_tables.items()
      }
      granular_sections, pvals_by_section = granular_summary(
          correls_by_model=correl_tables_df,
          pvals_by_model=pval_tables_df,
      )
      write_granular_summary(
          dataset_name=dataset_name,
          granular_sections=granular_sections,
          out_dir=out_dir,
      )
      write_granular_summary_tex(
          dataset_name=dataset_name,
          granular_sections=granular_sections,
          pvals_by_section=pvals_by_section,
          out_dir=out_dir,
      )
      summary_sections = single_dataset_summary_max(
          correls_by_model=correl_tables_df,
          pvals_by_model=pval_tables_df,
      )
      final_summary_df = (
          generate_single_dataset_final_summary_table_max(
              granular_sections=granular_sections,
              pvals_by_section=pvals_by_section,
          )
      )
      return summary_sections, final_summary_df
  
imports: import argparse
  from collections import defaultdict
  import csv
  import math
  import os
  import pathlib
  from typing import Dict, Iterable, List, Optional, Set, Tuple, Union
  import pandas
  from projects.roscoe.meta_evaluation.correlations import Analyzer
  from projects.roscoe.score import ROSCOE_SA, ROSCOE_SS, ROSCOE_LI, ROSCOE_LC, SUPERVISED_SCORES, UNSUPERVISED_SCORES
  from projects.roscoe.utils import assert_all_elements_same_length, ordered_union, split_list
  from projects.roscoe.meta_evaluation.table_file_writing import ANNOTATION_COLUMN_ORDER, COLUMN_RENAMES, MODELS, ROSCOE_SECTIONS, STEP_COLUMN_RENAMES, section_rows, write_every_dataset_summary_table_tex, write_every_dataset_final_summary_table_tex, write_granular_summary_tex
label_desc: Use image node_id 38 for calling a global function with example usage: generate_scores_and_correls_for_dataset(dataset_name, out_dir, reference_option, include_baselines) and returns: summary_sections,  final_summary_df