class_docstr: BERT model
class_docstr_tok: ["BERT","model"]
code: def __init__(
      self,
      task: str = None,
      load_checkpoint: str = None,
      label_map: Dict = None,
      num_classes: int = 2,
      suffix: bool = False,
      **kwargs,
  ):
      super(Bert, self).__init__()
      if label_map:
          self.label_map = label_map
          self.num_classes = len(label_map)
      else:
          self.num_classes = num_classes
  
      if task == "sequence_classification":
          task = "seq-cls"
          logger.warning(
              "current task name 'sequence_classification' was renamed to 'seq-cls', "
              "'sequence_classification' has been deprecated and will be removed in the future.",
          )
      if task == "seq-cls":
          self.model = BertForSequenceClassification.from_pretrained(
              pretrained_model_name_or_path="bert-base-uncased",
              num_classes=self.num_classes,
              **kwargs,
          )
          self.criterion = paddle.nn.loss.CrossEntropyLoss()
          self.metric = paddle.metric.Accuracy()
      elif task == "token-cls":
          self.model = BertForTokenClassification.from_pretrained(
              pretrained_model_name_or_path="bert-base-uncased",
              num_classes=self.num_classes,
              **kwargs,
          )
          self.criterion = paddle.nn.loss.CrossEntropyLoss()
          self.metric = ChunkEvaluator(
              label_list=[
                  self.label_map[i]
                  for i in sorted(self.label_map.keys())
              ],
              suffix=suffix,
          )
      elif task == "text-matching":
          self.model = BertModel.from_pretrained(
              pretrained_model_name_or_path="bert-base-uncased",
              **kwargs,
          )
          self.dropout = paddle.nn.Dropout(0.1)
          self.classifier = paddle.nn.Linear(
              self.model.config["hidden_size"] * 3, 2
          )
          self.criterion = paddle.nn.loss.CrossEntropyLoss()
          self.metric = paddle.metric.Accuracy()
      elif task is None:
          self.model = BertModel.from_pretrained(
              pretrained_model_name_or_path="bert-base-uncased",
              **kwargs,
          )
      else:
          raise RuntimeError(
              "Unknown task {}, task should be one in {}".format(
                  task, self._tasks_supported
              )
          )
  
      self.task = task
  
      if load_checkpoint is not None and os.path.isfile(
          load_checkpoint
      ):
          state_dict = paddle.load(load_checkpoint)
          self.set_state_dict(state_dict)
          logger.info(
              "Loaded parameters from %s"
              % os.path.abspath(load_checkpoint)
          )
  
file_path: PaddleHub/modules/text/language_model/bert-base-uncased/module.py
imports: from typing import Dict
  import os
  import math
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddlenlp.transformers.bert.modeling import BertForSequenceClassification, BertModel, BertForTokenClassification
  from paddlenlp.transformers.bert.tokenizer import BertTokenizer
  from paddlenlp.metrics import ChunkEvaluator
  from paddlehub.module.module import moduleinfo
  from paddlehub.module.nlp_module import TransformerModule
  from paddlehub.utils.log import logger
label_desc: Use image node_id 1 to create a new Bert object from inherited base classes: nn with example: obj = Bert(task, load_checkpoint, label_map, num_classes, suffix)