class_docstr: Dataset for Causal Language modeling.
code: def format_output(
      self, cfg, df: pd.DataFrame, output: Dict
  ) -> Tuple[Dict, pd.DataFrame]:
      output = {
          key: value
          for key, value in output.items()
          if key not in ["loss", "target", "losses"]
      }
      output.pop("target_text", None)
  
      # in case limit_chained_samples is True, only last answer is predicted
      end_conversation_ids = (
          self.conversation_chain_handler.get_conversation_end_ids()
      )
  
      if "predicted_text" in output.keys():
          output["predicted_text"] = np.array(output["predicted_text"])
  
      if "logits" in output.keys():
          output["logits"] = np.array(output["logits"].float())
  
      if isinstance(cfg.dataset.prompt_column, tuple):
          for col in cfg.dataset.prompt_column:
              output[col] = df.loc[end_conversation_ids, col].values
      else:
          output[cfg.dataset.prompt_column] = df.loc[
              end_conversation_ids, cfg.dataset.prompt_column
          ].values
  
      if "predicted_text" in output.keys():
          df[f"pred_{cfg.dataset.answer_column}"] = (
              "NO ANSWER GENERATED. "
              "ONLY LAST ANSWER OF A CONVERSATION IS PREDICTED."
          )
          df.loc[
              end_conversation_ids, f"pred_{cfg.dataset.answer_column}"
          ] = output["predicted_text"]
      return output, df
  
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 13 for calling the CustomDataset obj's underlying member method code with example usage: obj.format_output(cfg, df, output) and returns: output,  df