class_docstr: Dataset for Causal Language modeling.
docstr: Args:
      df: input DataFrame
      cfg: config with all the hyperparameters
      mode: dataset mode. One of {"train", "validation"}
docstr_tok: ["Args",":","df",":","input","DataFrame","cfg",":","config","with","all","the","hyperparameters","mode",":","dataset","mode",".","One","of","{","``","train","''",",","``","validation","''","}"]
code: def __init__(self, df: pd.DataFrame, cfg: Any, mode: str = "train"):
      """
      Args:
          df: input DataFrame
          cfg: config with all the hyperparameters
          mode: dataset mode. One of {"train", "validation"}
      """
      self.cfg = cfg
      self.mode = mode
      self.df = df.copy()
  
      self.tokenizer = get_tokenizer(self.cfg)
      self.conversation_chain_handler = ConversationChainHandler(
          self.df, cfg
      )
  
imports: import codecs
  import collections.abc
  import logging
  from typing import Any, Dict, List, Tuple, Union
  import numpy
  import pandas
  import torch
  from torch.utils.data import Dataset
  from llm_studio.src.datasets.conversation_chain_handler import ConversationChainHandler
  from llm_studio.src.datasets.text_utils import get_tokenizer
label_desc: Use image node_id 1 to create a new CustomDataset object from inherited base classes: Dataset with example: obj = CustomDataset(df, cfg, mode)