class_docstr: Hierarchical text classification model with attention.
class_docstr_tok: ["Hierarchical","text","classification","model","with","attention","."]
code: def __init__(self, config, **kwargs):
      super().__init__(config, **kwargs)
  
      logging.info("Initialize HierarchicalAttentionModel...")
  
      self.vocab_size = config["data"]["vocab_size"]
      self.num_classes = config["data"]["task"]["classes"][
          "num_classes"
      ]
      self.use_true_length = config["model"].get(
          "use_true_length", False
      )
      if self.use_true_length:
          self.split_token = config["data"]["split_token"]
      self.padding_token = utils.PAD_IDX
  
      model_config = config["model"]["net"]["structure"]
      self.dropout_rate = model_config["dropout_rate"]
      self.embedding_size = model_config["embedding_size"]
      self.emb_trainable = model_config["emb_trainable"]
      self.num_layers = model_config["num_layers"]
      self.l2_reg_lambda = model_config["l2_reg_lambda"]
      self.max_len = model_config["max_len"]
      self.max_sen_len = model_config["max_sen_len"]
      self.max_doc_len = model_config["max_doc_len"]
  
      self.embed = tf.keras.layers.Embedding(
          self.vocab_size,
          self.embedding_size,
          trainable=self.emb_trainable,
          embeddings_initializer=self.embed_initializer,
      )
  
      self.embed_d = tf.keras.layers.Dropout(self.dropout_rate)
      self.sen_encoder = delta.layers.RnnAttentionEncoder(
          config, name="sen_encoder"
      )
      self.doc_encoder = delta.layers.RnnAttentionEncoder(
          config, name="doc_encoder"
      )
  
      self.final_dense = tf.keras.layers.Dense(
          self.num_classes,
          activation=tf.keras.activations.linear,
          name="final_dense",
      )
      logging.info("Initialize HierarchicalAttentionModel done.")
  
file_path: delta/delta/models/text_hierarchical_model.py
imports: import pickle
  from absl import logging
  import delta.compat
  import delta.utils
  import delta.layers
  from delta.layers.utils import cut_or_padding
  from delta.layers.utils import compute_sen_lens
  from delta.layers.utils import compute_doc_lens
  from delta.layers.utils import split_one_doc_to_true_len_sens
  from delta.models.text_cls_model import TextClassModel
  from delta.utils.register import registers
label_desc: Use image node_id 1 to create a new HierarchicalAttentionModel object from inherited base classes: HierarchicalModel with example: obj = HierarchicalAttentionModel(config)