class_docstr: NHITS block which takes a basis function as an argument.
class_docstr_tok: ["NHITS","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]:
      # Pooling
      # Pool1d needs 3D input, (B,C,L), adding C dimension
      insample_y = insample_y.unsqueeze(1)
      insample_y = self.pooling_layer(insample_y)
      insample_y = insample_y.squeeze(1)
  
      # 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:
          hist_exog = hist_exog.permute(
              0, 2, 1
          )  # [B, L, C] -> [B, C, L]
          hist_exog = self.pooling_layer(hist_exog)
          hist_exog = hist_exog.permute(
              0, 2, 1
          )  # [B, C, L] -> [B, L, C]
          insample_y = torch.cat(
              (insample_y, hist_exog.reshape(batch_size, -1)), dim=1
          )
  
      if self.futr_input_size > 0:
          futr_exog = futr_exog.permute(
              0, 2, 1
          )  # [B, L, C] -> [B, C, L]
          futr_exog = self.pooling_layer(futr_exog)
          futr_exog = futr_exog.permute(
              0, 2, 1
          )  # [B, C, L] -> [B, L, C]
          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)
      backcast, forecast = self.basis(theta)
      return backcast, forecast
  
imports: from typing import Tuple, Optional
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from ..losses.pytorch import MAE
  from ..common._base_windows import BaseWindows
label_desc: Use image node_id 2 for calling the NHITSBlock obj's underlying member method code with example usage: obj.forward(insample_y, futr_exog, hist_exog, stat_exog) and returns: backcast,  forecast