class_docstr: This module wraps the self-attention with the output-layer, similar to the architecture in BERT.
  Details in the paper:
  [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, Devlin et al, 2019]
  (https://api.semanticscholar.org/CorpusID:52967399)
  
  # Parameters
  
  hidden_size: `int`
  num_attention_heads: `int`
  attention_dropout: `float` (default = `0.0`)
      Dropout probability for the `SelfAttention` layer.
  hidden_dropout: `float` (default = `0.0`)
      Dropout probability for the `OutputLayer`.
docstr: # Parameters
  
  input_tensor : `torch.Tensor`
      Shape `batch_size x seq_len x hidden_dim`
  attention_mask : `torch.BoolTensor`, optional
      Shape `batch_size x seq_len`
  head_mask : `torch.BoolTensor`, optional
  output_attentions : `bool`
      Whether to also return the attention probabilities, default = `False`
docstr_tok: ["#","Parameters","input_tensor",":","`","torch.Tensor","`","Shape","`","batch_size","x","seq_len","x","hidden_dim","`","attention_mask",":","`","torch.BoolTensor","`",",","optional","Shape","`","batch_size","x","seq_len","`","head_mask",":","`","torch.BoolTensor","`",",","optional","output_attentions",":","`","bool","`","Whether","to","also","return","the","attention","probabilities",",","default","=","`","False","`"]
code: def forward(
      self,
      input_tensor: torch.Tensor,
      attention_mask: torch.BoolTensor,
      head_mask: Optional[torch.Tensor] = None,
      encoder_hidden_states: Optional[torch.Tensor] = None,
      encoder_attention_mask: Optional[torch.BoolTensor] = None,
      output_attentions: bool = False,
  ):
      """
      # Parameters
  
      input_tensor : `torch.Tensor`
          Shape `batch_size x seq_len x hidden_dim`
      attention_mask : `torch.BoolTensor`, optional
          Shape `batch_size x seq_len`
      head_mask : `torch.BoolTensor`, optional
      output_attentions : `bool`
          Whether to also return the attention probabilities, default = `False`
      """
  
      if encoder_hidden_states is not None:
          attention_mask = encoder_attention_mask
  
      self_output = self.self(
          input_tensor,
          source_states=encoder_hidden_states,
          attention_mask=attention_mask,
          head_mask=head_mask,
          output_attentions=output_attentions,
      )
  
      attention_output = self.output(
          self_output.hidden_states, input_tensor
      )
      outputs = AttentionOutput(
          attention_output,
          self_output.key_value_state,
          self_output.position_bias,
          self_output.attention_probs,
      )
      return outputs
  
imports: from typing import Union, Optional, TYPE_CHECKING
  from dataclasses import dataclass
  import torch
  from allennlp.common import FromParams
  from allennlp.modules.transformer.transformer_module import TransformerModule
  from allennlp.modules.transformer.activation_layer import ActivationLayer
  from allennlp.modules.transformer.attention_module import SelfAttention, AttentionOutput
  from allennlp.modules.transformer.output_layer import OutputLayer
  from allennlp.modules.transformer.util import FloatT
label_desc: Use image node_id 2 for calling the AttentionLayer obj's underlying member method code with example usage: obj.forward(input_tensor, attention_mask, head_mask, encoder_hidden_states, encoder_attention_mask, output_attentions) and returns: outputs