class_docstr: Abstract class for compiling results of crowdsourcing runs.
  
  Currently only provides utility attributes/methods for analyzing turn annotations.
docstr: Compile results and save them.
  
  Results will be saved in the format given by --results-format.
docstr_tok: ["Compile","results","and","save","them",".","Results","will","be","saved","in","the","format","given","by","--","results-format","."]
code: def compile_and_save_results(self):
      """
      Compile results and save them.
  
      Results will be saved in the format given by --results-format.
      """
      compiled_results = self.compile_results()
      self._validate_compiled_result_type(compiled_results)
      results_path_base = self.get_results_path_base()
      results_path = f"{results_path_base}.{self.results_format}"
      os.makedirs(self.output_folder, exist_ok=True)
      if self.results_format == "csv":
          if not isinstance(compiled_results, pd.DataFrame):
              logging.warning(
                  "The requested data output format was 'csv' while the data was compiled as a 'dict'. "
                  "Transforming dictionary data into pd.DataFrame using pandas."
              )
              compiled_results = pd.DataFrame.from_dict(
                  compiled_results, orient="index"
              )
          compiled_results.to_csv(results_path, index=False)
      elif self.results_format == "json":
          if isinstance(compiled_results, pd.DataFrame):
              logging.warning(
                  "The requested data output format was 'json' while the data was compiled as a 'dataframe'. "
                  "Transforming dataframe into json using pandas."
              )
              # Reset the index to make each row have a unique index value
              compiled_results.reset_index().to_json(results_path)
          else:
              with open(results_path, "w") as fout:
                  fout.write(json.dumps(compiled_results))
  
      else:
          raise ValueError(
              f'Results save format of "{self.results_format}" currently unsupported!'
          )
      logging.info(f"Wrote results file to {results_path}.")
  
imports: from __future__ import annotations
  import argparse
  import os
  from abc import ABC, abstractmethod
  from datetime import datetime
  import json
  from typing import Any, Dict, List, Union
  import pandas
  from parlai.core.opt import Opt
  import parlai.utils.logging
label_desc: Use image node_id 13 for calling the AbstractResultsCompiler obj's underlying member method code with example usage: obj.compile_and_save_results() without return types