class_docstr: TSPipeline is an E2E solution for time series analysis (only forecasting task for now).
  You can use TSPipeline to:
  
  1. Further development on the prototype. (predict, evaluate, incremental fit)
  
  2. Deploy the model to their scenario. (save, load)
docstr: Quantization TSPipeline.
  
  :param calib_data: Required for static quantization or evaluation.
  
         | 1. data creator:
         | a function that takes a config dictionary as parameter and
         | returns a PyTorch DataLoader.
         |
         | 2. a bigdl.chronos.data.TSDataset:
         | the TSDataset should follow the same operations as the training
         | TSDataset used in `AutoTSEstimator.fit`.
         |
         | 3. A torch.utils.data.dataloader.DataLoader object for calibration,
         | Users should set the configs correctly (e.g. past_seq_len, ...).
         | They can be found in TSPipeline._best_config.
         |
         | 4. A numpy ndarray tuple (x, y).
         | x's shape is (num_samples, past_seq_len, input_feature_dim).
         | y's shape is (num_samples, future_seq_len, output_feature_dim).
         | They can be found in TSPipeline._best_config.
  
  :param metric: A str represent the metrics for tunning the quality of
         quantization. You may choose from "mse", "mae", "rmse", "r2", "mape", "smape".
  :param conf: A path to conf yaml file for quantization. Default to None,
         using default config.
  :param framework: string or list, [{'pytorch'|'pytorch_fx'|'pytorch_ipex'},
         {'onnxrt_integerops'|'onnxrt_qlinearops'}]. Default: 'pytorch_fx'.
         Consistent with Intel Neural Compressor.
  :param approach: str, 'static' or 'dynamic'. Default to 'static'.
  :param tuning_strategy: str, 'bayesian', 'basic', 'mse' or 'sigopt'. Default to 'bayesian'.
  :param relative_drop: Float, tolerable ralative accuracy drop. Default to None,
         e.g. set to 0.1 means that we accept a 10% increase in the metrics error.
  :param absolute_drop: Float, tolerable ralative accuracy drop. Default to None,
         e.g. set to 5 means that we can only accept metrics smaller than 5.
  :param timeout: Tuning timeout (seconds). Default to 0, which means early stop.
         Combine with max_trials field to decide when to exit.
  :param max_trials: Max tune times. Default to 1. Combine with timeout field to
         decide when to exit. "timeout=0, max_trials=1" means it will try quantization
         only once and return satisfying best model.
