class_docstr: BERT encoder for language embedding.
  
  Args:
      name (str): name of the pretrained BERT model from HuggingFace.
              Defaults to bert-base-uncased.
      add_pooling_layer (bool): whether to add a pooling layer.
      num_layers_of_embedded (int): number of layers of the embedded model.
              Defaults to 1.
      use_checkpoint (bool): whether to use gradient checkpointing.
              Defaults to False.
class_docstr_tok: ["BERT","encoder","for","language","embedding",".","Args",":","name","(","str",")",":","name","of","the","pretrained","BERT","model","from","HuggingFace",".","Defaults","to","bert-base-uncased",".","add_pooling_layer","(","bool",")",":","whether","to","add","a","pooling","layer",".","num_layers_of_embedded","(","int",")",":","number","of","layers","of","the","embedded","model",".","Defaults","to","1.","use_checkpoint","(","bool",")",":","whether","to","use","gradient","checkpointing",".","Defaults","to","False","."]
code: def __init__(
      self,
      name: str,
      add_pooling_layer: bool = False,
      num_layers_of_embedded: int = 1,
      use_checkpoint: bool = False,
  ):
      super().__init__()
      if BertConfig is None:
          raise RuntimeError(
              "transformers is not installed, please install it by: "
              "pip install transformers."
          )
      config = BertConfig.from_pretrained(name)
      config.gradient_checkpointing = use_checkpoint
      # only encoder
      self.model = HFBertModel.from_pretrained(
          name, add_pooling_layer=add_pooling_layer, config=config
      )
      self.language_dim = config.hidden_size
      self.num_layers_of_embedded = num_layers_of_embedded
  
file_path: mmdetection/mmdet/models/language_models/bert.py
imports: from collections import OrderedDict
  from typing import Sequence
  import torch
  from mmengine.model import BaseModel
  from torch import nn
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new BertEncoder object from inherited base classes: nn with example: obj = BertEncoder(name, add_pooling_layer, num_layers_of_embedded, use_checkpoint)