class_docstr: Complete Bert Model (Transformer encoder).
class_docstr_tok: ["Complete","Bert","Model","(","Transformer","encoder",")","."]
code: def forward(self, hidden_states, attention_mask, head_mask=None):
      all_hidden_states = ()
      all_attentions = ()
      for i, layer_module in enumerate(self.layer):
          if self.output_hidden_states:
              all_hidden_states = all_hidden_states + (hidden_states,)
  
          layer_outputs = layer_module(
              hidden_states, attention_mask, head_mask[i]
          )
          hidden_states = layer_outputs[0]
  
          if self.output_attentions:
              all_attentions = all_attentions + (layer_outputs[1],)
  
      # Add last layer
      if self.output_hidden_states:
          all_hidden_states = all_hidden_states + (hidden_states,)
  
      outputs = (hidden_states,)
      if self.output_hidden_states:
          outputs = outputs + (all_hidden_states,)
      if self.output_attentions:
          outputs = outputs + (all_attentions,)
      # last-layer hidden state, (all hidden states), (all attentions)
      return outputs
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  import math
  import torch
  from torch import nn
  from towhee.models.layers.activations import swish, gelu
label_desc: Use image node_id 2 for calling the BertEncoder obj's underlying member method code with example usage: obj.forward(hidden_states, attention_mask, head_mask) and returns: outputs