class_docstr: Forecaster base model for lstm, seq2seq, tcn and nbeats forecasters.
class_docstr_tok: ["Forecaster","base","model","for","lstm",",","seq2seq",",","tcn","and","nbeats","forecasters","."]
docstr: Predict using a trained forecaster with onnxruntime. The method can only be
  used when forecaster is a non-distributed version.
  
  Directly call this method without calling build_onnx is valid and Forecaster will
  automatically build an onnxruntime session with default settings (thread num is 1).
  
  :param data: The data support following formats:
  
         | 1. a numpy ndarray x:
         | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
         | should be the same as past_seq_len and input_feature_num.
         |
         | 2. pytorch dataloader:
         | the dataloader needs to return at least x in each iteration
         | with the shape as following:
         | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
         | should be the same as past_seq_len and input_feature_num.
         | If returns x and y only get x.
         |
         | 3. A bigdl.chronos.data.tsdataset.TSDataset instance:
         | Forecaster will automatically process the TSDataset.
         | By default, TSDataset will be transformed to a pytorch dataloader,
         | which is memory-friendly while a little bit slower.
         | Users may call `roll` on the TSDataset before calling `fit`
         | Then the training speed will be faster but will consume more memory.
  
  :param batch_size: predict batch size. The value will not affect predict
         result but will affect resources cost(e.g. memory and time). Defaults
         to 32. None for all-data-single-time inference.
  :param quantize: if use the quantized onnx model to predict.
  
  :return: A numpy array with shape (num_samples, horizon, target_dim).
code: def predict_with_onnx(self, data, batch_size=32, quantize=False):
      """
      Predict using a trained forecaster with onnxruntime. The method can only be
      used when forecaster is a non-distributed version.
  
      Directly call this method without calling build_onnx is valid and Forecaster will
      automatically build an onnxruntime session with default settings (thread num is 1).
  
      :param data: The data support following formats:
  
             | 1. a numpy ndarray x:
             | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
             | should be the same as past_seq_len and input_feature_num.
             |
             | 2. pytorch dataloader:
             | the dataloader needs to return at least x in each iteration
             | with the shape as following:
             | x's shape is (num_samples, lookback, feature_dim) where lookback and feature_dim
             | should be the same as past_seq_len and input_feature_num.
             | If returns x and y only get x.
             |
             | 3. A bigdl.chronos.data.tsdataset.TSDataset instance:
             | Forecaster will automatically process the TSDataset.
             | By default, TSDataset will be transformed to a pytorch dataloader,
             | which is memory-friendly while a little bit slower.
             | Users may call `roll` on the TSDataset before calling `fit`
             | Then the training speed will be faster but will consume more memory.
  
      :param batch_size: predict batch size. The value will not affect predict
             result but will affect resources cost(e.g. memory and time). Defaults
             to 32. None for all-data-single-time inference.
      :param quantize: if use the quantized onnx model to predict.
  
      :return: A numpy array with shape (num_samples, horizon, target_dim).
      """
      if self.distributed:
          invalidInputError(
              False,
              "ONNX inference has not been supported for distributed "
              "forecaster. You can call .to_local() to transform the "
              "forecaster to a non-distributed version.",
          )
      if not self.fitted:
          invalidInputError(
              False,
              "You must call fit or restore first before calling predict!",
          )
  
      self.thread_num = set_pytorch_thread(
          self.optimized_model_thread_num, self.thread_num
      )
  
      if isinstance(data, TSDataset):
          _rolled = data.numpy_x is None
          data = data.to_torch_data_loader(
              batch_size=batch_size,
              roll=_rolled,
              lookback=self.data_config["past_seq_len"],
              horizon=self.data_config["future_seq_len"],
              feature_col=data.roll_feature,
              target_col=data.roll_target,
              shuffle=False,
          )
      if not self.context_enabled:
          self.cxt_manager = ForecasterContextManager(
              self, self.thread_num, True
          )
      else:
          self.cxt_manager = DummyForecasterContextManager()
      with self.cxt_manager:
          if quantize:
              if self.accelerate_method != "onnxruntime_int8":
                  invalidInputError(
                      False,
                      "Can't find the quantized model, "
                      "please call .quantize() method first",
                  )
              return _pytorch_fashion_inference(
                  model=self.accelerated_model,
                  input_data=data,
                  batch_size=batch_size,
                  output_tensor=self.optimized_model_output_tensor,
              )
          else:
              if self.accelerate_method != "onnxruntime_fp32":
                  self.build_onnx(self.thread_num)
              return _pytorch_fashion_inference(
                  model=self.accelerated_model,
                  input_data=data,
                  batch_size=batch_size,
                  output_tensor=self.optimized_model_output_tensor,
              )
  
imports: from bigdl.chronos.forecaster.abstract import Forecaster
  from bigdl.chronos.forecaster.utils import *
  from bigdl.chronos.metric.forecast_metrics import Evaluator
  from typing import Optional
  import numpy
  import warnings
  import os
  from tempfile import TemporaryDirectory
  import torch
  from torch.utils.data import TensorDataset, DataLoader
  from .utils_hpo import GenericLightningModule, _format_metric_str, _config_has_search_space
  from bigdl.nano.utils.common import invalidOperationError, invalidInputError
  from bigdl.chronos.data.tsdataset import TSDataset
  from bigdl.chronos.pytorch.context_manager import DummyForecasterContextManager, ForecasterContextManager
  from bigdl.chronos.pytorch.utils import _pytorch_fashion_inference
label_desc: Use image node_id 9 for calling the BasePytorchForecaster obj's underlying member method code with example usage: obj.predict_with_onnx(data, batch_size, quantize) and returns: _pytorch_fashion_inference, _pytorch_fashion_inference