code: def inference(
      ckpt_path,
      inference_input_file,
      inference_output_file,
      hparams,
      num_workers=1,
      jobid=0,
      scope=None,
  ):
      """Perform translation."""
      if hparams.inference_indices:
          assert num_workers == 1
  
      model_creator = get_model_creator(hparams)
      infer_model = model_helper.create_infer_model(
          model_creator, hparams, scope
      )
  
      if hparams.quantize_ckpt or hparams.from_quantized_ckpt:
          model_helper.add_quatization_variables(infer_model)
  
      with tf.Session(
          graph=infer_model.graph, config=utils.get_config_proto()
      ) as sess:
          with infer_model.graph.as_default():
              load_fn = (
                  model_helper.load_model
                  if not hparams.from_quantized_ckpt
                  else model_helper.load_quantized_model
              )
              if hparams.quantize_ckpt:
                  load_fn(infer_model.model, ckpt_path, sess, "infer")
                  load_fn = model_helper.load_quantized_model
                  ckpt_path = os.path.join(
                      hparams.out_dir,
                      "quant_" + os.path.basename(ckpt_path),
                  )
                  model_helper.quantize_checkpoint(sess, ckpt_path)
              loaded_infer_model = load_fn(
                  infer_model.model, ckpt_path, sess, "infer"
              )
  
          if num_workers == 1:
              single_worker_inference(
                  sess,
                  infer_model,
                  loaded_infer_model,
                  inference_input_file,
                  inference_output_file,
                  hparams,
              )
          else:
              multi_worker_inference(
                  sess,
                  infer_model,
                  loaded_infer_model,
                  inference_input_file,
                  inference_output_file,
                  hparams,
                  num_workers=num_workers,
                  jobid=jobid,
              )
  
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 4 for calling a global function with example usage: inference(ckpt_path, inference_input_file, inference_output_file, hparams, num_workers, jobid, scope) without return types