class_docstr: Tokenizing strategy for ShareGPT prompts.
class_docstr_tok: ["Tokenizing","strategy","for","ShareGPT","prompts","."]
code: def tokenize_prompt(self, prompt):
      # Initial values. We will append to these as we go through the conversation.
      result, current_len = tokenize_prompt_default()
      conversation: Conversation = (
          self.prompter._conversation.copy()  # pylint: disable=protected-access
      )
  
      # support for custom roles from the dataset, only useful for vicuna style prompts/roles
      role_remap = []
      if (
          conversation.name == "vicuna_v1.1"
          and "roles" in prompt
          and len(prompt["roles"]) >= 2
      ):
          role_remap = [
              {"from": conversation.roles[0], "to": prompt["roles"][0]},
              {"from": conversation.roles[1], "to": prompt["roles"][1]},
          ]
  
      try:
          for _, part in enumerate(
              self.prompter.build_prompt(
                  self.get_conversation_thread(prompt)
              )
          ):
              if not isinstance(part, tuple):
                  LOG.warning(f"expected tuple, got {part}")
                  continue
  
              user, assistant = conversation.roles
              role, content = part
  
              # Uses "in" because role contains extra characters
              if user in role:
                  role = (
                      role.replace(
                          role_remap[0]["from"], role_remap[0]["to"]
                      )
                      if role_remap
                      else role
                  )
                  turn = role + content
                  # this is still the user query, we should
                  if not content.strip():
                      LOG.warning(f"user turn has empty text: {prompt}")
                  res = self._tokenize(
                      turn,
                      add_eos_token=False,
                      strip_bos_token=True,
                  )
                  if self.train_on_inputs:
                      labels = copy.deepcopy(res["input_ids"])
                  else:
                      # everything from this is masked out from the labels
                      labels = [IGNORE_TOKEN_ID] * len(res["input_ids"])
              elif assistant in role:
                  role = (
                      role.replace(
                          role_remap[1]["from"], role_remap[1]["to"]
                      )
                      if role_remap
                      else role
                  )
                  turn = role + content
                  # this should be the assistant response, should end with an eos token
                  if not content.strip():
                      LOG.warning(
                          f"assistant turn has empty text: {prompt}"
                      )
                  add_eos_token = not (
                      conversation.name == "chatml"
                      and conversation.sep == self.tokenizer.eos_token
                  )
                  res = self._tokenize(
                      turn,
                      add_eos_token=add_eos_token,
                      strip_bos_token=True,
                  )
                  role_res = self._tokenize(
                      role.rstrip(),
                      add_eos_token=False,
                      strip_bos_token=True,
                  )
                  labels = copy.deepcopy(res["input_ids"])
                  if not self.train_on_inputs:
                      # mask out role tokens from the labels
                      len_role = len(role_res["input_ids"])
                      labels[:len_role] = [IGNORE_TOKEN_ID] * min(
                          len_role, len(labels)
                      )
              elif role == "":
                  turn = content
                  # this is only ever the first part, should include the bos token and the user query
                  res = self._tokenize(
                      turn, add_eos_token=False, strip_bos_token=False
                  )
                  if self.train_on_inputs:
                      labels = copy.deepcopy(res["input_ids"])
                  else:
                      # everything from this is masked out from the labels
                      labels = [IGNORE_TOKEN_ID] * len(res["input_ids"])
              else:
                  LOG.warning(f"unhandled role: {role}")
                  continue
  
              # pylint: disable=duplicate-code
              result, current_len = parse_tokenized_to_result(
                  result,
                  current_len,
                  res,
                  labels,
                  pad_token_id=self.tokenizer.pad_token_id,
              )
          return result
      except (KeyError, AssertionError, IndexError) as err:
          raise InvalidDataException(str(err)) from err
  
imports: import abc
  import copy
  import logging
  from typing import Dict, List, Tuple, Union
  from fastchat.conversation import Conversation
  from transformers import BatchEncoding, PreTrainedTokenizer
  from axolotl.monkeypatch.fastchat_conversation_turns import add_get_turns_to_conversation
  from axolotl.prompters import IGNORE_TOKEN_ID
label_desc: Use image node_id 2 for calling the ShareGPTPromptTokenizingStrategy obj's underlying member method code with example usage: obj.tokenize_prompt(prompt) and returns: result