code: def __init__(self, layer_num, head_num, head_size, weights=None):
      super().__init__()
      hidden_dim = head_num * head_size
      # TODO(bhsueh) The implementation of hidden_act='gelu' is differen
      #  to FT's (and google BERT) implementation
      # FT's implementation is equivalent to hidden_act='gelu_new',
      # but there are some issues for int8 sparse under gelu_new
      conf = BertConfig(
          hidden_size=hidden_dim,
          intermediate_size=4 * hidden_dim,
          num_attention_heads=head_num,
          num_hidden_layers=layer_num,
          hidden_act="gelu",
      )
      self.encoder = BertEncoder(conf)
      w = {}
      for k, v in weights.weights.items():
          if k.startswith("encoder") and not k.endswith("_amax"):
              w[k[13:]] = weights.weights[k]
      self.encoder.load_state_dict(w)
      self.head_mask = [None] * layer_num
  
imports: from typing import List, Optional
  from loguru import logger
  from nebullvm.optional_modules.torch import torch, torch_distributed
  from nebullvm.optional_modules.huggingface import BertConfig, BertEmbeddings, BertEncoder, BertPooler, BertPreTrainedModel
  from .checkpoint_quantization import checkpoint_quantization
label_desc: Use image node_id 1 to create a new HuggingFaceEncoder object from inherited base classes: torch.nn with example: obj = HuggingFaceEncoder(layer_num, head_num, head_size, weights)