docstr: Build a AutoformerForecaster Forecast Model.
  
  :param past_seq_len: Specify the history time steps (i.e. lookback).
  :param future_seq_len: Specify the output time steps (i.e. horizon).
  :param input_feature_num: Specify the feature dimension.
  :param output_feature_num: Specify the output dimension.
  :param freq: Freq for time features encoding. You may choose from "s",
         "t","h","d","w","m" for second, minute, hour, day, week or month.
  :param label_len: Start token length of AutoFormer decoder.
  :param optimizer: Specify the optimizer used for training. This value
         defaults to "Adam".
  :param loss: str or pytorch loss instance, Specify the loss function
         used for training. This value defaults to "mse". You can choose
         from "mse", "mae", "huber_loss" or any customized loss instance
         you want to use.
  :param lr: Specify the learning rate. This value defaults to 0.001.
  :param lr_scheduler_milestones: Specify the milestones parameters in
         torch.optim.lr_scheduler.MultiStepLR.This value defaults to
         [3, 4, 5, 6, 7, 8, 9, 10]. If you don't want to use scheduler,
         set this parameter to None to disbale lr_scheduler.
  :param metrics: A list contains metrics for evaluating the quality of
         forecasting. You may only choose from "mse" and "mae" for a
         distributed forecaster. You may choose from "mse", "mae",
         "rmse", "r2", "mape", "smape" or a callable function for a
         non-distributed forecaster. If callable function, it signature
         should be func(y_true, y_pred), where y_true and y_pred are numpy
         ndarray.
  :param seed: int, random seed for training. This value defaults to None.
  :param distributed: bool, if init the forecaster in a distributed
         fashion. If True, the internal model will use an Orca Estimator.
         If False, the internal model will use a pytorch model. The value
         defaults to False.
  :param workers_per_node: int, the number of worker you want to use.
         The value defaults to 1. The param is only effective when
         distributed is set to True.
  :param distributed_backend: str, select from "ray" or
         "horovod". The value defaults to "ray".
  :param kwargs: other hyperparameter please refer to
         https://github.com/zhouhaoyi/Informer2020#usage
