code: def forward(
      self,
      src: torch.Tensor,
      key_padding_mask: Optional[torch.Tensor] = None,
      attn_mask: Optional[torch.Tensor] = None,
  ):
      output = src
      scores = None
      if self.res_attention:
          for mod in self.layers:
              output, scores = mod(
                  output,
                  prev=scores,
                  key_padding_mask=key_padding_mask,
                  attn_mask=attn_mask,
              )
          return output
      else:
          for mod in self.layers:
              output = mod(
                  output,
                  key_padding_mask=key_padding_mask,
                  attn_mask=attn_mask,
              )
          return output
  
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 TSTEncoder obj's underlying member method code with example usage: obj.forward(src, key_padding_mask, attn_mask) and returns: output, output