class_docstr: Automated TimeSeries Estimator for time series forecasting task, which supports
  TSDataset and customized data creator as data input on built-in model (only
  "lstm", "tcn", "seq2seq" for now) and 3rd party model.
  
  Only backend="torch" is supported for now. Customized data creator has not been
  fully supported by TSPipeline.
  
  >>> # Here is a use case example:
  >>> # prepare train/valid/test tsdataset
  >>> autoest = AutoTSEstimator(model="lstm",
  >>>                           search_space=search_space,
  >>>                           past_seq_len=6,
  >>>                           future_seq_len=1)
  >>> tsppl = autoest.fit(data=tsdata_train,
  >>>                     validation_data=tsdata_valid)
  >>> tsppl.predict(tsdata_test)
  >>> tsppl.save("my_tsppl")
class_docstr_tok: ["Automated","TimeSeries","Estimator","for","time","series","forecasting","task",",","which","supports","TSDataset","and","customized","data","creator","as","data","input","on","built-in","model","(","only","''","lstm","''",",","``","tcn","''",",","``","seq2seq","''","for","now",")","and","3rd","party","model",".","Only","backend=","''","torch","''","is","supported","for","now",".","Customized","data","creator","has","not","been","fully","supported","by","TSPipeline",".",">",">",">","#","Here","is","a","use","case","example",":",">",">",">","#","prepare","train\/valid\/test","tsdataset",">",">",">","autoest","=","AutoTSEstimator","(","model=","''","lstm","''",",",">",">",">","search_space=search_space",",",">",">",">","past_seq_len=6",",",">",">",">","future_seq_len=1",")",">",">",">","tsppl","=","autoest.fit","(","data=tsdata_train",",",">",">",">","validation_data=tsdata_valid",")",">",">",">","tsppl.predict","(","tsdata_test",")",">",">",">","tsppl.save","(","``","my_tsppl","''",")"]
docstr: prepare the data creators and add selected features to search_space
  :param search_space: the search space
  :param train_data: train data
  :param val_data: validation data
  :return: data creators from train and validation data
docstr_tok: ["prepare","the","data","creators","and","add","selected","features","to","search_space",":","param","search_space",":","the","search","space",":","param","train_data",":","train","data",":","param","val_data",":","validation","data",":","return",":","data","creators","from","train","and","validation","data"]
code: def _prepare_data_creator(
      self, search_space, train_data, val_data=None
  ):
      """
      prepare the data creators and add selected features to search_space
      :param search_space: the search space
      :param train_data: train data
      :param val_data: validation data
      :return: data creators from train and validation data
      """
      import torch
      from torch.utils.data import TensorDataset, DataLoader
      import ray
  
      # automatically inference output_feature_num
      # input_feature_num will be set by base pytorch model according to selected features.
      search_space["output_feature_num"] = len(train_data.target_col)
  
      # append feature selection into search space
      # TODO: more flexible setting
      all_features = train_data.feature_col
      if self.selected_features not in ("all", "auto"):
          raise ValueError(
              f'Only "all" and "auto" are supported for selected_features,\
                  but found {self.selected_features}'
          )
      if self.selected_features == "auto":
          if len(all_features) == 0:
              search_space["selected_features"] = all_features
          else:
              search_space["selected_features"] = hp.choice_n(
                  all_features, min_items=0, max_items=len(all_features)
              )
      if self.selected_features == "all":
          search_space["selected_features"] = all_features
  
      # put train/val data in ray
      train_data_id = ray.put(train_data)
      valid_data_id = ray.put(val_data)
  
      def train_data_creator(config):
          train_d = ray.get(train_data_id)
  
          x, y = train_d.roll(
              lookback=config.get("past_seq_len"),
              horizon=config.get("future_seq_len"),
              feature_col=config["selected_features"],
          ).to_numpy()
  
          return DataLoader(
              TensorDataset(
                  torch.from_numpy(x).float(),
                  torch.from_numpy(y).float(),
              ),
              batch_size=config["batch_size"],
              shuffle=True,
          )
  
      def val_data_creator(config):
          val_d = ray.get(valid_data_id)
  
          x, y = val_d.roll(
              lookback=config.get("past_seq_len"),
              horizon=config.get("future_seq_len"),
              feature_col=config["selected_features"],
          ).to_numpy()
  
          return DataLoader(
              TensorDataset(
                  torch.from_numpy(x).float(),
                  torch.from_numpy(y).float(),
              ),
              batch_size=config["batch_size"],
              shuffle=True,
          )
  
      return train_data_creator, val_data_creator
  
file_path: analytics-zoo/pyzoo/zoo/chronos/autots/autotsestimator.py
imports: import types
  from zoo.orca.automl.auto_estimator import AutoEstimator
  from zoo.chronos.data import TSDataset
  import zoo.orca.automl.hp
  from zoo.chronos.autots.model import AutoModelFactory
  from zoo.chronos.autots.tspipeline import TSPipeline
label_desc: Use image node_id 3 for calling the AutoTSEstimator obj's underlying member method code with example usage: obj._prepare_data_creator(search_space, train_data, val_data) and returns: train_data_creator,  val_data_creator, DataLoader, DataLoader