docstr_tok: ["Build","a","AutoformerForecaster","Forecast","Model",".",":","param","past_seq_len",":","Specify","the","history","time","steps","(","i.e",".","lookback",")",".",":","param","future_seq_len",":","Specify","the","output","time","steps","(","i.e",".","horizon",")",".",":","param","input_feature_num",":","Specify","the","feature","dimension",".",":","param","output_feature_num",":","Specify","the","output","dimension",".",":","param","freq",":","Freq","for","time","features","encoding",".","You","may","choose","from","``","s","''",",","``","t","''",",","''","h","''",",","''","d","''",",","''","w","''",",","''","m","''","for","second",",","minute",",","hour",",","day",",","week","or","month",".",":","param","label_len",":","Start","token","length","of","AutoFormer","decoder",".",":","param","optimizer",":","Specify","the","optimizer","used","for","training",".","This","value","defaults","to","``","Adam","''",".",":","param","loss",":","str","or","pytorch","loss","instance",",","Specify","the","loss","function","used","for","training",".","This","value","defaults","to","``","mse","''",".","You","can","choose","from","``","mse","''",",","``","mae","''",",","``","huber_loss","''","or","any","customized","loss","instance","you","want","to","use",".",":","param","lr",":","Specify","the","learning","rate",".","This","value","defaults","to","0.001.",":","param","lr_scheduler_milestones",":","Specify","the","milestones","parameters","in","torch.optim.lr_scheduler.MultiStepLR.This","value","defaults","to","[","3",",","4",",","5",",","6",",","7",",","8",",","9",",","10","]",".","If","you","do","n't","want","to","use","scheduler",",","set","this","parameter","to","None","to","disbale","lr_scheduler",".",":","param","metrics",":","A","list","contains","metrics","for","evaluating","the","quality","of","forecasting",".","You","may","only","choose","from","``","mse","''","and","``","mae","''","for","a","distributed","forecaster",".","You","may","choose","from","``","mse","''",",","``","mae","''",",","``","rmse","''",",","``","r2","''",",","``","mape","''",",","``","smape","''","or","a","callable","function","for","a","non-distributed","forecaster",".","If","callable","function",",","it","signature","should","be","func","(","y_true",",","y_pred",")",",","where","y_true","and","y_pred","are","numpy","ndarray",".",":","param","seed",":","int",",","random","seed","for","training",".","This","value","defaults","to","None",".",":","param","distributed",":","bool",",","if","init","the","forecaster","in","a","distributed","fashion",".","If","True",",","the","internal","model","will","use","an","Orca","Estimator",".","If","False",",","the","internal","model","will","use","a","pytorch","model",".","The","value","defaults","to","False",".",":","param","workers_per_node",":","int",",","the","number","of","worker","you","want","to","use",".","The","value","defaults","to","1",".","The","param","is","only","effective","when","distributed","is","set","to","True",".",":","param","distributed_backend",":","str",",","select","from","``","ray","''","or","``","horovod","''",".","The","value","defaults","to","``","ray","''",".",":","param","kwargs",":","other","hyperparameter","please","refer","to","https",":","\/\/github.com\/zhouhaoyi\/Informer2020","#","usage"]
code: def __init__(
      self,
      past_seq_len,
      future_seq_len,
      input_feature_num,
      output_feature_num,
      freq,
      label_len=None,
      output_attention=False,
      moving_avg=25,
      d_model=128,
      embed="timeF",
      dropout=0.05,
      factor=3,
      n_head=8,
      d_ff=256,
      activation="gelu",
      e_layers=2,
      d_layers=1,
      optimizer="Adam",
      loss="mse",
      lr=0.0001,
      lr_scheduler_milestones=[3, 4, 5, 6, 7, 8, 9, 10],
      metrics=["mse"],
      seed=None,
      distributed=False,
      workers_per_node=1,
      distributed_backend="ray",
  ):
      """
      Build a AutoformerForecaster Forecast Model.
  
      :param past_seq_len: Specify the history time steps (i.e. lookback).
      :param future_seq_len: Specify the output time steps (i.e. horizon).
      :param input_feature_num: Specify the feature dimension.
      :param output_feature_num: Specify the output dimension.
      :param freq: Freq for time features encoding. You may choose from "s",
             "t","h","d","w","m" for second, minute, hour, day, week or month.
      :param label_len: Start token length of AutoFormer decoder.
      :param optimizer: Specify the optimizer used for training. This value
             defaults to "Adam".
      :param loss: str or pytorch loss instance, Specify the loss function
             used for training. This value defaults to "mse". You can choose
             from "mse", "mae", "huber_loss" or any customized loss instance
             you want to use.
      :param lr: Specify the learning rate. This value defaults to 0.001.
      :param lr_scheduler_milestones: Specify the milestones parameters in
             torch.optim.lr_scheduler.MultiStepLR.This value defaults to
             [3, 4, 5, 6, 7, 8, 9, 10]. If you don't want to use scheduler,
             set this parameter to None to disbale lr_scheduler.
      :param metrics: A list contains metrics for evaluating the quality of
             forecasting. You may only choose from "mse" and "mae" for a
             distributed forecaster. You may choose from "mse", "mae",
             "rmse", "r2", "mape", "smape" or a callable function for a
             non-distributed forecaster. If callable function, it signature
             should be func(y_true, y_pred), where y_true and y_pred are numpy
             ndarray.
      :param seed: int, random seed for training. This value defaults to None.
      :param distributed: bool, if init the forecaster in a distributed
             fashion. If True, the internal model will use an Orca Estimator.
             If False, the internal model will use a pytorch model. The value
             defaults to False.
      :param workers_per_node: int, the number of worker you want to use.
             The value defaults to 1. The param is only effective when
             distributed is set to True.
      :param distributed_backend: str, select from "ray" or
             "horovod". The value defaults to "ray".
      :param kwargs: other hyperparameter please refer to
             https://github.com/zhouhaoyi/Informer2020#usage
      """
      invalidInputError(
          past_seq_len > 1,
          "past_seq_len of Autoformer must exceeds one.",
      )
  
      # config setting
      self.data_config = {
          "past_seq_len": past_seq_len,
          "future_seq_len": future_seq_len,
          "input_feature_num": input_feature_num,
          "output_feature_num": output_feature_num,
          "label_len": past_seq_len // 2
          if label_len is None
          else label_len,
      }
      self.model_config = {
          "seq_len": past_seq_len,
          "label_len": past_seq_len // 2
          if label_len is None
          else label_len,
          "pred_len": future_seq_len,
          "output_attention": output_attention,
          "moving_avg": moving_avg,
          "enc_in": input_feature_num,
          "d_model": d_model,
          "embed": embed,
          "freq": freq,
          "dropout": dropout,
          "dec_in": input_feature_num,
          "factor": factor,
          "n_head": n_head,
          "d_ff": d_ff,
          "activation": activation,
          "e_layers": e_layers,
          "c_out": output_feature_num,
          "d_layers": d_layers,
          "seed": seed,
      }
      self.loss_config = {"loss": loss}
      self.optim_config = {
          "lr": lr,
          "optim": optimizer,
          "lr_scheduler_milestones": lr_scheduler_milestones,
      }
  
      self.model_config.update(self.loss_config)
      self.model_config.update(self.optim_config)
  
      self.metrics = metrics
  
      self.distributed = distributed
      self.checkpoint_callback = True
      # seed setting
      if not isinstance(seed, Space):
          from pytorch_lightning import seed_everything
  
          seed_everything(seed=seed, workers=True)
  
      # disable multi-process training for now.
      # TODO: enable it in future.
      self.num_processes = 1
      self.use_ipex = False
      self.onnx_available = False
      self.quantize_available = False
      self.use_amp = False
      self.use_hpo = True
  
      # Model preparation
      self.fitted = False
  
      has_space = _config_has_search_space(
          config={
              **self.model_config,
              **self.optim_config,
              **self.loss_config,
              **self.data_config,
          }
      )
  
      if not has_space:
          self.use_hpo = False
          self.internal = model_creator(self.model_config)
  
      self.model_creator = model_creator
      self.loss_creator = loss_creator
      self.cxt_manager = DummyForecasterContextManager()
      self.context_enabled = False
      current_num_threads = torch.get_num_threads()
      self.thread_num = current_num_threads
      self.accelerate_method = None
  
