docstr: Wrapper around GluonTS probabilistic deep learning models. For now, only DeepAR is supported.
  
  Due to inference speed, predictions are only generated for the last data point (as opposed to other mixers).  
  
  :param stop_after: time budget in seconds.
  :param target: column to forecast.
  :param horizon: length of forecasted horizon.
  :param window: length of input data.
  :param dtype_dict: data type of each column in the dataset.
  :param ts_analysis: dictionary with miscellaneous time series info, as generated by 'lightwood.data.timeseries_analyzer'.
  :param n_epochs: amount of epochs to train the model for. Will perform early stopping automatically if validation loss degrades.
  :param early_stop_patience: amount of consecutive epochs with no improvement in the validation loss.
  :param distribution_output: specify the type of distribution the model will learn.
  :param seed: specifies the seed used internally by GluonTS for reproducible predictions
docstr_tok: ["Wrapper","around","GluonTS","probabilistic","deep","learning","models",".","For","now",",","only","DeepAR","is","supported",".","Due","to","inference","speed",",","predictions","are","only","generated","for","the","last","data","point","(","as","opposed","to","other","mixers",")",".",":","param","stop_after",":","time","budget","in","seconds",".",":","param","target",":","column","to","forecast",".",":","param","horizon",":","length","of","forecasted","horizon",".",":","param","window",":","length","of","input","data",".",":","param","dtype_dict",":","data","type","of","each","column","in","the","dataset",".",":","param","ts_analysis",":","dictionary","with","miscellaneous","time","series","info",",","as","generated","by","'lightwood.data.timeseries_analyzer","'",".",":","param","n_epochs",":","amount","of","epochs","to","train","the","model","for",".","Will","perform","early","stopping","automatically","if","validation","loss","degrades",".",":","param","early_stop_patience",":","amount","of","consecutive","epochs","with","no","improvement","in","the","validation","loss",".",":","param","distribution_output",":","specify","the","type","of","distribution","the","model","will","learn",".",":","param","seed",":","specifies","the","seed","used","internally","by","GluonTS","for","reproducible","predictions"]
code: def __init__(
      self,
      stop_after: float,
      target: str,
      horizon: int,
      window: int,
      dtype_dict: Dict,
      ts_analysis: Dict,
      n_epochs: int = 10,
      early_stop_patience: int = 3,
      distribution_output: str = "",
      seed: int = 0,
      static_features_cat: Optional[List[str]] = None,
      static_features_real: Optional[List[str]] = None,
  ):
      """
      Wrapper around GluonTS probabilistic deep learning models. For now, only DeepAR is supported.
  
      Due to inference speed, predictions are only generated for the last data point (as opposed to other mixers).
  
      :param stop_after: time budget in seconds.
      :param target: column to forecast.
      :param horizon: length of forecasted horizon.
      :param window: length of input data.
      :param dtype_dict: data type of each column in the dataset.
      :param ts_analysis: dictionary with miscellaneous time series info, as generated by 'lightwood.data.timeseries_analyzer'.
      :param n_epochs: amount of epochs to train the model for. Will perform early stopping automatically if validation loss degrades.
      :param early_stop_patience: amount of consecutive epochs with no improvement in the validation loss.
      :param distribution_output: specify the type of distribution the model will learn.
      :param seed: specifies the seed used internally by GluonTS for reproducible predictions
      """  # noqa
      super().__init__(stop_after)
      self.stable = True
      self.prepared = False
      self.supports_proba = False
      self.target = target
      self.window = window
      self.horizon = horizon
      self.n_epochs = n_epochs
      self.dtype_dict = dtype_dict
      self.ts_analysis = ts_analysis
      self.grouped_by = (
          ["__default"]
          if not ts_analysis["tss"].group_by
          else ts_analysis["tss"].group_by
      )
      self.groups = []  # list can grow using adjust() with new data
      self.estimator = None
      self.model = None
      self.train_cache = None
      self.patience = early_stop_patience
      self.seed = seed
      self.trains_once = True
      self.static_features_cat_encoders = {}
      self.static_features_cat = (
          static_features_cat if static_features_cat else []
      )
      self.static_features_real = (
          static_features_real if static_features_real else []
      )
  
      dist_module = importlib.import_module(
          ".".join(
              [
                  "gluonts.mx.distribution",
                  *distribution_output.split(".")[:-1],
              ]
          )
      )
      try:
          self.distribution = getattr(
              dist_module, distribution_output.split(".")[-1]
          )()
      except AttributeError:
          self.distribution = (
              StudentTOutput()
          )  # use StudentTOutput when the provided distribution does not exist
  
      if len(self.grouped_by) > 1:
          raise Exception(
              "This mixer can only be used with 0 or 1 partition columns."
          )
  
imports: import importlib
  from copy import deepcopy
  from typing import Dict, Union, Optional, List
  import numpy
  import pandas
  import mxnet
  from sklearn.preprocessing import OrdinalEncoder
  from gluonts.dataset.pandas import PandasDataset
  from gluonts.mx import DeepAREstimator, Trainer
  from gluonts.mx.trainer.callback import TrainingHistory
  from gluonts.mx.distribution.student_t import StudentTOutput
  from lightwood.helpers.log import log
  from lightwood.mixer.base import BaseMixer
  from lightwood.api.types import PredictionArguments
  from lightwood.data.encoded_ds import EncodedDs, ConcatedEncodedDs
label_desc: Use image node_id 1 to create a new GluonTSMixer object from inherited base classes: BaseMixer with example: obj = GluonTSMixer(stop_after, target, horizon, window, dtype_dict, ts_analysis, n_epochs, early_stop_patience, distribution_output, seed, static_features_cat, static_features_real)