docstr: Build a Forecaster Model.
  
  :param tsdataset: A bigdl.chronos.data.tsdataset.TSDataset instance.
  :param past_seq_len: int or "auto", Specify the history time steps (i.e. lookback).
         Do not specify the 'past_seq_len' if your tsdataset has called
         the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
         If "auto", the mode of time series' cycle length will be taken as the past_seq_len.
  :param future_seq_len: int or list, Specify the output time steps (i.e. horizon).
         Do not specify the 'future_seq_len' if your tsdataset has called
         the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
  :param kwargs: Specify parameters of Forecaster,
         e.g. loss and optimizer, etc.
         More info, please refer to Forecaster.__init__ methods.
  
  :return: A Forecaster Model.
docstr_tok: ["Build","a","Forecaster","Model",".",":","param","tsdataset",":","A","bigdl.chronos.data.tsdataset.TSDataset","instance",".",":","param","past_seq_len",":","int","or","``","auto","''",",","Specify","the","history","time","steps","(","i.e",".","lookback",")",".","Do","not","specify","the","'past_seq_len","'","if","your","tsdataset","has","called","the","'TSDataset.roll","'","method","or","'TSDataset.to_torch_data_loader","'",".","If","``","auto","''",",","the","mode","of","time","series","'","cycle","length","will","be","taken","as","the","past_seq_len",".",":","param","future_seq_len",":","int","or","list",",","Specify","the","output","time","steps","(","i.e",".","horizon",")",".","Do","not","specify","the","'future_seq_len","'","if","your","tsdataset","has","called","the","'TSDataset.roll","'","method","or","'TSDataset.to_torch_data_loader","'",".",":","param","kwargs",":","Specify","parameters","of","Forecaster",",","e.g",".","loss","and","optimizer",",","etc",".","More","info",",","please","refer","to","Forecaster.__init__","methods",".",":","return",":","A","Forecaster","Model","."]
code: def from_tsdataset(
      cls,
      tsdataset,
      past_seq_len=None,
      future_seq_len=None,
      label_len=None,
      freq=None,
      **kwargs,
  ):
      """
      Build a Forecaster Model.
  
      :param tsdataset: A bigdl.chronos.data.tsdataset.TSDataset instance.
      :param past_seq_len: int or "auto", Specify the history time steps (i.e. lookback).
             Do not specify the 'past_seq_len' if your tsdataset has called
             the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
             If "auto", the mode of time series' cycle length will be taken as the past_seq_len.
      :param future_seq_len: int or list, Specify the output time steps (i.e. horizon).
             Do not specify the 'future_seq_len' if your tsdataset has called
             the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
      :param kwargs: Specify parameters of Forecaster,
             e.g. loss and optimizer, etc.
             More info, please refer to Forecaster.__init__ methods.
  
      :return: A Forecaster Model.
      """
      from bigdl.nano.utils.common import invalidInputError
  
      invalidInputError(
          isinstance(tsdataset, TSDataset),
          f"We only supports input a TSDataset, but get{type(tsdataset)}.",
      )
  
      def check_time_steps(tsdataset, past_seq_len, future_seq_len):
          if (
              tsdataset.lookback is not None
              and past_seq_len is not None
          ):
              future_seq_len = (
                  future_seq_len
                  if isinstance(future_seq_len, int)
                  else max(future_seq_len)
              )
              return (
                  tsdataset.lookback == past_seq_len
                  and tsdataset.horizon == future_seq_len
              )
          return True
  
      invalidInputError(
          not tsdataset._has_generate_agg_feature,
          "We will add support for 'gen_rolling_feature' method later.",
      )
  
      if (
          tsdataset.lookback is not None
      ):  # called roll or to_torch_data_loader
          past_seq_len = tsdataset.lookback
          future_seq_len = (
              tsdataset.horizon
              if isinstance(tsdataset.horizon, int)
              else max(tsdataset.horizon)
          )
          output_feature_num = len(tsdataset.roll_target)
          input_feature_num = (
              len(tsdataset.roll_feature) + output_feature_num
          )
      elif (
          past_seq_len is not None and future_seq_len is not None
      ):  # initialize only
          past_seq_len = (
              past_seq_len
              if isinstance(past_seq_len, int)
              else tsdataset.get_cycle_length()
          )
          future_seq_len = (
              future_seq_len
              if isinstance(future_seq_len, int)
              else max(future_seq_len)
          )
          output_feature_num = len(tsdataset.target_col)
          input_feature_num = (
              len(tsdataset.feature_col) + output_feature_num
          )
      else:
          invalidInputError(
              False,
              "Forecaster requires 'past_seq_len' and 'future_seq_len' to specify "
              "the history time step and output time step.",
          )
  
      if label_len is None:
          label_len = max(past_seq_len // 2, 1)
  
      invalidInputError(
          tsdataset.label_len == label_len
          or tsdataset.label_len is None,
          f"Expected label_len to be {tsdataset.label_len}, "
          f"but found {label_len}",
      )
  
      invalidInputError(
          check_time_steps(tsdataset, past_seq_len, future_seq_len),
          "tsdataset already has history time steps and "
          "differs from the given past_seq_len and future_seq_len "
          "Expected past_seq_len and future_seq_len to be "
          f"{tsdataset.lookback, tsdataset.horizon}, "
          f"but found {past_seq_len, future_seq_len}.",
          fixMsg="Do not specify past_seq_len and future seq_len "
          "or call tsdataset.roll method again and specify time step",
      )
  
      if tsdataset._freq is not None:
          infer_freq_str = _timedelta_to_delta_str(tsdataset._freq)
          freq = infer_freq_str
  
      return cls(
          past_seq_len=past_seq_len,
          future_seq_len=future_seq_len,
          input_feature_num=input_feature_num,
          output_feature_num=output_feature_num,
          freq=freq,
          label_len=label_len,
          **kwargs,
      )
  
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 13 for calling the AutoformerForecaster obj's underlying member method code with example usage: obj.from_tsdataset(cls, tsdataset, past_seq_len, future_seq_len, label_len, freq) and returns: cls, True, unknown