docstr: Builds the internal matrices and start parameter
  
  TODO: currently only one attention head, implement MHA
code: def __init__(
      self,
      input_size,
      output_size,
      input_dropout,
      length_limit=None,
      use_position=False,
      num_heads=1,
  ):
      """
      Builds the internal matrices and start parameter
  
      TODO: currently only one attention head, implement MHA
      """
      super().__init__()
  
      self.input_size = input_size
      self.output_size = output_size
      self.inv_sqrt_output_size = 1 / output_size**0.5
      self.num_heads = num_heads
  
      self.w_query = nn.Linear(input_size, output_size)
      self.w_key = nn.Linear(input_size, output_size)
      self.w_value = nn.Linear(input_size, output_size)
  
      self.register_parameter(
          "start_embedding",
          torch.nn.Parameter(
              0.2 * torch.randn(input_size, requires_grad=True)
          ),
      )
      if isinstance(input_dropout, nn.Module):
          self.input_dropout = input_dropout
      else:
          self.input_dropout = nn.Dropout(input_dropout)
  
      if length_limit is not None and length_limit < 1:
          raise ValueError("length_limit < 1 makes no sense")
      self.length_limit = length_limit
  
      self.use_position = use_position
      if use_position:
          self.position_encoding = SinusoidalEncoding(
              model_dim=self.input_size, max_len=512
          )
  
file_path: stanza/stanza/models/constituency/transformer_tree_stack.py
imports: from collections import namedtuple
  import torch
  import torch.nn
  from stanza.models.constituency.positional_encoding import SinusoidalEncoding
  from stanza.models.constituency.tree_stack import TreeStack
label_desc: Use image node_id 1 to create a new TransformerTreeStack object from inherited base classes: nn with example: obj = TransformerTreeStack(input_size, output_size, input_dropout, length_limit, use_position, num_heads)