class_docstr: Wrapper Class to run Inference.
  
  Args:
      opt: inference options
class_docstr_tok: ["Wrapper","Class","to","run","Inference",".","Args",":","opt",":","inference","options"]
docstr: File inference. Source file must be the opt.src argument
docstr_tok: ["File","inference",".","Source","file","must","be","the","opt.src","argument"]
code: def infer_file(self):
      """File inference. Source file must be the opt.src argument"""
      if self.opt.world_size <= 1:
          infer_iter = build_dynamic_dataset_iter(
              self.opt,
              self.transforms_cls,
              self.vocabs,
              task=CorpusTask.INFER,
              device_id=self.device_id,
          )
          scores, preds = self._translate(infer_iter)
      else:
          scores, preds = self.infer_file_parallel()
      return scores, preds
  
imports: import json
  from onmt.constants import CorpusTask, DefaultTokens, ModelTask
  from onmt.inputters.dynamic_iterator import build_dynamic_dataset_iter
  from onmt.utils.distributed import ErrorHandler, spawned_infer
  from onmt.utils.logging import init_logger
  from onmt.transforms import get_transforms_cls, make_transforms, TransformPipe
label_desc: Use image node_id 4 for calling the InferenceEngine obj's underlying member method code with example usage: obj.infer_file() and returns: scores,  preds