code: def create_predictor(
      config: PyTextConfig,
      model_file: Optional[str] = None,
      db_type: str = CAFFE2_DB_TYPE,
      task: Optional[NewTask] = None,
      cache_size: int = 0,
  ) -> Predictor:
      """
      Create a simple prediction API from a training config and an exported caffe2
      model file. This model file should be created by calling export on a trained
      model snapshot.
      """
      workspace_id = str(uuid.uuid4())
      workspace.SwitchWorkspace(workspace_id, True)
      predict_net = predictor_exporter.prepare_prediction_net(
          filename=model_file
          or PathManager.get_local_path(config.export_caffe2_path),
          db_type=db_type,
      )
  
      new_task = task or NewTask.from_config(config.task)
      input_tensorizers = {
          name: tensorizer
          for name, tensorizer in new_task.data.tensorizers.items()
          if tensorizer.is_input
      }
  
      def predict_fn(input):
          return _predict(
              workspace_id,
              predict_net,
              new_task.model,
              input_tensorizers,
              input,
          )
  
      if cache_size < 0:
          return lru_cache(maxsize=None)(predict_fn)
      elif cache_size > 0:
          return lru_cache(maxsize=cache_size)(predict_fn)
      else:
          return predict_fn
  
file_path: pytext/pytext/__init__.py
imports: import json
  import logging
  import uuid
  from functools import lru_cache
  from typing import Callable, Mapping, Optional
  import numpy
  from caffe2.python import workspace
  from caffe2.python.predictor import predictor_exporter
  from pytext.data.sources.data_source import DataSource
  from pytext.task import load
  from pytext.task.new_task import NewTask
  from pytext.utils.file_io import PathManager, register_http_url_handler
  from pytext.workflow import _set_cuda
  from .builtin_task import register_builtin_tasks
  from .config import pytext_config_from_json, PyTextConfig
  from .utils.onnx import CAFFE2_DB_TYPE, convert_caffe2_blob_name
label_desc: Use image node_id 3 for calling a global function with example usage: create_predictor(config, model_file, db_type, task, cache_size) and returns: _predict, lru_cache, lru_cache, predict_fn