class_docstr: Named entity recognition with huggingface backbones. Inherit from HFAutoModelForTextPrediction.
class_docstr_tok: ["Named","entity","recognition","with","huggingface","backbones",".","Inherit","from","HFAutoModelForTextPrediction","."]
docstr: Load a pretrained huggingface text transformer backbone.
  Parameters
  ----------
  prefix
      The model prefix.
  checkpoint_name
      Name of the checkpoint. We support loading checkpoint from
      Huggingface Models list: https://huggingface.co/models
      For example, you may use
          English backbones:
              - 'bert-base-cased'
  num_classes
      The number of classes. 1 for a regression task.
  pooling_mode
      The pooling mode to be used, it is not used in the NER task.
  gradient_checkpointing
      Whether to enable gradient checkpointing
  low_cpu_mem_usage
      Whether to turn on the optimization of reducing the peak CPU memory usage when loading the pretrained model.
  pretrained
      Whether using the pretrained weights. If pretrained=True, download the pretrained model.
  tokenizer_name
      Name of the huggingface tokenizer type.
docstr_tok: ["Load","a","pretrained","huggingface","text","transformer","backbone",".","Parameters","--","--","--","--","--","prefix","The","model","prefix",".","checkpoint_name","Name","of","the","checkpoint",".","We","support","loading","checkpoint","from","Huggingface","Models","list",":","https",":","\/\/huggingface.co\/models","For","example",",","you","may","use","English","backbones",":","-","'bert-base-cased'","num_classes","The","number","of","classes",".","1","for","a","regression","task",".","pooling_mode","The","pooling","mode","to","be","used",",","it","is","not","used","in","the","NER","task",".","gradient_checkpointing","Whether","to","enable","gradient","checkpointing","low_cpu_mem_usage","Whether","to","turn","on","the","optimization","of","reducing","the","peak","CPU","memory","usage","when","loading","the","pretrained","model",".","pretrained","Whether","using","the","pretrained","weights",".","If","pretrained=True",",","download","the","pretrained","model",".","tokenizer_name","Name","of","the","huggingface","tokenizer","type","."]
code: def __init__(
      self,
      prefix: str,
      checkpoint_name: str = "microsoft/deberta-v3-base",
      num_classes: Optional[int] = 0,
      pooling_mode: Optional[str] = "cls",
      gradient_checkpointing: Optional[bool] = False,
      low_cpu_mem_usage: Optional[bool] = False,
      pretrained: Optional[bool] = True,
      tokenizer_name: Optional[str] = "hf_auto",
  ):
      """
      Load a pretrained huggingface text transformer backbone.
      Parameters
      ----------
      prefix
          The model prefix.
      checkpoint_name
          Name of the checkpoint. We support loading checkpoint from
          Huggingface Models list: https://huggingface.co/models
          For example, you may use
              English backbones:
                  - 'bert-base-cased'
      num_classes
          The number of classes. 1 for a regression task.
      pooling_mode
          The pooling mode to be used, it is not used in the NER task.
      gradient_checkpointing
          Whether to enable gradient checkpointing
      low_cpu_mem_usage
          Whether to turn on the optimization of reducing the peak CPU memory usage when loading the pretrained model.
      pretrained
          Whether using the pretrained weights. If pretrained=True, download the pretrained model.
      tokenizer_name
          Name of the huggingface tokenizer type.
      """
      logger.debug(f"initializing {checkpoint_name}")
      super().__init__(
          prefix=prefix,
          checkpoint_name=checkpoint_name,
          num_classes=num_classes,
          pooling_mode=pooling_mode,
          gradient_checkpointing=gradient_checkpointing,
          low_cpu_mem_usage=low_cpu_mem_usage,
          pretrained=pretrained,
          tokenizer_name=tokenizer_name,
      )
  
      if self.config.model_type in {"gpt2", "roberta"}:
          # Refer to this PR: https://github.com/huggingface/transformers/pull/12116
          self.tokenizer = get_pretrained_tokenizer(
              tokenizer_name=self.tokenizer_name,
              checkpoint_name=self.checkpoint_name,
              add_prefix_space=True,
          )
  
      # some checkpoint such as deberta does not specify model_max_length
      # here, we reset it using model config.
      if hasattr(self.model.config, "max_position_embeddings"):
          self.tokenizer.model_max_length = (
              self.model.config.max_position_embeddings
          )
      if hasattr(self.model.config, "n_positions"):
          self.tokenizer.model_max_length = (
              self.model.config.n_positions
          )
  
file_path: autogluon/multimodal/src/autogluon/multimodal/models/ner_text.py
imports: import logging
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import nn
  from transformers import logging
  from ..constants import AUTOMM, COLUMN, COLUMN_FEATURES, FEATURES, LABEL, LOGITS, MASKS, NER_ANNOTATION, TEXT_SEGMENT_IDS, TEXT_TOKEN_IDS, TEXT_VALID_LENGTH, TOKEN_WORD_MAPPING, WORD_OFFSETS
  from .huggingface_text import HFAutoModelForTextPrediction
  from .utils import assign_layer_ids, get_column_features, get_pretrained_tokenizer
label_desc: Use image node_id 1 to create a new HFAutoModelForNER object from inherited base classes: HFAutoModelForTextPrediction with example: obj = HFAutoModelForNER(prefix, checkpoint_name, num_classes, pooling_mode, gradient_checkpointing, low_cpu_mem_usage, pretrained, tokenizer_name)