class_docstr: Dataset for DPO optimization.
  The data is assumed to be in the same format as for causal language modeling,
  but an additional column with rejected answers is required.
  For chained conversations, rejected answers are equal normal answers up to the
  last answer. THe last answers are then different.
class_docstr_tok: ["Dataset","for","DPO","optimization",".","The","data","is","assumed","to","be","in","the","same","format","as","for","causal","language","modeling",",","but","an","additional","column","with","rejected","answers","is","required",".","For","chained","conversations",",","rejected","answers","are","equal","normal","answers","up","to","the","last","answer",".","THe","last","answers","are","then","different","."]
code: def __init__(self, df: pd.DataFrame, cfg: Any, mode: str = "train"):
      assert (
          cfg.dataset.limit_chained_samples
      ), "Need to enable limit_chained_samples for dpo training"
      super().__init__(df=df, cfg=cfg, mode=mode)
      with PatchedAttribute(
          cfg.dataset,
          "answer_column",
          cfg.dataset.rejected_answer_column,
      ):
          self.conversation_chain_handler_rejected = (
              ConversationChainHandler(self.df, cfg)
          )
  
file_path: h2o-llmstudio/llm_studio/src/datasets/text_dpo_modeling_ds.py
imports: import logging
  from typing import Any, Dict
  import pandas
  import torch
  import llm_studio.src.datasets.text_causal_language_modeling_ds
  from llm_studio.src.datasets.conversation_chain_handler import ConversationChainHandler
  from llm_studio.src.utils.utils import PatchedAttribute
label_desc: Use image node_id 1 to create a new CustomDataset object from inherited base classes: text_causal_language_modeling_ds with example: obj = CustomDataset(df, cfg, mode)