docstr: WaveNet estimator that uses the architecture proposed in
  [Oord et al., 2016] with quantized targets. The model is trained
  using the cross-entropy loss.
  
  [Oord et al., 2016] "Wavenet: A generative model for raw audio."
  arXiv preprint arXiv:1609.03499 (2016).
  
  Parameters
  ----------
  freq
      Frequency of the time series
  prediction_length
      Length of the prediction horizon
  num_bins, optional
      Number ofum bins used for quantization of the time series,
      by default 1024
  num_residual_channels, optional
      Number of residual channels in wavenet architecture, by default 24
  num_skip_channels, optional
      Number of skip channels in wavenet architecture, by default 32
  dilation_depth, optional
      Number of dilation layers in wavenet architecture. If set to None
      (default), dialation_depth is set such that the receptive length
      is at least as long as typical seasonality for the frequency and
      at least 2 * prediction_length, by default None
  num_stacks, optional
      Number of dilation stacks in wavenet architecture, by default 1
  temperature, optional
      Temparature used for sampling from softmax distribution,
      by default 1.0
  num_feat_dynamic_real, optional
      The number of dynamic real features, by default 0
  num_feat_static_cat, optional
      The number of static categorical features, by default 0
  num_feat_static_real, optional
      The number of static real features, by default 0
  cardinality, optional
      The cardinalities of static categorical features, by default [1]
  seasonality, optional
      The seasonality of the time series. If set to None, seasonality
      is set to default value based on the `freq`, by default None
  embedding_dimension, optional
      The dimension of the embeddings for categorical features,
      by default 5
  use_log_scale_feature, optional
      If True, logarithm of the scale of the past data will be used as an
      additional static feature,
      by default True
  time_features, optional
      List of time features, from :py:mod:`gluonts.time_feature`,
      by default None
  lr, optional
      Learning rate, by default 1e-3
  weight_decay, optional
      Weight decay, by default 1e-8
  train_sampler, optional
      Controls the sampling of windows during training,
      by default None
  validation_sampler, optional
      Controls the sampling of windows during validation,
      by default None
  batch_size, optional
      The size of the batches to be used for training, by default 32
  num_batches_per_epoch, optional
      Number of batches to be processed in each training epoch,
      by default 50
  num_parallel_samples, optional
      The number of parallel samples to generate during inference.
      This parameter is only used in inference mode, by default 100
  negative_data, optional
      Flag indicating whether the time series take negative values,
      by default False
  trainer_kwargs, optional
      Additional arguments to provide to ``pl.Trainer`` for construction,
      by default None
