code: def load_models(opt, inference_mode):
      if CACHE.get("inference_engine", None) is None:
          ArgumentParser.validate_translate_opts(opt)
          ArgumentParser._get_all_transform_translate(opt)
          ArgumentParser._validate_transforms_opts(opt)
          ArgumentParser.validate_translate_opts_dynamic(opt)
          set_random_seed(opt.seed, use_gpu(opt))
          # Build the translator (along with the model)
          if inference_mode == "py":
              print("Inference with py ...")
              from onmt.inference_engine import InferenceEnginePY
  
              CACHE["inference_engine"] = InferenceEnginePY(opt)
          elif inference_mode == "ct2":
              print("Inference with ctranslate2 ...")
              from onmt.inference_engine import InferenceEngineCT2
  
              CACHE["inference_engine"] = InferenceEngineCT2(opt)
          # We need to build the Llama tokenizer to count tokens and prune the history.
          CACHE["tokenizer"] = SentencePieceTransform(opt)
          CACHE["tokenizer"].warm_up()
  
file_path: OpenNMT-py/docs/source/examples/replicate_vicuna/chatbot.py
imports: import argparse
  import gradio
  import numpy
  import time
  import onmt.opts
  from onmt.transforms.tokenize import SentencePieceTransform
  from onmt.utils.parse import ArgumentParser
  from onmt.utils.misc import use_gpu, set_random_seed
label_desc: Use image node_id 4 for calling a global function with example usage: load_models(opt, inference_mode) without return types