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 a mask for padding tokens.
  
  This mask will be used by the language model so that it does not attend to
  padding tokens.
  
  Args:
      actual_sequence_lengths: List of length of each example without any
      padding.
      max_input_sequence_length: Maximum length of a sequence that will be
      present in the input batch. This is
      after taking into consideration the maximum input sequence the model
      can handle. Hence it can never be
      greater than self.max_model_sequence_length in case the model
      applies length restriction.
  
  Returns: Computed attention mask, 0 for padding and 1 for non-padding
  tokens.
docstr_tok: ["Computes","a","mask","for","padding","tokens",".","This","mask","will","be","used","by","the","language","model","so","that","it","does","not","attend","to","padding","tokens",".","Args",":","actual_sequence_lengths",":","List","of","length","of","each","example","without","any","padding",".","max_input_sequence_length",":","Maximum","length","of","a","sequence","that","will","be","present","in","the","input","batch",".","This","is","after","taking","into","consideration","the","maximum","input","sequence","the","model","can","handle",".","Hence","it","can","never","be","greater","than","self.max_model_sequence_length","in","case","the","model","applies","length","restriction",".","Returns",":","Computed","attention","mask",",","0","for","padding","and","1","for","non-padding","tokens","."]
code: def _compute_attention_mask(
      actual_sequence_lengths: List[int], max_input_sequence_length: int
  ) -> np.ndarray:
      """Computes a mask for padding tokens.
  
      This mask will be used by the language model so that it does not attend to
      padding tokens.
  
      Args:
          actual_sequence_lengths: List of length of each example without any
          padding.
          max_input_sequence_length: Maximum length of a sequence that will be
          present in the input batch. This is
          after taking into consideration the maximum input sequence the model
          can handle. Hence it can never be
          greater than self.max_model_sequence_length in case the model
          applies length restriction.
  
      Returns: Computed attention mask, 0 for padding and 1 for non-padding
      tokens.
      """
      attention_mask = []
  
      for actual_sequence_length in actual_sequence_lengths:
          # add 1s for present tokens, fill up the remaining space up to max
          # sequence length with 0s (non-existing tokens)
          padded_sequence = [1] * min(
              actual_sequence_length, max_input_sequence_length
          ) + [0] * (
              max_input_sequence_length
              - min(actual_sequence_length, max_input_sequence_length)
          )
          attention_mask.append(padded_sequence)
  
      return np.array(attention_mask).astype(np.float32)
  
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 15 for calling the LanguageModelFeaturizer obj's underlying member method code with example usage: obj._compute_attention_mask(actual_sequence_lengths, max_input_sequence_length) and returns: np