class_docstr: DLinear module
class_docstr_tok: ["DLinear","module"]
docstr: x_in
      comes as tuple `(x_past, x_future, x_static)` where `x_past` is the input/past chunk and `x_future`
      is the output/future chunk. Input dimensions are `(n_samples, n_time_steps, n_variables)`
docstr_tok: ["x_in","comes","as","tuple","`","(","x_past",",","x_future",",","x_static",")","`","where","`","x_past","`","is","the","input\/past","chunk","and","`","x_future","`","is","the","output\/future","chunk",".","Input","dimensions","are","`","(","n_samples",",","n_time_steps",",","n_variables",")","`"]
code: def forward(
      self,
      x_in: Tuple[
          torch.Tensor, Optional[torch.Tensor], Optional[torch.Tensor]
      ],
  ):
      """
      x_in
          comes as tuple `(x_past, x_future, x_static)` where `x_past` is the input/past chunk and `x_future`
          is the output/future chunk. Input dimensions are `(n_samples, n_time_steps, n_variables)`
      """
  
      x, x_future, x_static = x_in  # x: (batch, in_len, in_dim)
      batch, _, _ = x.shape
  
      if self.shared_weights:
          # discard covariates, to ensure that in_dim == out_dim
          x = x[:, :, : self.output_dim]
  
          # extract trend
          res, trend = self.decomposition(x)
  
          # permute to (batch, in_dim, in_len) and apply linear layer on last dimension
          seasonal_output = self.linear_seasonal(res.permute(0, 2, 1))
          trend_output = self.linear_trend(trend.permute(0, 2, 1))
  
          x = seasonal_output + trend_output
  
          # extract nr_params
          x = x.view(
              batch,
              self.output_dim,
              self.output_chunk_length,
              self.nr_params,
          )
  
          # permute back to (batch, out_len, out_dim, nr_params)
          x = x.permute(0, 2, 1, 3)
  
      else:
          res, trend = self.decomposition(x)
  
          # (in_len * in_dim) => (out_len * out_dim * out_nr_params)
          seasonal_output = self.linear_seasonal(res.view(batch, -1))
          trend_output = self.linear_trend(trend.view(batch, -1))
          seasonal_output = seasonal_output.view(
              batch,
              self.output_chunk_length,
              self.output_dim * self.nr_params,
          )
          trend_output = trend_output.view(
              batch,
              self.output_chunk_length,
              self.output_dim * self.nr_params,
          )
  
          x = seasonal_output + trend_output
  
          if self.future_cov_dim != 0:
              # x_future might be shorter than output_chunk_length when n < output_chunk_length
              # so we need to pad it with zeros at the end to match the output_chunk_length
              x_future = torch.nn.functional.pad(
                  input=x_future,
                  pad=(
                      0,
                      0,
                      0,
                      self.output_chunk_length - x_future.shape[1],
                  ),
                  mode="constant",
                  value=0,
              )
  
              fut_cov_output = self.linear_fut_cov(x_future)
              x = x + fut_cov_output.view(
                  batch,
                  self.output_chunk_length,
                  self.output_dim * self.nr_params,
              )
  
          if self.static_cov_dim != 0:
              static_cov_output = self.linear_static_cov(
                  x_static.reshape(batch, -1)
              )
              x = x + static_cov_output.view(
                  batch,
                  self.output_chunk_length,
                  self.output_dim * self.nr_params,
              )
  
          # extract nr_params
          x = x.view(
              batch,
              self.output_chunk_length,
              self.output_dim,
              self.nr_params,
          )
  
      return x
  
imports: from typing import Optional, Tuple
  import torch
  import torch.nn
  from darts.logging import raise_if
  from darts.models.forecasting.pl_forecasting_module import PLMixedCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import MixedCovariatesTorchModel
label_desc: Use image node_id 2 for calling the _DLinearModule obj's underlying member method code with example usage: obj.forward(x_in) and returns: x