docstr_tok: ["WaveNet","estimator","that","uses","the","architecture","proposed","in","[","Oord","et","al.",",","2016","]","with","quantized","targets",".","The","model","is","trained","using","the","cross-entropy","loss",".","[","Oord","et","al.",",","2016","]","``","Wavenet",":","A","generative","model","for","raw","audio",".","''","arXiv","preprint","arXiv:1609.03499","(","2016",")",".","Parameters","--","--","--","--","--","freq","Frequency","of","the","time","series","prediction_length","Length","of","the","prediction","horizon","num_bins",",","optional","Number","ofum","bins","used","for","quantization","of","the","time","series",",","by","default","1024","num_residual_channels",",","optional","Number","of","residual","channels","in","wavenet","architecture",",","by","default","24","num_skip_channels",",","optional","Number","of","skip","channels","in","wavenet","architecture",",","by","default","32","dilation_depth",",","optional","Number","of","dilation","layers","in","wavenet","architecture",".","If","set","to","None","(","default",")",",","dialation_depth","is","set","such","that","the","receptive","length","is","at","least","as","long","as","typical","seasonality","for","the","frequency","and","at","least","2","*","prediction_length",",","by","default","None","num_stacks",",","optional","Number","of","dilation","stacks","in","wavenet","architecture",",","by","default","1","temperature",",","optional","Temparature","used","for","sampling","from","softmax","distribution",",","by","default","1.0","num_feat_dynamic_real",",","optional","The","number","of","dynamic","real","features",",","by","default","0","num_feat_static_cat",",","optional","The","number","of","static","categorical","features",",","by","default","0","num_feat_static_real",",","optional","The","number","of","static","real","features",",","by","default","0","cardinality",",","optional","The","cardinalities","of","static","categorical","features",",","by","default","[","1","]","seasonality",",","optional","The","seasonality","of","the","time","series",".","If","set","to","None",",","seasonality","is","set","to","default","value","based","on","the","`","freq","`",",","by","default","None","embedding_dimension",",","optional","The","dimension","of","the","embeddings","for","categorical","features",",","by","default","5","use_log_scale_feature",",","optional","If","True",",","logarithm","of","the","scale","of","the","past","data","will","be","used","as","an","additional","static","feature",",","by","default","True","time_features",",","optional","List","of","time","features",",","from",":","py",":","mod",":","`","gluonts.time_feature","`",",","by","default","None","lr",",","optional","Learning","rate",",","by","default","1e-3","weight_decay",",","optional","Weight","decay",",","by","default","1e-8","train_sampler",",","optional","Controls","the","sampling","of","windows","during","training",",","by","default","None","validation_sampler",",","optional","Controls","the","sampling","of","windows","during","validation",",","by","default","None","batch_size",",","optional","The","size","of","the","batches","to","be","used","for","training",",","by","default","32","num_batches_per_epoch",",","optional","Number","of","batches","to","be","processed","in","each","training","epoch",",","by","default","50","num_parallel_samples",",","optional","The","number","of","parallel","samples","to","generate","during","inference",".","This","parameter","is","only","used","in","inference","mode",",","by","default","100","negative_data",",","optional","Flag","indicating","whether","the","time","series","take","negative","values",",","by","default","False","trainer_kwargs",",","optional","Additional","arguments","to","provide","to","``","pl.Trainer","``","for","construction",",","by","default","None"]
code: def __init__(
      self,
      freq: str,
      prediction_length: int,
      num_bins: int = 1024,
      num_residual_channels: int = 24,
      num_skip_channels: int = 32,
      dilation_depth: Optional[int] = None,
      num_stacks: int = 1,
      temperature: float = 1.0,
      num_feat_dynamic_real: int = 0,
      num_feat_static_cat: int = 0,
      num_feat_static_real: int = 0,
      cardinality: List[int] = [1],
      seasonality: Optional[int] = None,
      embedding_dimension: int = 5,
      use_log_scale_feature: bool = True,
      time_features: Optional[List[TimeFeature]] = None,
      lr: float = 1e-3,
      weight_decay: float = 1e-8,
      train_sampler: Optional[InstanceSampler] = None,
      validation_sampler: Optional[InstanceSampler] = None,
      batch_size: int = 32,
      num_batches_per_epoch: int = 50,
      num_parallel_samples: int = 100,
      negative_data: bool = False,
      trainer_kwargs: Optional[Dict[str, Any]] = None,
  ) -> None:
      """WaveNet estimator that uses the architecture proposed in
      [Oord et al., 2016] with quantized targets. The model is trained
      using the cross-entropy loss.
  
      [Oord et al., 2016] "Wavenet: A generative model for raw audio."
      arXiv preprint arXiv:1609.03499 (2016).
  
      Parameters
      ----------
      freq
          Frequency of the time series
      prediction_length
          Length of the prediction horizon
      num_bins, optional
          Number ofum bins used for quantization of the time series,
          by default 1024
      num_residual_channels, optional
          Number of residual channels in wavenet architecture, by default 24
      num_skip_channels, optional
          Number of skip channels in wavenet architecture, by default 32
      dilation_depth, optional
          Number of dilation layers in wavenet architecture. If set to None
          (default), dialation_depth is set such that the receptive length
          is at least as long as typical seasonality for the frequency and
          at least 2 * prediction_length, by default None
      num_stacks, optional
          Number of dilation stacks in wavenet architecture, by default 1
      temperature, optional
          Temparature used for sampling from softmax distribution,
          by default 1.0
      num_feat_dynamic_real, optional
          The number of dynamic real features, by default 0
      num_feat_static_cat, optional
          The number of static categorical features, by default 0
      num_feat_static_real, optional
          The number of static real features, by default 0
      cardinality, optional
          The cardinalities of static categorical features, by default [1]
      seasonality, optional
          The seasonality of the time series. If set to None, seasonality
          is set to default value based on the `freq`, by default None
      embedding_dimension, optional
          The dimension of the embeddings for categorical features,
          by default 5
      use_log_scale_feature, optional
          If True, logarithm of the scale of the past data will be used as an
          additional static feature,
          by default True
      time_features, optional
          List of time features, from :py:mod:`gluonts.time_feature`,
          by default None
      lr, optional
          Learning rate, by default 1e-3
      weight_decay, optional
          Weight decay, by default 1e-8
      train_sampler, optional
          Controls the sampling of windows during training,
          by default None
      validation_sampler, optional
          Controls the sampling of windows during validation,
          by default None
      batch_size, optional
          The size of the batches to be used for training, by default 32
      num_batches_per_epoch, optional
          Number of batches to be processed in each training epoch,
          by default 50
      num_parallel_samples, optional
          The number of parallel samples to generate during inference.
          This parameter is only used in inference mode, by default 100
      negative_data, optional
          Flag indicating whether the time series take negative values,
          by default False
      trainer_kwargs, optional
          Additional arguments to provide to ``pl.Trainer`` for construction,
          by default None
      """
      default_trainer_kwargs = {
          "max_epochs": 100,
          "gradient_clip_val": 10.0,
      }
      if trainer_kwargs is not None:
          default_trainer_kwargs.update(trainer_kwargs)
      super().__init__(trainer_kwargs=default_trainer_kwargs)
  
      self.freq = freq
      self.prediction_length = prediction_length
      self.num_feat_dynamic_real = num_feat_dynamic_real
      self.num_feat_static_cat = num_feat_static_cat
      self.num_feat_static_real = num_feat_static_real
      self.cardinality = cardinality
      self.embedding_dimension = embedding_dimension
      self.num_bins = num_bins
      self.num_residual_channels = num_residual_channels
      self.num_skip_channels = num_skip_channels
      self.num_stacks = num_stacks
      self.use_log_scale_feature = use_log_scale_feature
      self.time_features = unwrap_or(
          time_features, time_features_from_frequency_str(freq)
      )
      self.temperature = temperature
      self.lr = lr
      self.weight_decay = weight_decay
      self.train_sampler = unwrap_or(
          train_sampler,
          ExpectedNumInstanceSampler(
              num_instances=1.0, min_future=self.prediction_length
          ),
      )
      self.validation_sampler = unwrap_or(
          validation_sampler,
          ValidationSplitSampler(min_future=self.prediction_length),
      )
      self.batch_size = batch_size
      self.num_batches_per_epoch = num_batches_per_epoch
      self.num_parallel_samples = num_parallel_samples
      self.negative_data = negative_data
      low = -10.0 if self.negative_data else 0
      high = 10.0
      bin_centers = np.linspace(low, high, self.num_bins)
      bin_edges = np.concatenate(
          [[-1e20], (bin_centers[1:] + bin_centers[:-1]) / 2.0, [1e20]]
      )
      self.bin_centers = bin_centers.tolist()
      self.bin_edges = bin_edges.tolist()
  
      self.seasonality = unwrap_or(
          seasonality,
          get_seasonality(
              freq,
              {
                  "H": 7 * 24,
                  "D": 7,
                  "W": 52,
                  "M": 12,
                  "B": 7 * 5,
                  "T": 24 * 60,
                  "S": 60 * 60,
              },
          ),
      )
  
      goal_receptive_length = max(
          2 * self.seasonality, 2 * self.prediction_length
      )
      if dilation_depth is None:
          d = 1
          while (
              WaveNet.get_receptive_field(
                  dilation_depth=d, num_stacks=num_stacks
              )
              < goal_receptive_length
          ):
              d += 1
          self.dilation_depth = d
      else:
          self.dilation_depth = dilation_depth
      self.context_length = WaveNet.get_receptive_field(
          dilation_depth=self.dilation_depth, num_stacks=num_stacks
      )
  
