code: def make_input_from_factored_string(
      sentence_id: SentenceId,
      factored_string: str,
      translator: "Translator",
      delimiter: str = C.DEFAULT_FACTOR_DELIMITER,
  ) -> TranslatorInput:
      """
      Returns a TranslatorInput object from a string with factor annotations on a token level, separated by delimiter.
      If translator does not require any source factors, the string is parsed as a plain token string.
  
      :param sentence_id: Sentence id.
      :param factored_string: An input string with additional factors per token, separated by delimiter.
      :param translator: A translator object.
      :param delimiter: A factor delimiter. Default: '|'.
      :return: A TranslatorInput.
      """
      utils.check_condition(
          bool(delimiter) and not delimiter.isspace(),
          "Factor delimiter can not be whitespace or empty.",
      )
  
      model_num_source_factors = translator.num_source_factors
  
      if model_num_source_factors == 1:
          return make_input_from_plain_string(
              sentence_id=sentence_id, string=factored_string
          )
  
      tokens = []  # type: Tokens
      factors = [
          [] for _ in range(model_num_source_factors - 1)
      ]  # type: List[Tokens]
      for token_id, token in enumerate(
          utils.get_tokens(factored_string)
      ):
          pieces = token.split(delimiter)
  
          if not all(pieces) or len(pieces) != model_num_source_factors:
              logger.error(
                  "Failed to parse %d factors at position %d ('%s') in '%s'"
                  % (
                      model_num_source_factors,
                      token_id,
                      token,
                      factored_string.strip(),
                  )
              )
              return _bad_input(sentence_id, reason=factored_string)
  
          tokens.append(pieces[0])
          for i, factor in enumerate(factors):
              factors[i].append(pieces[i + 1])
  
      return TranslatorInput(
          sentence_id=sentence_id, tokens=tokens, factors=factors
      )
  
imports: import copy
  import itertools
  import json
  import logging
  from dataclasses import dataclass
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from .None import constants
  from .None import lexicon
  from .None import utils
  from .None import vocab
  from .beam_search import CandidateScorer, get_search_algorithm, GreedySearch, SearchResult
  from .data_io import tokens2ids, get_prepended_token_length
  from .model import SockeyeModel
label_desc: Use image node_id 7 for calling a global function with example usage: make_input_from_factored_string(sentence_id, factored_string, translator, delimiter) and returns: TranslatorInput, make_input_from_plain_string, _bad_input