code: def forward(
      self,
      src: torch.Tensor,
      prev: Optional[torch.Tensor] = None,
      key_padding_mask: Optional[torch.Tensor] = None,
      attn_mask: Optional[torch.Tensor] = None,
  ):  # -> Tuple[torch.Tensor, Any]:
      # Multi-Head attention sublayer
      if self.pre_norm:
          src = self.norm_attn(src)
      ## Multi-Head attention
      if self.res_attention:
          src2, attn, scores = self.self_attn(
              src,
              src,
              src,
              prev,
              key_padding_mask=key_padding_mask,
              attn_mask=attn_mask,
          )
      else:
          src2, attn = self.self_attn(
              src,
              src,
              src,
              key_padding_mask=key_padding_mask,
              attn_mask=attn_mask,
          )
      if self.store_attn:
          self.attn = attn
      ## Add & Norm
      src = src + self.dropout_attn(
          src2
      )  # Add: residual connection with residual dropout
      if not self.pre_norm:
          src = self.norm_attn(src)
  
      # Feed-forward sublayer
      if self.pre_norm:
          src = self.norm_ffn(src)
      ## Position-wise Feed-Forward
      src2 = self.ff(src)
      ## Add & Norm
      src = src + self.dropout_ffn(
          src2
      )  # Add: residual connection with residual dropout
      if not self.pre_norm:
          src = self.norm_ffn(src)
  
      if self.res_attention:
          return src, scores
      else:
          return src
  
imports: import math
  import numpy
  from typing import Optional
  import torch
  import torch.nn
  import torch.nn.functional
  from ..common._base_windows import BaseWindows
  from ..losses.pytorch import MAE
label_desc: Use image node_id 2 for calling the TSTEncoderLayer obj's underlying member method code with example usage: obj.forward(src, prev, key_padding_mask, attn_mask) and returns: src,  scores, src