code: def test_make_input_from_valid_json_string(text, factors):
      sentence_id = 1
      translator = mock_translator()
      expected_tokens = list(sockeye.data_io.get_tokens(text))
      inp = sockeye.inference.make_input_from_json_string(
          sentence_id,
          json.dumps(
              {C.JSON_TEXT_KEY: text, C.JSON_FACTORS_KEY: factors}
          ),
          translator,
      )
      assert len(inp) == len(expected_tokens)
      assert inp.tokens == expected_tokens
      if factors is not None:
          assert len(inp.factors) == len(factors)
      else:
          assert inp.factors is None
  
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 9 for calling a global function with example usage: test_make_input_from_valid_json_string(text, factors) without return types