docstr_tok: ["Quantization","TSPipeline",".",":","param","calib_data",":","Required","for","static","quantization","or","evaluation",".","|","1.","data","creator",":","|","a","function","that","takes","a","config","dictionary","as","parameter","and","|","returns","a","PyTorch","DataLoader",".","|","|","2.","a","bigdl.chronos.data.TSDataset",":","|","the","TSDataset","should","follow","the","same","operations","as","the","training","|","TSDataset","used","in","`","AutoTSEstimator.fit","`",".","|","|","3",".","A","torch.utils.data.dataloader.DataLoader","object","for","calibration",",","|","Users","should","set","the","configs","correctly","(","e.g",".","past_seq_len",",","...",")",".","|","They","can","be","found","in","TSPipeline._best_config",".","|","|","4",".","A","numpy","ndarray","tuple","(","x",",","y",")",".","|","x","'s","shape","is","(","num_samples",",","past_seq_len",",","input_feature_dim",")",".","|","y","'s","shape","is","(","num_samples",",","future_seq_len",",","output_feature_dim",")",".","|","They","can","be","found","in","TSPipeline._best_config",".",":","param","metric",":","A","str","represent","the","metrics","for","tunning","the","quality","of","quantization",".","You","may","choose","from","``","mse","''",",","``","mae","''",",","``","rmse","''",",","``","r2","''",",","``","mape","''",",","``","smape","''",".",":","param","conf",":","A","path","to","conf","yaml","file","for","quantization",".","Default","to","None",",","using","default","config",".",":","param","framework",":","string","or","list",",","[","{","'pytorch'|'pytorch_fx'|'pytorch_ipex","'","}",",","{","'onnxrt_integerops'|'onnxrt_qlinearops","'","}","]",".","Default",":","'pytorch_fx","'",".","Consistent","with","Intel","Neural","Compressor",".",":","param","approach",":","str",",","'static","'","or","'dynamic","'",".","Default","to","'static","'",".",":","param","tuning_strategy",":","str",",","'bayesian","'",",","'basic","'",",","'mse","'","or","'sigopt","'",".","Default","to","'bayesian","'",".",":","param","relative_drop",":","Float",",","tolerable","ralative","accuracy","drop",".","Default","to","None",",","e.g",".","set","to","0.1","means","that","we","accept","a","10","%","increase","in","the","metrics","error",".",":","param","absolute_drop",":","Float",",","tolerable","ralative","accuracy","drop",".","Default","to","None",",","e.g",".","set","to","5","means","that","we","can","only","accept","metrics","smaller","than","5.",":","param","timeout",":","Tuning","timeout","(","seconds",")",".","Default","to","0",",","which","means","early","stop",".","Combine","with","max_trials","field","to","decide","when","to","exit",".",":","param","max_trials",":","Max","tune","times",".","Default","to","1",".","Combine","with","timeout","field","to","decide","when","to","exit",".","``","timeout=0",",","max_trials=1","''","means","it","will","try","quantization","only","once","and","return","satisfying","best","model","."]
code: def quantize(
      self,
      calib_data,
      metric=None,
      conf=None,
      framework="pytorch_fx",
      approach="static",
      tuning_strategy="bayesian",
      relative_drop=None,
      absolute_drop=None,
      timeout=0,
      max_trials=1,
  ):
      """
      Quantization TSPipeline.
  
      :param calib_data: Required for static quantization or evaluation.
  
             | 1. data creator:
             | a function that takes a config dictionary as parameter and
             | returns a PyTorch DataLoader.
             |
             | 2. a bigdl.chronos.data.TSDataset:
             | the TSDataset should follow the same operations as the training
             | TSDataset used in `AutoTSEstimator.fit`.
             |
             | 3. A torch.utils.data.dataloader.DataLoader object for calibration,
             | Users should set the configs correctly (e.g. past_seq_len, ...).
             | They can be found in TSPipeline._best_config.
             |
             | 4. A numpy ndarray tuple (x, y).
             | x's shape is (num_samples, past_seq_len, input_feature_dim).
             | y's shape is (num_samples, future_seq_len, output_feature_dim).
             | They can be found in TSPipeline._best_config.
  
      :param metric: A str represent the metrics for tunning the quality of
             quantization. You may choose from "mse", "mae", "rmse", "r2", "mape", "smape".
      :param conf: A path to conf yaml file for quantization. Default to None,
             using default config.
      :param framework: string or list, [{'pytorch'|'pytorch_fx'|'pytorch_ipex'},
             {'onnxrt_integerops'|'onnxrt_qlinearops'}]. Default: 'pytorch_fx'.
             Consistent with Intel Neural Compressor.
      :param approach: str, 'static' or 'dynamic'. Default to 'static'.
      :param tuning_strategy: str, 'bayesian', 'basic', 'mse' or 'sigopt'. Default to 'bayesian'.
      :param relative_drop: Float, tolerable ralative accuracy drop. Default to None,
             e.g. set to 0.1 means that we accept a 10% increase in the metrics error.
      :param absolute_drop: Float, tolerable ralative accuracy drop. Default to None,
             e.g. set to 5 means that we can only accept metrics smaller than 5.
      :param timeout: Tuning timeout (seconds). Default to 0, which means early stop.
             Combine with max_trials field to decide when to exit.
      :param max_trials: Max tune times. Default to 1. Combine with timeout field to
             decide when to exit. "timeout=0, max_trials=1" means it will try quantization
             only once and return satisfying best model.
      """
      from torch.utils.data import DataLoader, TensorDataset
      from bigdl.chronos.data import TSDataset
  
      # check model support for quantization
      from bigdl.chronos.autots.utils import check_quantize_available
  
      check_quantize_available(self._best_model.model)
      # calib data should be set if the forecaster is just loaded
      if calib_data is None and approach.startswith("static"):
          invalidInputError(
              False,
              "You must set a `calib_data` "
              "for quantization When you use 'static'.",
          )
      elif calib_data and approach.startswith("dynamic"):
          invalidInputError(
              False,
              "`calib_data` should be None When you use 'dynamic'.",
          )
  
      # preprocess data.
      from .utils import preprocess_quantize_data
  
      calib_data = preprocess_quantize_data(self, calib_data)
  
      # map metric str to function
      from bigdl.chronos.metric.forecast_metrics import REGRESSION_MAP
  
      if isinstance(metric, str):
          metric_func = REGRESSION_MAP[metric]
  
          def metric(y_label, y_predict):
              y_label = y_label.numpy()
              y_predict = y_predict.numpy()
              return metric_func(y_label, y_predict)
  
      # init acc criterion
      accuracy_criterion = None
      if relative_drop and absolute_drop:
          invalidInputError(
              False,
              "Please unset either `relative_drop` or `absolute_drop`.",
          )
      if relative_drop:
          accuracy_criterion = {
              "relative": relative_drop,
              "higher_is_better": False,
          }
      if absolute_drop:
          accuracy_criterion = {
              "absolute": absolute_drop,
              "higher_is_better": False,
          }
  
      from bigdl.nano.pytorch.trainer import Trainer
  
      self._trainer = Trainer(
          logger=False,
          max_epochs=1,
          checkpoint_callback=False,
          use_ipex=False,
      )
  
      # quantize
      framework = (
          [framework] if isinstance(framework, str) else framework
      )
      temp_quantized_model = None
      for framework_item in framework:
          accelerator, method = framework_item.split("_")
          if accelerator == "pytorch":
              accelerator = None
          else:
              accelerator = "onnxruntime"
              method = method[:-3]
          q_model = self._trainer.quantize(
              self._best_model,
              precision="int8",
              accelerator=accelerator,
              method=method,
              calib_dataloader=calib_data,
              metric=metric,
              conf=conf,
              approach=approach,
              tuning_strategy=tuning_strategy,
              accuracy_criterion=accuracy_criterion,
              timeout=timeout,
              max_trials=max_trials,
          )
          if accelerator == "onnxruntime":
              self._onnxruntime_int8 = q_model
          if accelerator is None:
              self._pytorch_int8 = q_model
  
imports: import os
  from bigdl.chronos.utils import LazyImport
  import types
  import numpy
  from bigdl.chronos.data import TSDataset
  from bigdl.chronos.metric.forecast_metrics import Evaluator
  from bigdl.chronos.pytorch.utils import _pytorch_fashion_inference
  from bigdl.nano.utils.common import invalidInputError
label_desc: Use image node_id 9 for calling the TSPipeline obj's underlying member method code with example usage: obj.quantize(calib_data, metric, conf, framework, approach, tuning_strategy, relative_drop, absolute_drop, timeout, max_trials) and returns: metric_func