class_docstr: Class for Automatic Hyperparameter Optimization, it builds on top of `ray` to
  give access to a wide variety of hyperparameter optimization tools ranging
  from classic grid search, to Bayesian optimization and HyperBand algorithm.
  
  The validation loss to be optimized is defined by the `config['loss']` dictionary
  value, the config also contains the rest of the hyperparameter search space.
  
  It is important to note that the success of this hyperparameter optimization
  heavily relies on a strong correlation between the validation and test periods.
  
  Parameters
  ----------
  cls_model : PyTorch/PyTorchLightning model
      See `neuralforecast.models` [collection here](https://nixtla.github.io/neuralforecast/models.html).
  h : int
      Forecast horizon
  loss : PyTorch module
      Instantiated train loss class from [losses collection](https://nixtla.github.io/neuralforecast/losses.pytorch.html).
  valid_loss : PyTorch module
      Instantiated valid loss class from [losses collection](https://nixtla.github.io/neuralforecast/losses.pytorch.html).
  config : dict or callable
      Dictionary with ray.tune defined search space or function that takes an optuna trial and returns a configuration dict.
  search_alg : ray.tune.search variant or optuna.sampler
      For ray see https://docs.ray.io/en/latest/tune/api_docs/suggestion.html
      For optuna see https://optuna.readthedocs.io/en/stable/reference/samplers/index.html.
  num_samples : int
      Number of hyperparameter optimization steps/samples.
  cpus : int (default=os.cpu_count())
      Number of cpus to use during optimization. Only used with ray tune.
  gpus : int (default=torch.cuda.device_count())
      Number of gpus to use during optimization, default all available. Only used with ray tune.
  refit_with_val : bool
      Refit of best model should preserve val_size.
  verbose : bool
      Track progress.
  alias : str, optional (default=None)
      Custom name of the model.
  backend : str (default='ray')
      Backend to use for searching the hyperparameter space, can be either 'ray' or 'optuna'.
  callbacks : list of callable, optional (default=None)
      List of functions to call during the optimization process.
      ray reference: https://docs.ray.io/en/latest/tune/tutorials/tune-metrics.html
      optuna reference: https://optuna.readthedocs.io/en/stable/tutorial/20_recipes/007_optuna_callback.html
class_docstr_tok: ["Class","for","Automatic","Hyperparameter","Optimization",",","it","builds","on","top","of","`","ray","`","to","give","access","to","a","wide","variety","of","hyperparameter","optimization","tools","ranging","from","classic","grid","search",",","to","Bayesian","optimization","and","HyperBand","algorithm",".","The","validation","loss","to","be","optimized","is","defined","by","the","`","config","[","'loss","'","]","`","dictionary","value",",","the","config","also","contains","the","rest","of","the","hyperparameter","search","space",".","It","is","important","to","note","that","the","success","of","this","hyperparameter","optimization","heavily","relies","on","a","strong","correlation","between","the","validation","and","test","periods",".","Parameters","--","--","--","--","--","cls_model",":","PyTorch\/PyTorchLightning","model","See","`","neuralforecast.models","`","[","collection","here","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/models.html",")",".","h",":","int","Forecast","horizon","loss",":","PyTorch","module","Instantiated","train","loss","class","from","[","losses","collection","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/losses.pytorch.html",")",".","valid_loss",":","PyTorch","module","Instantiated","valid","loss","class","from","[","losses","collection","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/losses.pytorch.html",")",".","config",":","dict","or","callable","Dictionary","with","ray.tune","defined","search","space","or","function","that","takes","an","optuna","trial","and","returns","a","configuration","dict",".","search_alg",":","ray.tune.search","variant","or","optuna.sampler","For","ray","see","https",":","\/\/docs.ray.io\/en\/latest\/tune\/api_docs\/suggestion.html","For","optuna","see","https",":","\/\/optuna.readthedocs.io\/en\/stable\/reference\/samplers\/index.html",".","num_samples",":","int","Number","of","hyperparameter","optimization","steps\/samples",".","cpus",":","int","(","default=os.cpu_count","(",")",")","Number","of","cpus","to","use","during","optimization",".","Only","used","with","ray","tune",".","gpus",":","int","(","default=torch.cuda.device_count","(",")",")","Number","of","gpus","to","use","during","optimization",",","default","all","available",".","Only","used","with","ray","tune",".","refit_with_val",":","bool","Refit","of","best","model","should","preserve","val_size",".","verbose",":","bool","Track","progress",".","alias",":","str",",","optional","(","default=None",")","Custom","name","of","the","model",".","backend",":","str","(","default='ray","'",")","Backend","to","use","for","searching","the","hyperparameter","space",",","can","be","either","'ray","'","or","'optuna","'",".","callbacks",":","list","of","callable",",","optional","(","default=None",")","List","of","functions","to","call","during","the","optimization","process",".","ray","reference",":","https",":","\/\/docs.ray.io\/en\/latest\/tune\/tutorials\/tune-metrics.html","optuna","reference",":","https",":","\/\/optuna.readthedocs.io\/en\/stable\/tutorial\/20_recipes\/007_optuna_callback.html"]
docstr: BaseAuto.predict
  
  Predictions of the best performing model on validation.
  
  **Parameters:**<br>
  `dataset`: NeuralForecast's `TimeSeriesDataset` see details [here](https://nixtla.github.io/neuralforecast/tsdataset.html)<br>
  `step_size`: int, steps between sequential predictions, (default 1).<br>
  `**data_kwarg`: additional parameters for the dataset module.<br>
  `random_seed`: int=None, random_seed for hyperparameter exploration algorithms (not implemented).<br>
  **Returns:**<br>
  `y_hat`: numpy predictions of the `NeuralForecast` model.<br>
docstr_tok: ["BaseAuto.predict","Predictions","of","the","best","performing","model","on","validation",".","*","*","Parameters",":","*","*","<","br",">","`","dataset","`",":","NeuralForecast","'s","`","TimeSeriesDataset","`","see","details","[","here","]","(","https",":","\/\/nixtla.github.io\/neuralforecast\/tsdataset.html",")","<","br",">","`","step_size","`",":","int",",","steps","between","sequential","predictions",",","(","default","1",")",".","<","br",">","`","*","*","data_kwarg","`",":","additional","parameters","for","the","dataset","module.","<","br",">","`","random_seed","`",":","int=None",",","random_seed","for","hyperparameter","exploration","algorithms","(","not","implemented",")",".","<","br",">","*","*","Returns",":","*","*","<","br",">","`","y_hat","`",":","numpy","predictions","of","the","`","NeuralForecast","`","model.","<","br",">"]
code: def predict(self, dataset, step_size=1, **data_kwargs):
      """BaseAuto.predict
  
      Predictions of the best performing model on validation.
  
      **Parameters:**<br>
      `dataset`: NeuralForecast's `TimeSeriesDataset` see details [here](https://nixtla.github.io/neuralforecast/tsdataset.html)<br>
      `step_size`: int, steps between sequential predictions, (default 1).<br>
      `**data_kwarg`: additional parameters for the dataset module.<br>
      `random_seed`: int=None, random_seed for hyperparameter exploration algorithms (not implemented).<br>
      **Returns:**<br>
      `y_hat`: numpy predictions of the `NeuralForecast` model.<br>
      """
      return self.model.predict(
          dataset=dataset, step_size=step_size, **data_kwargs
      )
  
imports: from copy import deepcopy
  from os import cpu_count
  import torch
  import pytorch_lightning
  from pytorch_lightning.callbacks import TQDMProgressBar
  from ray import air, tune
  from ray.tune.integration.pytorch_lightning import TuneReportCallback
  from ray.tune.search.basic_variant import BasicVariantGenerator
label_desc: Use image node_id 9 for calling the BaseAuto obj's underlying member method code with example usage: obj.predict(dataset, step_size) and returns: self