code: def compute_dataset_statistics(
      dataset_path: str, cfg_path: str, cfg_hash: str
  ):
      """
      Compute various statistics for a dataset.
      - text length distribution for prompts and answers
      - text length distribution for complete conversations
      - distribution of number of prompt-answer turns per conversation
      - statistics for non text features
  
      We use LRU caching to avoid recomputing the statistics for the same dataset.
      Thus, cfg_hash is used as a function argument to identify the dataset.
      """
      df_train = read_dataframe(dataset_path)
      cfg = load_config_yaml(cfg_path)
      conversations = get_conversation_chains(
          df=df_train, cfg=cfg, limit_chained_samples=True
      )
      stats_dict = {}
      for chat_type in ["prompts", "answers"]:
          text_lengths = [
              [len(text.split(" ")) for text in conversation[chat_type]]
              for conversation in conversations
          ]
          text_lengths = [
              item for sublist in text_lengths for item in sublist
          ]
          stats_dict[chat_type] = text_lengths
      input_texts = []
      for conversation in conversations:
          input_text = conversation["systems"][0]
          prompts = conversation["prompts"]
          answers = conversation["answers"]
          for prompt, answer in zip(prompts, answers):
              input_text += prompt + answer
          input_texts += [input_text]
      stats_dict["complete_conversations"] = [
          len(text.split(" ")) for text in input_texts
      ]
      stats_dict["number_of_prompts"] = [
          len(conversation["prompts"]) for conversation in conversations
      ]
      stats_dict["df_stats"] = get_frame_stats(df_train)
      return stats_dict
  
imports: import functools
  import hashlib
  import logging
  import os
  import re
  import shutil
  import time
  import traceback
  from typing import List, Optional
  import pandas
  from h2o_wave import Q, ui
  from h2o_wave.types import FormCard, ImageCard, MarkupCard, StatListItem, Tab
  from llm_studio.app_utils.config import default_cfg
  from llm_studio.app_utils.db import Dataset
  from llm_studio.app_utils.sections.common import clean_dashboard
  from llm_studio.app_utils.sections.experiment import experiment_start
  from llm_studio.app_utils.sections.histogram_card import histogram_card
  from llm_studio.app_utils.utils import add_model_type, azure_download, azure_file_options, check_valid_upload_content, clean_error, dir_file_table, get_data_dir, get_dataset_elements, get_datasets, get_experiments_status, get_frame_stats, get_model_types, get_problem_types, get_unique_dataset_name, kaggle_download, local_download, make_label, parse_ui_elements, remove_temp_files, s3_download, s3_file_options
  from llm_studio.app_utils.wave_utils import busy_dialog, ui_table_from_df
  from llm_studio.src.datasets.conversation_chain_handler import get_conversation_chains
  from llm_studio.src.utils.config_utils import load_config_py, load_config_yaml, save_config_yaml
  from llm_studio.src.utils.data_utils import get_fill_columns, read_dataframe, read_dataframe_drop_missing_labels, sanity_check
  from llm_studio.src.utils.plot_utils import PlotData
label_desc: Use image node_id 2 for calling a global function with example usage: compute_dataset_statistics(dataset_path, cfg_path, cfg_hash) and returns: stats_dict