class_docstr: A featurizer that uses transformer-based language models.
  
  This component loads a pre-trained language model
  from the Transformers library (https://github.com/huggingface/transformers)
  including BERT, GPT, GPT-2, xlnet, distilbert, and roberta.
  It also tokenizes and featurizes the featurizable dense attributes of
  each message.
class_docstr_tok: ["A","featurizer","that","uses","transformer-based","language","models",".","This","component","loads","a","pre-trained","language","model","from","the","Transformers","library","(","https",":","\/\/github.com\/huggingface\/transformers",")","including","BERT",",","GPT",",","GPT-2",",","xlnet",",","distilbert",",","and","roberta",".","It","also","tokenizes","and","featurizes","the","featurizable","dense","attributes","of","each","message","."]
docstr: Tries to load the model instance.
  
  Model loading should be skipped in unit tests.
  See unit tests for examples.
docstr_tok: ["Tries","to","load","the","model","instance",".","Model","loading","should","be","skipped","in","unit","tests",".","See","unit","tests","for","examples","."]
code: def _load_model_instance(self) -> None:
      """Tries to load the model instance.
  
      Model loading should be skipped in unit tests.
      See unit tests for examples.
      """
      from rasa.nlu.utils.hugging_face.registry import (
          model_class_dict,
          model_tokenizer_dict,
      )
  
      logger.debug(f"Loading Tokenizer and Model for {self.model_name}")
  
      self.tokenizer = model_tokenizer_dict[
          self.model_name
      ].from_pretrained(self.model_weights, cache_dir=self.cache_dir)
      self.model = model_class_dict[self.model_name].from_pretrained(
          self.model_weights, cache_dir=self.cache_dir
      )
  
      # Use a universal pad token since all transformer architectures do not have a
      # consistent token. Instead of pad_token_id we use unk_token_id because
      # pad_token_id is not set for all architectures. We can't add a new token as
      # well since vocabulary resizing is not yet supported for TF classes.
      # Also, this does not hurt the model predictions since we use an attention mask
      # while feeding input.
      self.pad_token_id = self.tokenizer.unk_token_id
  
imports: from __future__ import annotations
  import numpy
  import logging
  from typing import Any, Text, List, Dict, Tuple, Type
  import tensorflow
  from rasa.engine.graph import ExecutionContext, GraphComponent
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.featurizers.dense_featurizer.dense_featurizer import DenseFeaturizer
  from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.nlu.constants import DENSE_FEATURIZABLE_ATTRIBUTES, SEQUENCE_FEATURES, SENTENCE_FEATURES, NO_LENGTH_RESTRICTION, NUMBER_OF_SUB_TOKENS, TOKENS_NAMES
  from rasa.shared.nlu.constants import TEXT, ACTION_TEXT
  from rasa.utils import train_utils
  from rasa.utils.tensorflow.model_data import ragged_array_to_ndarray
label_desc: Use image node_id 8 for calling the LanguageModelFeaturizer obj's underlying member method code with example usage: obj._load_model_instance() without return types