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: Computes language model docs for all examples in the batch.
  
  Args:
      batch_examples: Batch of message objects for which language model docs
      need to be computed.
      attribute: Property of message to be processed, one of ``TEXT`` or
      ``RESPONSE``.
      inference_mode: Whether the call is during inference or during training.
  
  
  Returns:
      List of language model docs for each message in batch.
docstr_tok: ["Computes","language","model","docs","for","all","examples","in","the","batch",".","Args",":","batch_examples",":","Batch","of","message","objects","for","which","language","model","docs","need","to","be","computed",".","attribute",":","Property","of","message","to","be","processed",",","one","of","``","TEXT","``","or","``","RESPONSE","``",".","inference_mode",":","Whether","the","call","is","during","inference","or","during","training",".","Returns",":","List","of","language","model","docs","for","each","message","in","batch","."]
code: def _get_docs_for_batch(
      self,
      batch_examples: List[Message],
      attribute: Text,
      inference_mode: bool = False,
  ) -> List[Dict[Text, Any]]:
      """Computes language model docs for all examples in the batch.
  
      Args:
          batch_examples: Batch of message objects for which language model docs
          need to be computed.
          attribute: Property of message to be processed, one of ``TEXT`` or
          ``RESPONSE``.
          inference_mode: Whether the call is during inference or during training.
  
  
      Returns:
          List of language model docs for each message in batch.
      """
      batch_tokens, batch_token_ids = self._get_token_ids_for_batch(
          batch_examples, attribute
      )
  
      (
          batch_sentence_features,
          batch_sequence_features,
      ) = self._get_model_features_for_batch(
          batch_token_ids,
          batch_tokens,
          batch_examples,
          attribute,
          inference_mode,
      )
  
      # A doc consists of
      # {'sequence_features': ..., 'sentence_features': ...}
      batch_docs = []
      for index in range(len(batch_examples)):
          doc = {
              SEQUENCE_FEATURES: batch_sequence_features[index],
              SENTENCE_FEATURES: np.reshape(
                  batch_sentence_features[index], (1, -1)
              ),
          }
          batch_docs.append(doc)
  
      return batch_docs
  
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 23 for calling the LanguageModelFeaturizer obj's underlying member method code with example usage: obj._get_docs_for_batch(batch_examples, attribute, inference_mode) and returns: batch_docs