class_docstr: Linear time regression fun and some not so linear fun.
  A modular model that models classic time-series components
      * trend
      * seasonality
      * auto-regression (as AR-Net)
      * covariates (as AR-Net)
      * apriori regressors
      * events and holidays
  by using Neural Network components.
  The Auto-regression and covariate components can be configured as a deeper network (AR-Net).
class_docstr_tok: ["Linear","time","regression","fun","and","some","not","so","linear","fun",".","A","modular","model","that","models","classic","time-series","components","*","trend","*","seasonality","*","auto-regression","(","as","AR-Net",")","*","covariates","(","as","AR-Net",")","*","apriori","regressors","*","events","and","holidays","by","using","Neural","Network","components",".","The","Auto-regression","and","covariate","components","can","be","configured","as","a","deeper","network","(","AR-Net",")","."]
docstr: This method defines the model forward pass.
  Note
  ----
  Time input is required. Minimum model setup is a linear trend.
  Parameters
  ----------
      inputs : dict
          Model inputs, each of len(df) but with varying dimensions
          Note
          ----
          Contains the following data:
          Model Inputs
              * ``time`` (torch.Tensor , loat), normalized time, dims: (batch, n_forecasts)
              * ``lags`` (torch.Tensor, float), dims: (batch, n_lags)
              * ``seasonalities`` (torch.Tensor, float), dict of named seasonalities (keys) with their features
              (values), dims of each dict value (batch, n_forecasts, n_features)
              * ``covariates`` (torch.Tensor, float), dict of named covariates (keys) with their features
              (values), dims of each dict value: (batch, n_lags)
              * ``events`` (torch.Tensor, float), all event features, dims (batch, n_forecasts, n_features)
              * ``regressors``(torch.Tensor, float), all regressor features, dims (batch, n_forecasts, n_features)
              * ``predict_mode`` (bool), optional and only passed during prediction
      meta : dict, default=None
          Metadata about the all the samples of the model input batch.
          Contains the following:
          Model Meta:
              * ``df_name`` (list, str), time series ID corresponding to each sample of the input batch.
          Note
          ----
          The meta is sorted in the same way the inputs are sorted.
          Note
          ----
          The default None value allows the forward method to be used without providing the meta argument.
          This was designed to avoid issues with the library `lr_finder` https://github.com/davidtvs/pytorch-lr-finder
          while having  ``config_trend.trend_global_local="local"``.
          The turnaround consists on passing the same meta (dummy ID) to all the samples of the batch.
          Internally, this is equivalent to use ``config_trend.trend_global_local="global"`` to find the optimal
          learning rate.
      compute_components_flag : bool, default=False
          If True, components will be computed.
  
  Returns
  -------
      torch.Tensor
          Forecast of dims (batch, n_forecasts, no_quantiles)
