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 returns the values of each model component.
  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)
      components_raw : dict
          components to be computed
  -------
      dict
          Containing forecast coomponents with elements of dims (batch, n_forecasts)
docstr_tok: ["This","method","returns","the","values","of","each","model","component",".","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",")","components_raw",":","dict","components","to","be","computed","--","--","--","-","dict","Containing","forecast","coomponents","with","elements","of","dims","(","batch",",","n_forecasts",")"]
code: def compute_components(
      self, inputs: Dict, components_raw: Dict, meta: Dict
  ) -> Dict:
      """This method returns the values of each model component.
      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)
          components_raw : dict
              components to be computed
      -------
          dict
              Containing forecast coomponents with elements of dims (batch, n_forecasts)
      """
      components = {}
  
      components["trend"] = components_raw["trend"][
          :, self.n_lags : inputs["time"].shape[1], :
      ]
      if self.config_trend is not None and "seasonalities" in inputs:
          for name, features in inputs["seasonalities"].items():
              components[
                  f"season_{name}"
              ] = self.seasonality.compute_fourier(
                  features=features[
                      :, self.n_lags : inputs["time"].shape[1], :
                  ],
                  name=name,
                  meta=meta,
              )
      if self.n_lags > 0 and "lags" in inputs:
          components["ar"] = components_raw["lags"]
      if (
          self.config_lagged_regressors is not None
          and "covariates" in inputs
      ):
          # Combined forward pass
          all_covariates = components_raw["covariates"]
          # Calculate the contribution of each covariate on each forecast
          covar_attributions = self.covar_weights
          # Sum the contributions of all covariates
          covar_attribution_sum_per_forecast = reduce(
              torch.add,
              [
                  torch.sum(covar, axis=1)
                  for _, covar in covar_attributions.items()
              ],
          ).to(all_covariates.device)
          for name in inputs["covariates"].keys():
              # Distribute the contribution of the current covariate to the combined forward pass
              # 1. Calculate the relative share of each covariate on the total attributions
              # 2. Multiply the relative share with the combined forward pass
              components[f"lagged_regressor_{name}"] = torch.multiply(
                  all_covariates,
                  torch.divide(
                      torch.sum(covar_attributions[name], axis=1).to(
                          all_covariates.device
                      ),
                      covar_attribution_sum_per_forecast,
                  ).reshape(self.n_forecasts, len(self.quantiles)),
              )
      if (
          self.config_events is not None
          or self.config_holidays is not None
      ) and "events" in inputs:
          if "additive" in inputs["events"].keys():
              components["events_additive"] = components_raw[
                  "additive_events"
              ][:, self.n_lags : inputs["time"].shape[1], :]
          if "multiplicative" in inputs["events"].keys():
              components["events_multiplicative"] = components_raw[
                  "multiplicative_events"
              ][:, self.n_lags : inputs["time"].shape[1], :]
          for event, configs in self.events_dims.items():
              mode = configs["mode"]
              indices = configs["event_indices"]
              if mode == "additive":
                  features = inputs["events"]["additive"][
                      :, self.n_lags : inputs["time"].shape[1], :
                  ]
                  params = self.event_params["additive"]
              else:
                  features = inputs["events"]["multiplicative"][
                      :, self.n_lags : inputs["time"].shape[1], :
                  ]
                  params = self.event_params["multiplicative"]
              components[
                  f"event_{event}"
              ] = self.scalar_features_effects(
                  features=features, params=params, indices=indices
              )
      if self.config_regressors is not None and "regressors" in inputs:
          if "additive" in inputs["regressors"].keys():
              components["future_regressors_additive"] = components_raw[
                  "additive_regressors"
              ][:, self.n_lags : inputs["time"].shape[1], :]
  
          if "multiplicative" in inputs["regressors"].keys():
              components[
                  "future_regressors_multiplicative"
              ] = components_raw["multiplicative_regressors"][
                  :, self.n_lags : inputs["time"].shape[1], :
              ]
  
          for (
              regressor,
              configs,
          ) in self.future_regressors.regressors_dims.items():
              mode = configs["mode"]
              index = []
              index.append(configs["regressor_index"])
              features = inputs["regressors"][mode]
              components[
                  f"future_regressor_{regressor}"
              ] = self.future_regressors(
                  features[:, self.n_lags : inputs["time"].shape[1], :],
                  mode,
                  indeces=index,
              )
  
      return 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 11 for calling the TimeNet obj's underlying member method code with example usage: obj.compute_components(inputs, components_raw, meta) and returns: components