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: Validates sequence length.
  
  Checks if sequence lengths of inputs are less than
  the max sequence length the model can handle.
  
  This method should throw an error during training, and log a debug
  message during inference if any of the input examples have a length
  greater than maximum sequence length allowed.
  
  Args:
      actual_sequence_lengths: original sequence length of all inputs
      batch_examples: all message instances in the batch
      attribute: attribute of message object to be processed
      inference_mode: whether this is during training or inference
docstr_tok: ["Validates","sequence","length",".","Checks","if","sequence","lengths","of","inputs","are","less","than","the","max","sequence","length","the","model","can","handle",".","This","method","should","throw","an","error","during","training",",","and","log","a","debug","message","during","inference","if","any","of","the","input","examples","have","a","length","greater","than","maximum","sequence","length","allowed",".","Args",":","actual_sequence_lengths",":","original","sequence","length","of","all","inputs","batch_examples",":","all","message","instances","in","the","batch","attribute",":","attribute","of","message","object","to","be","processed","inference_mode",":","whether","this","is","during","training","or","inference"]
code: def _validate_sequence_lengths(
      self,
      actual_sequence_lengths: List[int],
      batch_examples: List[Message],
      attribute: Text,
      inference_mode: bool = False,
  ) -> None:
      """Validates sequence length.
  
      Checks if sequence lengths of inputs are less than
      the max sequence length the model can handle.
  
      This method should throw an error during training, and log a debug
      message during inference if any of the input examples have a length
      greater than maximum sequence length allowed.
  
      Args:
          actual_sequence_lengths: original sequence length of all inputs
          batch_examples: all message instances in the batch
          attribute: attribute of message object to be processed
          inference_mode: whether this is during training or inference
      """
      if self.max_model_sequence_length == NO_LENGTH_RESTRICTION:
          # There is no restriction on sequence length from the model
          return
  
      for sequence_length, example in zip(
          actual_sequence_lengths, batch_examples
      ):
          if sequence_length > self.max_model_sequence_length:
              if not inference_mode:
                  raise RuntimeError(
                      f"The sequence length of '{example.get(attribute)[:20]}...' "
                      f"is too long({sequence_length} tokens) for the "
                      f"model chosen {self.model_name} which has a maximum "
                      f"sequence length of {self.max_model_sequence_length} tokens. "
                      f"Either shorten the message or use a model which has no "
                      f"restriction on input sequence length like XLNet."
                  )
              logger.debug(
                  f"The sequence length of '{example.get(attribute)[:20]}...' "
                  f"is too long({sequence_length} tokens) for the "
                  f"model chosen {self.model_name} which has a maximum "
                  f"sequence length of {self.max_model_sequence_length} tokens. "
                  f"Downstream model predictions may be affected because of this."
              )
  
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 20 for calling the LanguageModelFeaturizer obj's underlying member method code with example usage: obj._validate_sequence_lengths(actual_sequence_lengths, batch_examples, attribute, inference_mode) without return types