docstr_tok: ["This","method","defines","the","model","forward","pass",".","Note","--","--","Time","input","is","required",".","Minimum","model","setup","is","a","linear","trend",".","Parameters","--","--","--","--","--","inputs",":","dict","Model","inputs",",","each","of","len","(","df",")","but","with","varying","dimensions","Note","--","--","Contains","the","following","data",":","Model","Inputs","*","``","time","``","(","torch.Tensor",",","loat",")",",","normalized","time",",","dims",":","(","batch",",","n_forecasts",")","*","``","lags","``","(","torch.Tensor",",","float",")",",","dims",":","(","batch",",","n_lags",")","*","``","seasonalities","``","(","torch.Tensor",",","float",")",",","dict","of","named","seasonalities","(","keys",")","with","their","features","(","values",")",",","dims","of","each","dict","value","(","batch",",","n_forecasts",",","n_features",")","*","``","covariates","``","(","torch.Tensor",",","float",")",",","dict","of","named","covariates","(","keys",")","with","their","features","(","values",")",",","dims","of","each","dict","value",":","(","batch",",","n_lags",")","*","``","events","``","(","torch.Tensor",",","float",")",",","all","event","features",",","dims","(","batch",",","n_forecasts",",","n_features",")","*","``","regressors","``","(","torch.Tensor",",","float",")",",","all","regressor","features",",","dims","(","batch",",","n_forecasts",",","n_features",")","*","``","predict_mode","``","(","bool",")",",","optional","and","only","passed","during","prediction","meta",":","dict",",","default=None","Metadata","about","the","all","the","samples","of","the","model","input","batch",".","Contains","the","following",":","Model","Meta",":","*","``","df_name","``","(","list",",","str",")",",","time","series","ID","corresponding","to","each","sample","of","the","input","batch",".","Note","--","--","The","meta","is","sorted","in","the","same","way","the","inputs","are","sorted",".","Note","--","--","The","default","None","value","allows","the","forward","method","to","be","used","without","providing","the","meta","argument",".","This","was","designed","to","avoid","issues","with","the","library","`","lr_finder","`","https",":","\/\/github.com\/davidtvs\/pytorch-lr-finder","while","having","``","config_trend.trend_global_local=","''","local","''","``",".","The","turnaround","consists","on","passing","the","same","meta","(","dummy","ID",")","to","all","the","samples","of","the","batch",".","Internally",",","this","is","equivalent","to","use","``","config_trend.trend_global_local=","''","global","''","``","to","find","the","optimal","learning","rate",".","compute_components_flag",":","bool",",","default=False","If","True",",","components","will","be","computed",".","Returns","--","--","--","-","torch.Tensor","Forecast","of","dims","(","batch",",","n_forecasts",",","no_quantiles",")"]
code: def forward(
      self,
      inputs: Dict,
      meta: Dict = None,
      compute_components_flag: bool = False,
  ) -> torch.Tensor:
      """This method defines the model forward pass.
      Note
      ----
      Time input is required. Minimum model setup is a linear trend.
      Parameters
      ----------
          inputs : dict
              Model inputs, each of len(df) but with varying dimensions
              Note
              ----
              Contains the following data:
              Model Inputs
                  * ``time`` (torch.Tensor , loat), normalized time, dims: (batch, n_forecasts)
                  * ``lags`` (torch.Tensor, float), dims: (batch, n_lags)
                  * ``seasonalities`` (torch.Tensor, float), dict of named seasonalities (keys) with their features
                  (values), dims of each dict value (batch, n_forecasts, n_features)
                  * ``covariates`` (torch.Tensor, float), dict of named covariates (keys) with their features
                  (values), dims of each dict value: (batch, n_lags)
                  * ``events`` (torch.Tensor, float), all event features, dims (batch, n_forecasts, n_features)
                  * ``regressors``(torch.Tensor, float), all regressor features, dims (batch, n_forecasts, n_features)
                  * ``predict_mode`` (bool), optional and only passed during prediction
          meta : dict, default=None
              Metadata about the all the samples of the model input batch.
              Contains the following:
              Model Meta:
                  * ``df_name`` (list, str), time series ID corresponding to each sample of the input batch.
              Note
              ----
              The meta is sorted in the same way the inputs are sorted.
              Note
              ----
              The default None value allows the forward method to be used without providing the meta argument.
              This was designed to avoid issues with the library `lr_finder` https://github.com/davidtvs/pytorch-lr-finder
              while having  ``config_trend.trend_global_local="local"``.
              The turnaround consists on passing the same meta (dummy ID) to all the samples of the batch.
              Internally, this is equivalent to use ``config_trend.trend_global_local="global"`` to find the optimal
              learning rate.
          compute_components_flag : bool, default=False
              If True, components will be computed.
  
      Returns
      -------
          torch.Tensor
              Forecast of dims (batch, n_forecasts, no_quantiles)
      """
      # Turnaround to avoid issues when the meta argument is None and meta_used_in_model
      if meta is None and self.meta_used_in_model:
          name_id_dummy = self.id_list[0]
          meta = OrderedDict()
          meta["df_name"] = [
              name_id_dummy for _ in range(inputs["time"].shape[0])
          ]
          meta = torch.tensor(
              [self.id_dict[i] for i in meta["df_name"]],
              device=self.device,
          )
  
      additive_components_nonstationary = torch.zeros(
          size=(
              inputs["time"].shape[0],
              inputs["time"].shape[1],
              len(self.quantiles),
          ),
          device=self.device,
      )
      multiplicative_components_nonstationary = torch.zeros(
          size=(
              inputs["time"].shape[0],
              inputs["time"].shape[1],
              len(self.quantiles),
          ),
          device=self.device,
      )
      additive_components = torch.zeros(
          size=(
              inputs["time"].shape[0],
              self.n_forecasts,
              len(self.quantiles),
          ),
          device=self.device,
      )
      components = {}
  
      # non-stationary components
      trend = self.trend(t=inputs["time"], meta=meta)
      components["trend"] = trend
  
      if "seasonalities" in inputs:
          s = self.seasonality(s=inputs["seasonalities"], meta=meta)
          if self.config_seasonality.mode == "additive":
              additive_components_nonstationary += s
          elif self.config_seasonality.mode == "multiplicative":
              multiplicative_components_nonstationary += s
          components["seasonalities"] = s
  
      if "events" in inputs:
          if "additive" in inputs["events"].keys():
              additive_events = self.scalar_features_effects(
                  inputs["events"]["additive"],
                  self.event_params["additive"],
              )
              additive_components_nonstationary += additive_events
              components["additive_events"] = additive_events
          if "multiplicative" in inputs["events"].keys():
              multiplicative_events = self.scalar_features_effects(
                  inputs["events"]["multiplicative"],
                  self.event_params["multiplicative"],
              )
              multiplicative_components_nonstationary += (
                  multiplicative_events
              )
              components[
                  "multiplicative_events"
              ] = multiplicative_events
  
      if "regressors" in inputs:
          if "additive" in inputs["regressors"].keys():
              additive_regressors = self.future_regressors(
                  inputs["regressors"]["additive"], "additive"
              )
              additive_components_nonstationary += additive_regressors
              components["additive_regressors"] = additive_regressors
          if "multiplicative" in inputs["regressors"].keys():
              multiplicative_regressors = self.future_regressors(
                  inputs["regressors"]["multiplicative"],
                  "multiplicative",
              )
              multiplicative_components_nonstationary += (
                  multiplicative_regressors
              )
              components[
                  "multiplicative_regressors"
              ] = multiplicative_regressors
  
      nonstationary_components = (  # dimensions - [batch, n_lags, median quantile]
          trend[:, : self.n_lags, 0]
          + additive_components_nonstationary[:, : self.n_lags, 0]
          + trend[:, : self.n_lags, 0].detach()
          * multiplicative_components_nonstationary[:, : self.n_lags, 0]
      )
  
      # stationarized input
      if "lags" in inputs:
          stationarized_lags = inputs["lags"] - nonstationary_components
          lags = self.auto_regression(lags=stationarized_lags)
          additive_components += lags
          components["lags"] = lags
  
      if "covariates" in inputs:
          covariates = self.forward_covar_net(
              covariates=inputs["covariates"]
          )
          additive_components += covariates
          components["covariates"] = covariates
  
      predictions_nonstationary = (
          trend[:, self.n_lags : inputs["time"].shape[1], :]
          + additive_components_nonstationary[
              :, self.n_lags : inputs["time"].shape[1], :
          ]
          + trend[:, self.n_lags : inputs["time"].shape[1], :].detach()
          * multiplicative_components_nonstationary[
              :, self.n_lags : inputs["time"].shape[1], :
          ]
      )
      prediction = (
          predictions_nonstationary
          + additive_components
          # 0 is the median quantile index
          # all multiplicative components are multiplied by the median quantile trend (uncomment line below to apply)
          # trend + additive_components + trend.detach()[:, :, 0].unsqueeze(dim=2) * multiplicative_components
      )  # dimensions - [batch, n_forecasts, no_quantiles]
  
      # check for crossing quantiles and correct them here
      if "predict_mode" in inputs.keys() and inputs["predict_mode"]:
          predict_mode = True
      else:
          predict_mode = False
      prediction_with_quantiles = (
          self._compute_quantile_forecasts_from_diffs(
              prediction, predict_mode
          )
      )
  
      # component calculation
      if compute_components_flag:
          components = self.compute_components(inputs, components, meta)
      else:
          components = None
  
      return prediction_with_quantiles, components
  
imports: import logging
  import math
  from collections import OrderedDict
  from functools import reduce
  from typing import Dict, List, Optional, Union
  import numpy
  import pytorch_lightning
  import torch
  import torch.nn
  import torchmetrics
  from neuralprophet import configure, np_types
  from neuralprophet.components.router import get_future_regressors, get_seasonality, get_trend
  from neuralprophet.utils import check_for_regularization, config_events_to_model_dims, reg_func_events, reg_func_regressors, reg_func_season, reg_func_trend
  from neuralprophet.utils_torch import init_parameter, interprete_model
label_desc: Use image node_id 10 for calling the TimeNet obj's underlying member method code with example usage: obj.forward(inputs, meta, compute_components_flag) and returns: prediction_with_quantiles,  components