code: def get_hh(
      split: str,
      sanity_check: bool = False,
      silent: bool = False,
      cache_dir: str = None,
  ) -> Dataset:
      """Load the Anthropic Helpful-Harmless dataset from Hugging Face and convert it to the necessary format.
  
      The dataset is converted to a dictionary with the following structure:
      {
          'prompt': List[str],
          'chosen': List[str],
          'rejected': List[str],
      }
  
      Prompts should be structured as follows:
        \n\nHuman: <prompt>\n\nAssistant:
      Multiple turns are allowed, but the prompt should always start with \n\nHuman: and end with \n\nAssistant:.
      """
      dataset = load_dataset(
          "Anthropic/hh-rlhf", split=split, cache_dir=cache_dir
      )
      if sanity_check:
          dataset = dataset.select(range(min(len(dataset), 1000)))
  
      def split_prompt_and_responses(sample) -> Dict[str, str]:
          prompt = extract_anthropic_prompt(sample["chosen"])
          return {
              "prompt": prompt,
              "chosen": sample["chosen"][len(prompt) :],
              "rejected": sample["rejected"][len(prompt) :],
          }
  
      return dataset.map(split_prompt_and_responses)
  
file_path: trl/examples/scripts/dpo.py
imports: from dataclasses import dataclass, field
  from typing import Dict, Optional
  import torch
  from accelerate import PartialState
  from datasets import Dataset, load_dataset
  from peft import LoraConfig
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, HfArgumentParser, TrainingArguments
  from trl import DPOTrainer, is_xpu_available
label_desc: Use image node_id 2 for calling a global function with example usage: get_hh(split, sanity_check, silent, cache_dir) and returns: dataset, dict