imports: from typing import Any, Dict, List, Optional, Iterable
  import lightning.pytorch
  import torch
  import numpy
  from gluonts.core.component import validated
  from gluonts.dataset.common import Dataset
  from gluonts.dataset.field_names import FieldName
  from gluonts.dataset.loader import as_stacked_batches
  from gluonts.itertools import Cyclic
  from gluonts.torch.model.estimator import PyTorchLightningEstimator
  from gluonts.torch.model.predictor import PyTorchPredictor
  from gluonts.time_feature import get_seasonality, time_features_from_frequency_str, TimeFeature
  from gluonts.transform import Transformation, AddAgeFeature, AddObservedValuesIndicator, AddTimeFeatures, AsNumpyArray, Chain, ExpectedNumInstanceSampler, InstanceSampler, InstanceSplitter, SetField, RemoveFields, QuantizeMeanScaled, VstackFeatures, Identity, TestSplitSampler, ValidationSplitSampler
  from gluonts.maybe import unwrap_or
  from .module import WaveNet
  from .lightning_module import WaveNetLightningModule
label_desc: Use image node_id 1 to create a new WaveNetEstimator object from inherited base classes: PyTorchLightningEstimator with example: obj = WaveNetEstimator(freq, prediction_length, num_bins, num_residual_channels, num_skip_channels, dilation_depth, num_stacks, temperature, num_feat_dynamic_real, num_feat_static_cat, num_feat_static_real, cardinality, seasonality, embedding_dimension, use_log_scale_feature, time_features, lr, weight_decay, train_sampler, validation_sampler, batch_size, num_batches_per_epoch, num_parallel_samples, negative_data, trainer_kwargs)