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: Adds padding so that all examples in the batch are of the same length.
  
  Args:
      batch_token_ids: Batch of examples where each example is a non-padded list
      of token ids.
      max_sequence_length_model: Maximum length of any input sequence in the batch
      to be fed to the model.
  
  Returns:
      Padded batch with all examples of the same length.
docstr_tok: ["Adds","padding","so","that","all","examples","in","the","batch","are","of","the","same","length",".","Args",":","batch_token_ids",":","Batch","of","examples","where","each","example","is","a","non-padded","list","of","token","ids",".","max_sequence_length_model",":","Maximum","length","of","any","input","sequence","in","the","batch","to","be","fed","to","the","model",".","Returns",":","Padded","batch","with","all","examples","of","the","same","length","."]
code: def _add_padding_to_batch(
      self,
      batch_token_ids: List[List[int]],
      max_sequence_length_model: int,
  ) -> List[List[int]]:
      """Adds padding so that all examples in the batch are of the same length.
  
      Args:
          batch_token_ids: Batch of examples where each example is a non-padded list
          of token ids.
          max_sequence_length_model: Maximum length of any input sequence in the batch
          to be fed to the model.
  
      Returns:
          Padded batch with all examples of the same length.
      """
      padded_token_ids = []
  
      # Add padding according to max_sequence_length
      # Some models don't contain pad token, we use unknown token as padding token.
      # This doesn't affect the computation since we compute an attention mask
      # anyways.
      for example_token_ids in batch_token_ids:
          # Truncate any longer sequences so that they can be fed to the model
          if len(example_token_ids) > max_sequence_length_model:
              example_token_ids = example_token_ids[
                  :max_sequence_length_model
              ]
  
          padded_token_ids.append(
              example_token_ids
              + [self.pad_token_id]
              * (max_sequence_length_model - len(example_token_ids))
          )
      return padded_token_ids
  
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 17 for calling the LanguageModelFeaturizer obj's underlying member method code with example usage: obj._add_padding_to_batch(batch_token_ids, max_sequence_length_model) and returns: padded_token_ids