code: def _tok_function(
      self, raw_dataset, args: QATrainArgs, file_type: str
  ) -> Dataset:
      def __preprocess_function(case):
          case["answer_start"] = int(case["answer_start"])
          gold_text = case["answer_text"]
          start_idx = case["answer_start"]
          end_idx = start_idx + len(gold_text)
  
          # todo (maybe): strip answer['text'] (remove white space from start and end)
          # sometimes squad answers are off by a character or two – fix this
          if case["context"][start_idx:end_idx] == gold_text:
              case["answer_end"] = end_idx
          elif (
              case["context"][start_idx - 1 : end_idx - 1] == gold_text
          ):
              case["context"]["answer_start"] = start_idx - 1
              case["context"]["answer_end"] = end_idx - 1
          elif case[start_idx - 2 : end_idx - 2] == gold_text:
              case["context"]["answer_start"] = start_idx - 2
              case["context"]["answer_end"] = end_idx - 2
  
          encodings = self.tokenizer(
              case["context"],
              case["question"],
              truncation=True,
              padding=True,
          )
  
          start_position = encodings.char_to_token(case["answer_start"])
          end_position = encodings.char_to_token(case["answer_end"] - 1)
          if start_position is None:
              start_position = self.tokenizer.model_max_length
          if end_position is None:
              end_position = self.tokenizer.model_max_length
  
          encodings.update(
              {
                  "start_positions": start_position,
                  "end_positions": end_position,
              }
          )
  
          return encodings
  
      tok_dataset = raw_dataset.map(
          __preprocess_function,
          batched=False,
          remove_columns=[
              "context",
              "question",
              "answer_text",
              "answer_start",
          ],
          desc="Tokenizing data",
      )
  
      return tok_dataset
  
file_path: happy-transformer/happytransformer/happy_question_answering.py
imports: import csv
  from dataclasses import dataclass
  from typing import List, Union
  from datasets import Dataset
  from transformers import AutoModelForQuestionAnswering, DataCollatorWithPadding, QuestionAnsweringPipeline
  from tqdm import tqdm
  from happytransformer.adaptors import get_adaptor
  from happytransformer.args import QAEvalArgs, QATestArgs, QATrainArgs
  from happytransformer.fine_tuning_util import EvalResult
  from happytransformer.happy_transformer import HappyTransformer
label_desc: Use image node_id 6 for calling the HappyQuestionAnswering obj's underlying member method code with example usage: obj._tok_function(raw_dataset, args, file_type) and returns: tok_dataset, encodings