code: def add_inference_args(params):
      decode_params = params.add_argument_group("Inference parameters")
  
      decode_params.add_argument(
          C.INFERENCE_ARG_INPUT_LONG,
          C.INFERENCE_ARG_INPUT_SHORT,
          default=None,
          help="Input file to translate. One sentence per line. "
          "If not given, will read from stdin.",
      )
  
      decode_params.add_argument(
          C.INFERENCE_ARG_INPUT_FACTORS_LONG,
          C.INFERENCE_ARG_INPUT_FACTORS_SHORT,
          required=False,
          nargs="+",
          type=regular_file(),
          default=None,
          help="List of input files containing additional source factors,"
          "each token-parallel to the source. Default: %(default)s.",
      )
  
      decode_params.add_argument(
          "--json-input",
          action="store_true",
          default=False,
          help="If given, the CLI expects string-serialized json objects as input."
          "Requires at least the input text field, for example: "
          "{'text': 'some input string'} "
          "Optionally, a list of factors can be provided: "
          "{'text': 'some input string', 'factors': ['C C C', 'X X X']}.",
      )
  
      decode_params.add_argument(
          C.INFERENCE_ARG_OUTPUT_LONG,
          C.INFERENCE_ARG_OUTPUT_SHORT,
          default=None,
          help="Output file to write translations to. "
          "If not given, will write to stdout.",
      )
  
      decode_params.add_argument(
          "--models",
          "-m",
          required=True,
          nargs="+",
          help="Model folder(s). Use multiple for ensemble decoding. "
          "Model determines config, best parameters and vocab files.",
      )
      decode_params.add_argument(
          "--checkpoints",
          "-c",
          default=None,
          type=int,
          nargs="+",
          help="If not given, chooses best checkpoints for model(s). "
          "If specified, must have the same length as --models and be integer",
      )
      decode_params.add_argument(
          "--nbest-size",
          type=int_greater_or_equal(1),
          default=1,
          help="Size of the nbest list of translations. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--beam-size",
          "-b",
          type=int_greater_or_equal(1),
          default=5,
          help="Size of the beam. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--greedy",
          "-g",
          action="store_true",
          default=False,
          help="Enables an alternative, faster greedy decoding implementation. It does not "
          "support batch decoding, ensembles, and hypothesis scores "
          "are not normalized. Default: %(default)s.",
      )
  
      decode_params.add_argument(
          "--beam-search-stop",
          choices=[C.BEAM_SEARCH_STOP_ALL, C.BEAM_SEARCH_STOP_FIRST],
          default=C.BEAM_SEARCH_STOP_ALL,
          help="Stopping criteria. Quit when (all) hypotheses are finished "
          "or when a finished hypothesis is in (first) position. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--batch-size",
          type=int_greater_or_equal(1),
          default=1,
          help="Batch size during decoding. Determines how many sentences are translated "
          "simultaneously. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--chunk-size",
          type=int_greater_or_equal(1),
          default=None,
          help="Size of the chunks to be read from input at once. The chunks are sorted and then "
          "split into batches. Therefore the larger the chunk size the better the grouping "
          "of segments of similar length and therefore the higher the increase in throughput."
          " Default: %d without batching "
          "and %d * batch_size with batching."
          % (C.CHUNK_SIZE_NO_BATCHING, C.CHUNK_SIZE_PER_BATCH_SEGMENT),
      )
      decode_params.add_argument(
          "--sample",
          type=int_greater_or_equal(0),
          default=None,
          nargs="?",
          const=0,
          help="Sample from softmax instead of taking best. Optional argument will restrict "
          "sampling to top N vocabulary items at each step. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--seed",
          type=int,
          default=None,
          help="Random seed used if sampling. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--ensemble-mode",
          type=str,
          default="linear",
          choices=["linear", "log_linear"],
          help="Ensemble mode. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--bucket-width",
          type=int_greater_or_equal(0),
          default=10,
          help="Bucket width for encoder steps. 0 means no bucketing. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--max-input-length",
          type=int_greater_or_equal(1),
          default=None,
          help="Maximum input sequence length. Default: value from model(s).",
      )
      decode_params.add_argument(
          "--max-output-length-num-stds",
          type=int,
          default=C.DEFAULT_NUM_STD_MAX_OUTPUT_LENGTH,
          help="Number of target-to-source length ratio standard deviations from training to add "
          "to calculate maximum output length for beam search for each sentence. "
          "Default: %(default)s.",
      )
      decode_params.add_argument(
          "--max-output-length",
          type=int_greater_or_equal(1),
          default=None,
          help="Maximum number of words to generate during translation. "
          "If None, it will be computed automatically. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--restrict-lexicon",
          nargs="+",
          type=multiple_values(num_values=2, data_type=str),
          default=None,
          help="Specify block or top-k lexicon. A top-k lexicon will pose a positive constraint, "
          "by providing the set of allowed target words. While a blocking lexicon poses a "
          "negative constraint on providing a set of target words to be avoided. "
          "Specifically, a top-k lexicon will restrict the output vocabulary to the k most "
          "likely context-free translations of the source words in each sentence "
          "(Devlin, 2017). See the lexicon module for creating lexicons, i.e. by running "
          "sockeye-lexicon. To use multiple lexicons, provide "
          "'--restrict-lexicon key1:path1 key2:path2 ...' and use JSON input to specify the "
          "lexicon for each sentence: "
          '{"text": "some input string", "restrict_lexicon": "key"}. '
          "If a single lexicon is specified it will be applied to all inputs. "
          "If multiple lexica are specified they can be selected via the JSON input or it "
          "can be skipped by not providing a lexicon in the JSON input. "
          "Default: %(default)s.",
      )
      decode_params.add_argument(
          "--restrict-lexicon-topk",
          type=int,
          default=None,
          help="Specify the number of translations to load for each source word from the lexicon "
          "given with --restrict-lexicon top-k lexicon. "
          "Default: Load all entries from the lexicon.",
      )
  
      decode_params.add_argument(
          "--skip-nvs",
          action="store_true",
          help="Manually turn off Neural Vocabulary Selection (NVS) to do a softmax over the full "
          "target vocabulary.",
          default=False,
      )
  
      decode_params.add_argument(
          "--nvs-thresh",
          type=float,
          help="The probability threshold for a word to be added to the set of target words. "
          "Default: 0.5.",
          default=0.5,
      )
  
      decode_params.add_argument(
          "--strip-unknown-words",
          action="store_true",
          default=False,
          help="Remove any <unk> symbols from outputs. Default: %(default)s.",
      )
      decode_params.add_argument(
          "--prevent-unk",
          action="store_true",
          default=False,
          help="Avoid generating <unk> during decoding. Default: %(default)s.",
      )
  
      decode_params.add_argument(
          "--output-type",
          default="translation",
          choices=C.OUTPUT_HANDLERS,
          help="Output type. Default: %(default)s.",
      )
  
      # common params with score CLI
      add_length_penalty_args(decode_params)
      add_brevity_penalty_args(decode_params)
  
      decode_params.add_argument(
          "--dtype",
          default=None,
          choices=[
              None,
              C.DTYPE_FP32,
              C.DTYPE_FP16,
              C.DTYPE_BF16,
              C.DTYPE_INT8,
          ],
          help="Data type. Default: infers from saved model.",
      )
      add_clamp_to_dtype_arg(decode_params)
  
imports: import argparse
  import os
  import sys
  import types
  from typing import Any, Callable, Dict, List, Tuple, Optional
  import yaml
  from sockeye.utils import smart_open
  from .None import constants
label_desc: Use image node_id 36 for calling a global function with example usage: add_inference_args(params) without return types