docstr: A transformer encoder block consists of a self-attention and a feed-
  forward layer with pre/post process blocks in between.
docstr_tok: ["A","transformer","encoder","block","consists","of","a","self-attention","and","a","feed-","forward","layer","with","pre\/post","process","blocks","in","between","."]
code: def hybrid_forward(
      self,
      F,
      data: Tensor,
      enc_out: Tensor,
      mask: Optional[Tensor] = None,
      is_train: bool = True,
  ) -> Tensor:
      """
      A transformer encoder block consists of a self-attention and a feed-
      forward layer with pre/post process blocks in between.
      """
  
      # embedding
      inputs = self.enc_input_layer(data)
  
      # self-attention
      data_att, cache = self.dec_self_att(
          self.dec_pre_self_att(inputs, None),
          mask,
          self.cache.copy() if not is_train else None,
      )
      data = self.dec_post_self_att(data_att, inputs)
  
      # encoder attention
      data_att = self.dec_enc_att(data, enc_out)
      data = self.dec_post_att(data_att, data)
  
      # feed-forward
      data_ff = self.dec_ff(data)
      data = self.dec_post_ff(data_ff, data)
  
      if not is_train:
          self.cache = cache.copy()
  
      return data
  
file_path: gluonts/src/gluonts/mx/model/transformer/trans_decoder.py
imports: from typing import Dict, Optional
  from mxnet.gluon import HybridBlock
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from .layers import InputLayer, MultiHeadAttention, MultiHeadSelfAttention, TransformerFeedForward, TransformerProcessBlock
label_desc: Use image node_id 3 for calling the TransformerDecoder obj's underlying member method code with example usage: obj.hybrid_forward(F, data, enc_out, mask, is_train) and returns: data