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: Search the hyper parameter.
  
  :param data: train data, as numpy ndarray tuple (x, y)
  :param validation_data: validation data, as numpy ndarray tuple (x,y)
  :param target_metric: the target metric to optimize,
         a string or an instance of torchmetrics.metric.Metric
  :param direction: in which direction to optimize the target metric,
         "maximize" - larger the better
         "minimize" - smaller the better
  :param n_trials: number of trials to run
  :param n_parallels: number of parallel processes used to run trials.
         to use parallel tuning you need to use a RDB url for storage and specify study_name.
         For more information, refer to Nano AutoML user guide.
  :param epochs: the number of epochs to run in each trial fit, defaults to 1
  :param batch_size: number of batch size for each trial fit, defaults to 32
  :param acceleration: Whether to automatically consider the model after
      inference acceleration in the search process. It will only take
      effect if target_metric contains "latency". Default value is False.
  :param input_sample: A set of inputs for trace, defaults to None if you have
      trace before or model is a LightningModule with any dataloader attached.
  :param kwargs: some other parameters could be used for tuning, most useful one is
         `sampler` from SamplerType.Grid, SamplerType.Random and SamplerType.TPE so on.
code: def tune(
      self,
      data,
      validation_data,
      target_metric,
      direction,
      directions=None,
      n_trials=2,
      n_parallels=1,
      epochs=1,
      batch_size=32,
      acceleration=False,
      input_sample=None,
      **kwargs,
  ):
      """
      Search the hyper parameter.
  
      :param data: train data, as numpy ndarray tuple (x, y)
      :param validation_data: validation data, as numpy ndarray tuple (x,y)
      :param target_metric: the target metric to optimize,
             a string or an instance of torchmetrics.metric.Metric
      :param direction: in which direction to optimize the target metric,
             "maximize" - larger the better
             "minimize" - smaller the better
      :param n_trials: number of trials to run
      :param n_parallels: number of parallel processes used to run trials.
             to use parallel tuning you need to use a RDB url for storage and specify study_name.
             For more information, refer to Nano AutoML user guide.
      :param epochs: the number of epochs to run in each trial fit, defaults to 1
      :param batch_size: number of batch size for each trial fit, defaults to 32
      :param acceleration: Whether to automatically consider the model after
          inference acceleration in the search process. It will only take
          effect if target_metric contains "latency". Default value is False.
      :param input_sample: A set of inputs for trace, defaults to None if you have
          trace before or model is a LightningModule with any dataloader attached.
      :param kwargs: some other parameters could be used for tuning, most useful one is
             `sampler` from SamplerType.Grid, SamplerType.Random and SamplerType.TPE so on.
      """
  
      invalidInputError(
          not self.distributed,
          "HPO is not supported in distributed mode."
          "Please use AutoTS instead.",
      )
      invalidOperationError(
          self.use_hpo,
          "HPO is disabled for this forecaster."
          "You may specify search space in hyper parameters to enable it.",
      )
  
      # prepare data
      from bigdl.chronos.pytorch import TSTrainer as Trainer
  
      # data transformation
      if isinstance(data, tuple):
          check_data(data[0], data[1], self.data_config)
          if validation_data and isinstance(validation_data, tuple):
              check_data(
                  validation_data[0],
                  validation_data[1],
                  self.data_config,
              )
          else:
              invalidInputError(
                  False,
                  "To use tuning, you must provide validation_data"
                  "as numpy arrays.",
              )
      else:
          invalidInputError(
              False, "HPO only supports numpy train input data."
          )
  
      if input_sample is None:
          input_sample = torch.from_numpy(data[0][:1, :, :])
  
      # prepare target metric
      if validation_data is not None:
          formated_target_metric = _format_metric_str(
              "val", target_metric
          )
      else:
          invalidInputError(
              False,
              "To use tuning, you must provide validation_data"
              "as numpy arrays.",
          )
  
      # build auto model
      self.tune_internal = self._build_automodel(
          data, validation_data, batch_size, epochs
      )
  
      # shall we use the same trainier
      self.tune_trainer = Trainer(
          logger=False,
          max_epochs=epochs,
          enable_checkpointing=self.checkpoint_callback,
          num_processes=self.num_processes,
          use_ipex=self.use_ipex,
          use_hpo=True,
      )
  
      # run hyper parameter search
      self.internal = self.tune_trainer.search(
          self.tune_internal,
          n_trials=n_trials,
          target_metric=formated_target_metric,
          direction=direction,
          directions=directions,
          n_parallels=n_parallels,
          acceleration=acceleration,
          input_sample=input_sample,
          **kwargs,
      )
  
      if self.tune_trainer.hposearcher.objective.mo_hpo:
          return self.internal
  
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 3 for calling the BasePytorchForecaster obj's underlying member method code with example usage: obj.tune(data, validation_data, target_metric, direction, directions, n_trials, n_parallels, epochs, batch_size, acceleration, input_sample) and returns: self