code: def create_batch_prediction_df(
      batch,
      tokenizer,
      ids_for_tokenized_text="input_ids",
      labels_column="labels",
  ):
      df = pd.DataFrame(
          {
              "Prompt Text": [
                  tokenizer.decode(input_ids, skip_special_tokens=True)
                  for input_ids in batch["prompt_input_ids"]
                  .detach()
                  .cpu()
                  .numpy()
              ]
          }
      )
      df["Prompt Text"] = df["Prompt Text"].apply(
          format_for_markdown_visualization
      )
      if labels_column in batch.keys():
          df["Answer Text"] = [
              tokenizer.decode(
                  [label for label in labels if label != -100],
                  skip_special_tokens=True,
              )
              for labels in batch.get(
                  labels_column, batch[ids_for_tokenized_text]
              )
              .detach()
              .cpu()
              .numpy()
          ]
      tokens_list = [
          tokenizer.convert_ids_to_tokens(input_ids)
          for input_ids in batch[ids_for_tokenized_text]
          .detach()
          .cpu()
          .numpy()
      ]
      masks_list = [
          [label != -100 for label in labels]
          for labels in batch.get(
              labels_column, batch[ids_for_tokenized_text]
          )
          .detach()
          .cpu()
          .numpy()
      ]
      df["Tokenized Text"] = [
          list_to_markdown_representation(
              tokens,
              masks,
              pad_token=tokenizer.pad_token,
              num_chars=100,
          )
          for tokens, masks in zip(tokens_list, masks_list)
      ]
      # limit to 2000 rows, still renders fast in wave
      df = df.iloc[:2000]
      # Convert into a scrollable table by transposing the dataframe
      df_transposed = pd.DataFrame(
          columns=["Sample Number", "Field", "Content"]
      )
      has_answer = "Answer Text" in df.columns
      for i, row in df.iterrows():
          offset = 2 + int(has_answer)
          df_transposed.loc[i * offset] = [
              i,
              "Prompt Text",
              row["Prompt Text"],
          ]
          if has_answer:
              df_transposed.loc[i * offset + 1] = [
                  i,
                  "Answer Text",
                  row["Answer Text"],
              ]
          df_transposed.loc[i * offset + 1 + int(has_answer)] = [
              i,
              "Tokenized Text",
              row["Tokenized Text"],
          ]
      return df_transposed
  
file_path: h2o-llmstudio/llm_studio/src/plots/text_causal_language_modeling_plots.py
imports: import hashlib
  import os
  from typing import Any, Dict
  import pandas
  from llm_studio.src.datasets.conversation_chain_handler import get_conversation_chains
  from llm_studio.src.datasets.text_utils import get_tokenizer
  from llm_studio.src.utils.data_utils import read_dataframe_drop_missing_labels
  from llm_studio.src.utils.plot_utils import PlotData, format_for_markdown_visualization, list_to_markdown_representation
label_desc: Use image node_id 2 for calling a global function with example usage: create_batch_prediction_df(batch, tokenizer, ids_for_tokenized_text, labels_column) and returns: df_transposed