code: def make_inputs(
      input_file: Optional[str],
      translator: inference.Translator,
      input_is_json: bool,
      input_factors: Optional[List[str]] = None,
  ) -> Generator[inference.TranslatorInput, None, None]:
      """
      Generates TranslatorInput instances from input. If input is None, reads from stdin. If num_input_factors > 1,
      the function will look for factors attached to each token, separated by '|'.
      If source is not None, reads from the source file. If num_source_factors > 1, num_source_factors source factor
      filenames are required.
  
      :param input_file: The source file (possibly None).
      :param translator: Translator that will translate each line of input.
      :param input_is_json: Whether the input is in json format.
      :param input_factors: Source factor files.
      :return: TranslatorInput objects.
      """
      if input_file is None:
          check_condition(
              input_factors is None,
              "Translating from STDIN, not expecting any factor files.",
          )
          for sentence_id, line in enumerate(sys.stdin, 1):
              if input_is_json:
                  yield inference.make_input_from_json_string(
                      sentence_id=sentence_id,
                      json_string=line,
                      translator=translator,
                  )
              else:
                  yield inference.make_input_from_factored_string(
                      sentence_id=sentence_id,
                      factored_string=line,
                      translator=translator,
                  )
      else:
          input_factors = [] if input_factors is None else input_factors
          inputs = [input_file] + input_factors
          if not input_is_json:
              check_condition(
                  translator.num_source_factors == len(inputs),
                  "Model(s) require %d factors, but %d given (through --input and --input-factors)."
                  % (translator.num_source_factors, len(inputs)),
              )
          with ExitStack() as exit_stack:
              streams = [
                  exit_stack.enter_context(smart_open(i))
                  for i in inputs
              ]
              for sentence_id, inputs in enumerate(zip(*streams), 1):
                  if input_is_json:
                      yield inference.make_input_from_json_string(
                          sentence_id=sentence_id,
                          json_string=inputs[0],
                          translator=translator,
                      )
                  else:
                      yield inference.make_input_from_multiple_strings(
                          sentence_id=sentence_id, strings=list(inputs)
                      )
  
file_path: sockeye/sockeye/translate.py
imports: import argparse
  import logging
  import sys
  import time
  from contextlib import ExitStack
  from typing import Dict, Generator, List, Optional, Union
  from sockeye.lexicon import load_restrict_lexicon, RestrictLexicon
  from sockeye.log import setup_main_logger
  from sockeye.model import load_models
  from sockeye.output_handler import get_output_handler, OutputHandler
  from sockeye.utils import log_basic_info, check_condition, grouper, smart_open, seed_rngs
  from .None import arguments
  from .None import constants
  from .None import inference
  from .None import utils
label_desc: Use image node_id 3 for calling a global function with example usage: make_inputs(input_file, translator, input_is_json, input_factors) without return types