class_docstr: Support huggingface text backbones.
  Refer to https://github.com/huggingface/transformers
class_docstr_tok: ["Support","huggingface","text","backbones",".","Refer","to","https",":","\/\/github.com\/huggingface\/transformers"]
docstr: Load a pretrained huggingface text transformer backbone.
  
  Parameters
  ----------
  prefix
      The model prefix.
  checkpoint_name
      Name of the checkpoint or the local directory of a custom checkpoint.
      We support loading checkpoint from
      Huggingface Models list: https://huggingface.co/models
      For example, you may use
          English backbones:
              - 'microsoft/deberta-v3-base'
              - 'bert-base-uncased'
              - 'google/electra-base-discriminator'
              - 'distilroberta-base'
          Multilingual backbones:
              - 'microsoft/mdeberta-v3-base'
              - 'xlm-roberta-base'
  num_classes
      The number of classes. 1 for a regression task.
  pooling_mode
      The pooling mode for the Transformer. Can be "cls", or "mean"
  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.
  use_fast
      Use a fast Rust-based tokenizer if it is supported for a given model.
      If a fast tokenizer is not available for a given model, a normal Python-based tokenizer is returned instead.
      See: https://huggingface.co/docs/transformers/model_doc/auto#transformers.AutoTokenizer.from_pretrained.use_fast
docstr_tok: ["Load","a","pretrained","huggingface","text","transformer","backbone",".","Parameters","--","--","--","--","--","prefix","The","model","prefix",".","checkpoint_name","Name","of","the","checkpoint","or","the","local","directory","of","a","custom","checkpoint",".","We","support","loading","checkpoint","from","Huggingface","Models","list",":","https",":","\/\/huggingface.co\/models","For","example",",","you","may","use","English","backbones",":","-","'microsoft\/deberta-v3-base'","-","'bert-base-uncased'","-","'google\/electra-base-discriminator'","-","'distilroberta-base'","Multilingual","backbones",":","-","'microsoft\/mdeberta-v3-base'","-","'xlm-roberta-base'","num_classes","The","number","of","classes",".","1","for","a","regression","task",".","pooling_mode","The","pooling","mode","for","the","Transformer",".","Can","be","``","cls","''",",","or","``","mean","''","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",".","use_fast","Use","a","fast","Rust-based","tokenizer","if","it","is","supported","for","a","given","model",".","If","a","fast","tokenizer","is","not","available","for","a","given","model",",","a","normal","Python-based","tokenizer","is","returned","instead",".","See",":","https",":","\/\/huggingface.co\/docs\/transformers\/model_doc\/auto","#","transformers.AutoTokenizer.from_pretrained.use_fast"]
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",
      use_fast: Optional[bool] = True,
  ):
      """
      Load a pretrained huggingface text transformer backbone.
  
      Parameters
      ----------
      prefix
          The model prefix.
      checkpoint_name
          Name of the checkpoint or the local directory of a custom checkpoint.
          We support loading checkpoint from
          Huggingface Models list: https://huggingface.co/models
          For example, you may use
              English backbones:
                  - 'microsoft/deberta-v3-base'
                  - 'bert-base-uncased'
                  - 'google/electra-base-discriminator'
                  - 'distilroberta-base'
              Multilingual backbones:
                  - 'microsoft/mdeberta-v3-base'
                  - 'xlm-roberta-base'
      num_classes
          The number of classes. 1 for a regression task.
      pooling_mode
          The pooling mode for the Transformer. Can be "cls", or "mean"
      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.
      use_fast
          Use a fast Rust-based tokenizer if it is supported for a given model.
          If a fast tokenizer is not available for a given model, a normal Python-based tokenizer is returned instead.
          See: https://huggingface.co/docs/transformers/model_doc/auto#transformers.AutoTokenizer.from_pretrained.use_fast
      """
      super().__init__()
      logger.debug(f"initializing {checkpoint_name}")
      self.checkpoint_name = checkpoint_name
      self.num_classes = num_classes
  
      self.config, self.model = get_hf_config_and_model(
          checkpoint_name=checkpoint_name,
          pretrained=pretrained,
          low_cpu_mem_usage=low_cpu_mem_usage,
      )
      self.tokenizer_name = tokenizer_name
      self.tokenizer = get_pretrained_tokenizer(
          tokenizer_name=self.tokenizer_name,
          checkpoint_name=self.checkpoint_name,
          use_fast=use_fast,
      )
  
      if isinstance(self.model, T5PreTrainedModel):
          self.is_t5 = True
          # Remove the decoder in T5. We will only use the T5 encoder for extracting the embeddings
          del self.model.decoder
      else:
          self.is_t5 = False
  
      self.gradient_checkpointing = gradient_checkpointing
      if gradient_checkpointing:
          self.model.gradient_checkpointing_enable()
          if self.is_t5:
              self.dummy_layer = DummyLayer()
  
      self.out_features = self.model.config.hidden_size
  
      self.head = (
          nn.Linear(self.out_features, num_classes)
          if num_classes
          else nn.Identity()
      )
      self.head.apply(init_weights)
  
      self.prefix = prefix
      self.pooling_mode = pooling_mode
  
      self.name_to_id = self.get_layer_ids()
      self.head_layer_names = [
          n for n, layer_id in self.name_to_id.items() if layer_id == 0
      ]
  
      if (
          hasattr(self.model.config, "type_vocab_size")
          and self.model.config.type_vocab_size <= 1
      ):
          # Disable segment ids for models like RoBERTa
          self.disable_seg_ids = True
      else:
          self.disable_seg_ids = False
  
imports: import logging
  from typing import Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from transformers import logging
  from transformers.models.t5 import T5PreTrainedModel
  from ..constants import AUTOMM, COLUMN, COLUMN_FEATURES, FEATURES, LABEL, LOGITS, MASKS, TEXT_SEGMENT_IDS, TEXT_TOKEN_IDS, TEXT_VALID_LENGTH
  from .utils import DummyLayer, assign_layer_ids, get_column_features, get_hf_config_and_model, get_pretrained_tokenizer, init_weights
label_desc: Use image node_id 1 to create a new HFAutoModelForTextPrediction object from inherited base classes: nn with example: obj = HFAutoModelForTextPrediction(prefix, checkpoint_name, num_classes, pooling_mode, gradient_checkpointing, low_cpu_mem_usage, pretrained, tokenizer_name, use_fast)