class_docstr: Bert embedding class.
  
  Parameters
  ----------
  name : str, optional
      BERT model name, default: ``'bert-base-uncased'``.
  max_seq_len : int, optional
      Maximal sequence length, default: ``500``.
  doc_stride : int, optional
      Chunking stride, default: ``250``.
  fix_emb : boolean, optional
      Specify whether to fix pretrained BERT embeddings, default: ``True``.
  lower_case : boolean, optional
      Specify whether to use lower case, default: ``True``.
class_docstr_tok: ["Bert","embedding","class",".","Parameters","--","--","--","--","--","name",":","str",",","optional","BERT","model","name",",","default",":","``","'bert-base-uncased","'","``",".","max_seq_len",":","int",",","optional","Maximal","sequence","length",",","default",":","``","500","``",".","doc_stride",":","int",",","optional","Chunking","stride",",","default",":","``","250","``",".","fix_emb",":","boolean",",","optional","Specify","whether","to","fix","pretrained","BERT","embeddings",",","default",":","``","True","``",".","lower_case",":","boolean",",","optional","Specify","whether","to","use","lower","case",",","default",":","``","True","``","."]
code: def __init__(
      self,
      name="bert-base-uncased",
      max_seq_len=500,
      doc_stride=250,
      fix_emb=True,
      lower_case=True,
  ):
      super(BertEmbedding, self).__init__()
      self.bert_max_seq_len = max_seq_len
      self.bert_doc_stride = doc_stride
      self.fix_emb = fix_emb
  
      from transformers import BertModel
      from transformers import BertTokenizer
  
      print("[ Using pretrained BERT embeddings ]")
      self.bert_tokenizer = BertTokenizer.from_pretrained(
          name, do_lower_case=lower_case
      )
      self.bert_model = BertModel.from_pretrained(name)
      if fix_emb:
          print("[ Fix BERT layers ]")
          self.bert_model.eval()
          for param in self.bert_model.parameters():
              param.requires_grad = False
      else:
          print("[ Finetune BERT layers ]")
          self.bert_model.train()
  
      # compute weighted average over BERT layers
      self.logits_bert_layers = nn.Parameter(
          nn.init.xavier_uniform_(
              torch.Tensor(1, self.bert_model.config.num_hidden_layers)
          )
      )
  
imports: import torch
  from torch import nn
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from ...data.data import from_batch
  from ..utils.bert_utils import convert_text_to_bert_features, extract_bert_hidden_states
  from ..utils.generic_utils import dropout_fn
  from ..utils.padding_utils import pad_4d_vals
  from ..utils.vocab_utils import Vocab
label_desc: Use image node_id 1 to create a new BertEmbedding object from inherited base classes: nn with example: obj = BertEmbedding(name, max_seq_len, doc_stride, fix_emb, lower_case)