code: def make_input_from_factored_string(sentence_id: SentenceId,
                                      factored_string: str,
                                      translator: 'Translator',
                                      delimiter: str = C.DEFAULT_FACTOR_DELIMITER) -> 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(data_io.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)
docs: 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.