code: def test_factor_parsing(sentence, num_expected_factors, delimiter):
      """
      Test to ensure we fail on parses with invalid factors.
      """
      sentence_id = 1
      translator = mock_translator(
          num_source_factors=num_expected_factors
      )
      inp = sockeye.inference.make_input_from_factored_string(
          sentence_id=sentence_id,
          factored_string=sentence,
          translator=translator,
          delimiter=delimiter,
      )
      assert isinstance(inp, sockeye.inference.BadTranslatorInput)
  
imports: import itertools
  import json
  from math import ceil
  from unittest.mock import patch, Mock
  import numpy
  import pytest
  import torch
  import sockeye.beam_search
  import sockeye.constants
  import sockeye.data_io
  import sockeye.inference
  import sockeye.lexicon
  import sockeye.model
  import sockeye.utils
label_desc: Use image node_id 7 for calling a global function with example usage: test_factor_parsing(sentence, num_expected_factors, delimiter) without return types