class_docstr: A transformer encoder block consists self-attention and a feed-forward layer with pre/post process blocks
  in between.
docstr: :param data: Input tensor of shape (length, batch_size, hidden)
  :param att_mask: Optional data length mask of shape (batch_size * self.heads, 1, length)
                   to mask self-attention scores. True for padding positions.
docstr_tok: [":","param","data",":","Input","tensor","of","shape","(","length",",","batch_size",",","hidden",")",":","param","att_mask",":","Optional","data","length","mask","of","shape","(","batch_size","*","self.heads",",","1",",","length",")","to","mask","self-attention","scores",".","True","for","padding","positions","."]
code: def forward(
      self, data: pt.Tensor, att_mask: pt.Tensor = None
  ) -> pt.Tensor:
      """
      :param data: Input tensor of shape (length, batch_size, hidden)
      :param att_mask: Optional data length mask of shape (batch_size * self.heads, 1, length)
                       to mask self-attention scores. True for padding positions.
      """
      # self-attention
      data_self_att, _ = self.self_attention(
          inputs=self.pre_self_attention(data),
          previous_states=None,
          mask=att_mask,
          bias=None,
      )
      data = self.post_self_attention(data_self_att, data)
  
      # feed-forward
      data_ff = self.ff(self.pre_ff(data))
  
      data = self.post_ff(data_ff, data)
  
      if self.lhuc is not None:
          data = self.lhuc(data)
  
      return data
  
imports: from dataclasses import dataclass
  from typing import Optional, Tuple
  import torch
  import sockeye.layers
  from sockeye import constants
  from .None import config
label_desc: Use image node_id 2 for calling the TransformerEncoderBlock obj's underlying member method code with example usage: obj.forward(data, att_mask) and returns: data