class_docstr: A user facing class for text to text generation
class_docstr_tok: ["A","user","facing","class","for","text","to","text","generation"]
code: def _tok_function(
      self,
      raw_dataset,
      args: Union[TTTrainArgs, TTEvalArgs],
      file_type: str,
  ) -> Dataset:
      if not args.max_input_length:
          max_input_length = self.tokenizer.model_max_length
      else:
          max_input_length = args.max_input_length
  
      if not args.max_output_length:
          max_output_length = self.tokenizer.model_max_length
      else:
          max_output_length = args.max_output_length
  
      def __preprocess_function(examples):
          model_inputs = self.tokenizer(
              examples["input"],
              max_length=max_input_length,
              truncation=True,
          )
  
          # Setup the tokenizer for targets
          labels = self.tokenizer(
              examples["target"],
              max_length=max_output_length,
              truncation=True,
          )
  
          model_inputs["labels"] = labels["input_ids"]
          return model_inputs
  
      tok_dataset = raw_dataset.map(
          __preprocess_function,
          batched=True,
          remove_columns=["input", "target"],
      )
  
      return tok_dataset
  
file_path: happy-transformer/happytransformer/happy_text_to_text.py
imports: from dataclasses import dataclass
  from typing import Union
  from datasets import Dataset
  from transformers import AutoModelForSeq2SeqLM, DataCollatorForSeq2Seq, Text2TextGenerationPipeline
  from happytransformer.adaptors import get_adaptor
  from happytransformer.args import TTEvalArgs, TTTestArgs, TTTrainArgs
  from happytransformer.fine_tuning_util import EvalResult
  from happytransformer.happy_transformer import HappyTransformer
label_desc: Use image node_id 7 for calling the HappyTextToText obj's underlying member method code with example usage: obj._tok_function(raw_dataset, args, file_type) and returns: tok_dataset, model_inputs