class_docstr: Label Attention Module for label-specific representations
  The module can be used right after the Partitioned Attention, or it can be experimented with for the transition stack
class_docstr_tok: ["Label","Attention","Module","for","label-specific","representations","The","module","can","be","used","right","after","the","Partitioned","Attention",",","or","it","can","be","experimented","with","for","the","transition","stack"]
code: def __init__(
      self,
      d_model,
      d_input_proj,
      d_k,
      d_v,
      d_l,
      d_proj,
      combine_as_self,
      use_resdrop=True,
      q_as_matrix=False,
      residual_dropout=0.1,
      attention_dropout=0.1,
      d_positional=None,
      d_ff=2048,
      relu_dropout=0.2,
      lattn_partitioned=True,
  ):
      super().__init__()
      self.ff_dim = d_proj * d_l
  
      if not lattn_partitioned:
          self.d_positional = 0
      else:
          self.d_positional = d_positional if d_positional else 0
  
      if d_input_proj:
          if d_input_proj <= self.d_positional:
              raise ValueError(
                  "Illegal argument for d_input_proj: d_input_proj %d is smaller than d_positional %d"
                  % (d_input_proj, self.d_positional)
              )
          self.input_projection = nn.Linear(
              d_model - self.d_positional,
              d_input_proj - self.d_positional,
              bias=False,
          )
          d_input = d_input_proj
      else:
          self.input_projection = None
          d_input = d_model
  
      self.label_attention = LabelAttention(
          d_input,
          d_k,
          d_v,
          d_l,
          d_proj,
          combine_as_self,
          use_resdrop,
          q_as_matrix,
          residual_dropout,
          attention_dropout,
          self.d_positional,
      )
  
      if not lattn_partitioned:
          self.lal_ff = PositionwiseFeedForward(
              self.ff_dim, d_ff, relu_dropout, residual_dropout
          )
      else:
          self.lal_ff = PartitionedPositionwiseFeedForward(
              self.ff_dim,
              d_ff,
              self.d_positional,
              relu_dropout,
              residual_dropout,
          )
  
imports: import numpy
  import functools
  import sys
  import torch
  from torch.autograd import Variable
  import torch.nn
  import torch.nn.init
label_desc: Use image node_id 1 to create a new LabelAttentionModule object from inherited base classes: nn with example: obj = LabelAttentionModule(d_model, d_input_proj, d_k, d_v, d_l, d_proj, combine_as_use_resdrop, q_as_matrix, residual_dropout, attention_dropout, d_positional, d_ff, relu_dropout, lattn_partitioned)