class_docstr: Forecaster base model for lstm, mtnet, seq2seq and tcn forecasters.
class_docstr_tok: ["Forecaster","base","model","for","lstm",",","mtnet",",","seq2seq","and","tcn","forecasters","."]
docstr: Build onnx model to speed up inference and reduce latency.
  The method is Not required to call before predict_with_onnx,
  evaluate_with_onnx or export_onnx_file.
  It is recommended to use when you want to:
  
  | 1. Strictly control the thread to be used during inferencing.
  | 2. Alleviate the cold start problem when you call predict_with_onnx
       for the first time.
  
  :param thread_num: int, the num of thread limit. The value is set to None by
         default where no limit is set.
  :param sess_options: an onnxruntime.SessionOptions instance, if you set this
         other than None, a new onnxruntime session will be built on this setting
         and ignore other settings you assigned(e.g. thread_num...).
  
  Example:
      >>> # to pre build onnx sess
      >>> forecaster.build_onnx(thread_num=1)  # build onnx runtime sess for single thread
      >>> pred = forecaster.predict_with_onnx(data)
      >>> # ------------------------------------------------------
      >>> # directly call onnx related method is also supported
      >>> pred = forecaster.predict_with_onnx(data)
docstr_tok: ["Build","onnx","model","to","speed","up","inference","and","reduce","latency",".","The","method","is","Not","required","to","call","before","predict_with_onnx",",","evaluate_with_onnx","or","export_onnx_file",".","It","is","recommended","to","use","when","you","want","to",":","|","1",".","Strictly","control","the","thread","to","be","used","during","inferencing",".","|","2",".","Alleviate","the","cold","start","problem","when","you","call","predict_with_onnx","for","the","first","time",".",":","param","thread_num",":","int",",","the","num","of","thread","limit",".","The","value","is","set","to","None","by","default","where","no","limit","is","set",".",":","param","sess_options",":","an","onnxruntime.SessionOptions","instance",",","if","you","set","this","other","than","None",",","a","new","onnxruntime","session","will","be","built","on","this","setting","and","ignore","other","settings","you","assigned","(","e.g",".","thread_num","...",")",".","Example",":",">",">",">","#","to","pre","build","onnx","sess",">",">",">","forecaster.build_onnx","(","thread_num=1",")","#","build","onnx","runtime","sess","for","single","thread",">",">",">","pred","=","forecaster.predict_with_onnx","(","data",")",">",">",">","#","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--","--",">",">",">","#","directly","call","onnx","related","method","is","also","supported",">",">",">","pred","=","forecaster.predict_with_onnx","(","data",")"]
code: def build_onnx(self, thread_num=None, sess_options=None):
      """
      Build onnx model to speed up inference and reduce latency.
      The method is Not required to call before predict_with_onnx,
      evaluate_with_onnx or export_onnx_file.
      It is recommended to use when you want to:
  
      | 1. Strictly control the thread to be used during inferencing.
      | 2. Alleviate the cold start problem when you call predict_with_onnx
           for the first time.
  
      :param thread_num: int, the num of thread limit. The value is set to None by
             default where no limit is set.
      :param sess_options: an onnxruntime.SessionOptions instance, if you set this
             other than None, a new onnxruntime session will be built on this setting
             and ignore other settings you assigned(e.g. thread_num...).
  
      Example:
          >>> # to pre build onnx sess
          >>> forecaster.build_onnx(thread_num=1)  # build onnx runtime sess for single thread
          >>> pred = forecaster.predict_with_onnx(data)
          >>> # ------------------------------------------------------
          >>> # directly call onnx related method is also supported
          >>> pred = forecaster.predict_with_onnx(data)
      """
      import onnxruntime
  
      if sess_options is not None and not isinstance(
          sess_options, onnxruntime.SessionOptions
      ):
          raise RuntimeError(
              "sess_options should be an onnxruntime.SessionOptions instance"
              f", but f{type(sess_options)}"
          )
      if self.distributed:
          raise NotImplementedError(
              "build_onnx has not been supported for distributed\
                                         forecaster. You can call .to_local() to transform the\
                                         forecaster to a non-distributed version."
          )
      import torch
  
      dummy_input = torch.rand(
          1,
          self.data_config["past_seq_len"],
          self.data_config["input_feature_num"],
      )
      self.internal._build_onnx(
          dummy_input,
          dirname=None,
          thread_num=thread_num,
          sess_options=None,
      )
  
file_path: analytics-zoo/pyzoo/zoo/chronos/forecaster/base_forecaster.py
imports: from zoo.chronos.forecaster.abstract import Forecaster
  from zoo.orca.data.shard import SparkXShards
  from zoo.chronos.forecaster.utils import np_to_creator, set_pytorch_seed, check_data, xshard_to_np, np_to_xshard
  import numpy
  from zoo.orca.learn.pytorch.estimator import Estimator
  from zoo.orca.learn.metrics import MSE, MAE
label_desc: Use image node_id 11 for calling the BasePytorchForecaster obj's underlying member method code with example usage: obj.build_onnx(thread_num, sess_options) without return types