class_docstr: N-BEATS block which takes a basis function as an argument.
class_docstr_tok: ["N-BEATS","block","which","takes","a","basis","function","as","an","argument","."]
code: def forward(
      self,
      insample_y: torch.Tensor,
      futr_exog: torch.Tensor,
      hist_exog: torch.Tensor,
      stat_exog: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      # Flatten MLP inputs [B, L+H, C] -> [B, (L+H)*C]
      # Contatenate [ Y_t, | X_{t-L},..., X_{t} | F_{t-L},..., F_{t+H} | S ]
      batch_size = len(insample_y)
      if self.hist_input_size > 0:
          insample_y = torch.cat(
              (insample_y, hist_exog.reshape(batch_size, -1)), dim=1
          )
  
      if self.futr_input_size > 0:
          insample_y = torch.cat(
              (insample_y, futr_exog.reshape(batch_size, -1)), dim=1
          )
  
      if self.stat_input_size > 0:
          insample_y = torch.cat(
              (insample_y, stat_exog.reshape(batch_size, -1)), dim=1
          )
  
      # Compute local projection weights and projection
      theta = self.layers(insample_y)
  
      if isinstance(self.basis, ExogenousBasis):
          if self.futr_input_size > 0 and self.stat_input_size > 0:
              futr_exog = torch.cat((futr_exog, stat_exog), dim=2)
          elif self.futr_input_size > 0:
              futr_exog = futr_exog
          elif self.stat_input_size > 0:
              futr_exog = stat_exog
          else:
              raise (
                  ValueError(
                      "No stats or future exogenous. ExogenousBlock not supported."
                  )
              )
          backcast, forecast = self.basis(theta, futr_exog)
          return backcast, forecast
      else:
          backcast, forecast = self.basis(theta)
          return backcast, forecast
  
imports: from typing import Tuple, Optional
  import numpy
  import torch
  import torch.nn
  from ..losses.pytorch import MAE
  from ..common._base_windows import BaseWindows
label_desc: Use image node_id 2 for calling the NBEATSBlock obj's underlying member method code with example usage: obj.forward(insample_y, futr_exog, hist_exog, stat_exog) and returns: backcast,  forecast, backcast,  forecast