imports: import torch
  import numpy
  from pandas import Timedelta
  from bigdl.chronos.forecaster.abstract import Forecaster
  from bigdl.chronos.forecaster.utils import read_csv, delete_folder
  from bigdl.chronos.metric.forecast_metrics import Evaluator
  from bigdl.chronos.model.autoformer import model_creator, loss_creator
  from torch.utils.data import TensorDataset, DataLoader
  from bigdl.chronos.model.autoformer.Autoformer import AutoFormer, _transform_config_to_namedtuple
  from bigdl.nano.utils.common import invalidInputError, invalidOperationError
  from bigdl.chronos.forecaster.utils import check_transformer_data
  from bigdl.chronos.pytorch import TSTrainer
  from bigdl.chronos.data import TSDataset
  from bigdl.nano.automl.hpo.space import Space
  from bigdl.chronos.forecaster.utils_hpo import GenericTSTransformerLightningModule, _config_has_search_space
  from bigdl.chronos.pytorch.context_manager import DummyForecasterContextManager, ForecasterContextManager
  from .utils_hpo import _format_metric_str
  import warnings
  from tempfile import TemporaryDirectory
  import os
label_desc: Use image node_id 1 to create a new AutoformerForecaster object from inherited base classes: Forecaster with example: obj = AutoformerForecaster(past_seq_len, future_seq_len, input_feature_num, output_feature_num, freq, label_len, output_attention, moving_avg, d_model, embed, dropout, factor, n_head, d_ff, activation, e_layers, d_layers, optimizer, loss, lr, lr_scheduler_milestones, metrics, seed, distributed, workers_per_node, distributed_backend)