class_docstr: Torchscriptable version of `BertLayer` from Huggingface transformers v2.3.0
  https://github.com/huggingface/transformers/blob/v2.3.0/transformers/modeling_bert.py # noqa
  
  Modifies the `forward` function as well as uses scriptable `BertAttentionJit`
  
  Changes to `forward` function::
      Typed inputs and modifies the output to be a List[Tensor]
class_docstr_tok: ["Torchscriptable","version","of","`","BertLayer","`","from","Huggingface","transformers","v2.3.0","https",":","\/\/github.com\/huggingface\/transformers\/blob\/v2.3.0\/transformers\/modeling_bert.py","#","noqa","Modifies","the","`","forward","`","function","as","well","as","uses","scriptable","`","BertAttentionJit","`","Changes","to","`","forward","`","function",":",":","Typed","inputs","and","modifies","the","output","to","be","a","List","[","Tensor","]"]
code: def forward(
      self,
      hidden_states: Tensor,
      attention_mask: Optional[Tensor] = None,
      head_mask: Optional[Tensor] = None,
      encoder_hidden_states: Optional[Tensor] = None,
      encoder_attention_mask: Optional[Tensor] = None,
  ) -> List[Tensor]:
      self_attention_outputs = self.attention(
          hidden_states, attention_mask, head_mask
      )
      attention_output = self_attention_outputs[0]
      outputs = self_attention_outputs[
          1:
      ]  # add self attentions if we output attention weights
  
      intermediate_output = self.intermediate(attention_output)
      layer_output = self.output(intermediate_output, attention_output)
      outputs = (layer_output,) + outputs
      return outputs
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
  from mmf.utils.patch import restore_saved_modules, safecopy_modules
  from torch import nn, Tensor
label_desc: Use image node_id 2 for calling the BertLayerJit obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, head_mask, encoder_hidden_states, encoder_attention_mask) and returns: outputs