code: def single_worker_inference(
      sess,
      infer_model,
      loaded_infer_model,
      inference_input_file,
      inference_output_file,
      hparams,
  ):
      """Inference with a single worker."""
      output_infer = inference_output_file
  
      # Read data
      infer_data = load_data(inference_input_file, hparams)
  
      with infer_model.graph.as_default():
          sess.run(
              infer_model.iterator.initializer,
              feed_dict={
                  infer_model.src_placeholder: infer_data,
                  infer_model.batch_size_placeholder: hparams.infer_batch_size,
              },
          )
          # Decode
          utils.print_out("# Start decoding")
          if hparams.inference_indices:
              _decode_inference_indices(
                  loaded_infer_model,
                  sess,
                  output_infer=output_infer,
                  output_infer_summary_prefix=output_infer,
                  inference_indices=hparams.inference_indices,
                  tgt_eos=hparams.eos,
                  subword_option=hparams.subword_option,
              )
          else:
              nmt_utils.decode_and_evaluate(
                  "infer",
                  loaded_infer_model,
                  sess,
                  output_infer,
                  ref_file=None,
                  metrics=hparams.metrics,
                  subword_option=hparams.subword_option,
                  beam_width=hparams.beam_width,
                  tgt_eos=hparams.eos,
                  num_translations_per_input=hparams.num_translations_per_input,
                  infer_mode=hparams.infer_mode,
              )
  
file_path: nlp-architect/examples/sparse_gnmt/inference.py
imports: from __future__ import print_function
  import codecs
  import os
  import time
  import tensorflow
  from .None import gnmt_model
  from .gnmt import attention_model, model
  from .gnmt import model_helper
  from .gnmt.utils import nmt_utils, misc_utils
label_desc: Use image node_id 5 for calling a global function with example usage: single_worker_inference(sess, infer_model, loaded_infer_model, inference_input_file, inference_output_file, hparams) without return types