class_docstr: Transformer Encoder is stacked with several
  TransformerdecLayers, consist of beamsearch for infrence.
class_docstr_tok: ["Transformer","Encoder","is","stacked","with","several","TransformerdecLayers",",","consist","of","beamsearch","for","infrence","."]
code: def __init__(self, config, embed_layer, vocab_size, **kwargs):
      super().__init__(**kwargs)
      model_config = config["model"]["net"]["structure"]
      self.is_infer = config["model"]["is_infer"]
      if self.is_infer:
          self.length_penalty = model_config.get("length_penalty")
      self.dropout_rate = model_config.get("dropout_rate")
      self.num_layers = model_config.get("num_layers")
      self.embedding_size = model_config.get("embedding_size")
      self.max_dec_len = model_config.get("max_dec_len")
      self.padding_id = model_config.get("padding_id", 0)
      self.sos_id = model_config.get("sos_id", 4)
      self.eos_id = model_config.get("eos_id", 5)
      self.beam_size = model_config.get("beam_size")
      self.use_const = model_config.get("use_const", True)
      self.share_embedding = model_config.get("share_embedding", True)
  
      self.vocab_size = vocab_size
      self.embed_dropout = tf.keras.layers.Dropout(self.dropout_rate)
  
      embed_layer, pos_embed_layer = embed_layer
      if self.share_embedding:
          self.pos_embed_layer = pos_embed_layer
      else:
          self.pos_embed_layer = delta.layers.PositionEmbedding(
              self.max_dec_len,
              self.embedding_size,
              self.use_const,
              "dec_pos",
          )
      self.embed_layer = embed_layer
      self.transformer_decs = [
          TransformerDecoderLayer(config)
          for _ in range(self.num_layers)
      ]
      self.final_dense = tf.keras.layers.Dense(vocab_size)
  
imports: import math
  from absl import logging
  import numpy
  import delta.compat
  from tensorflow.python.util import nest
  from delta.layers.base_layer import Layer
  from delta.layers import utils_tf
  import delta.layers
label_desc: Use image node_id 1 to create a new TransformerDecoder object from inherited base classes: Layer with example: obj = TransformerDecoder(config, embed_layer, vocab_size)