class_docstr: Creates an embedding from all features for a sequence attribute; facilitates MLM.
  
  This layer combines all features for an attribute and embeds them using a
  transformer, optionally doing masked language modeling. The layer is meant only for
  attributes with sequence-level features, such as `text`, `response` and
  `action_text`.
  
  Internally, this layer applies the following steps:
  1. Combine features using `RasaFeatureCombiningLayer`.
  2. Apply a dense layer(s) to the combined features.
  3. Optionally, and only during training for the `text` attribute, apply masking to
      the features and create further helper variables for masked language modeling.
  4. Embed the features using a transformer, effectively reducing variable-length
      sequences of features to fixed-size embeddings.
  
  Arguments:
      attribute: Name of attribute (e.g. `text` or `label`) whose features will be
          processed.
      attribute_signature: A dictionary containing two lists of feature signatures,
          one for each feature type (`sentence` or `sequence`) of the given attribute.
      config: A model config used for correctly parameterising the underlying layers.
  
  Input shape:
      Tuple of three input tensors:
          sequence_features: List of 3-D dense or sparse tensors, each with shape
              `(batch_size, max_seq_length, input_dim)` where `input_dim` can be
              different for sparse vs dense tensors. See the input shape of
              `ConcatenateSparseDenseFeatures` for more information.
          sentence_features: List of 3-D dense or sparse tensors, each with shape
              `(batch_size, 1, input_dim)` where `input_dim` can be different for
              sparse vs dense tensors, and can differ from that in
              `sequence_features`. See the input shape of
              `ConcatenateSparseDenseFeatures` for more information.
          sequence_feature_lengths: Dense tensor of shape `(batch_size, )`.
  
  Output shape:
      outputs: `(batch_size, seq_length, units)` where `units` matches the underlying
          transformer's output size (if present), otherwise it matches the output size
          of the `Ffnn` block applied to the combined features, or it's the output
          size of the underlying `RasaFeatureCombiningLayer` if the `Ffnn` block has 0
          layers. `seq_length` is the sum of the sequence dimension
          sizes of sequence- and sentence-level features (for details, see the output
          shape of `RasaFeatureCombiningLayer`). If both feature types are present,
          then `seq_length` will be 1 + the length of the longest sequence of real
          tokens across all examples in the given batch.
      seq_sent_features: `(batch_size, seq_length, hidden_dim)`, where `hidden_dim` is
          the output size of the underlying `Ffnn` block, or the output size of the
          underlying `RasaFeatureCombiningLayer` if the `Ffnn` block has 0 layers.
      mask_combined_sequence_sentence: `(batch_size, seq_length, 1)`
      token_ids: `(batch_size, seq_length, id_dim)`. `id_dim` is 2 when no dense
          sequence-level features are present. Otherwise, it's arbitrarily chosen to
          match the last dimension size of the first dense sequence-level feature in
          the input list of features.
      mlm_boolean_mask: `(batch_size, seq_length, 1)`, empty tensor if not doing MLM.
      attention_weights: `(transformer_layers, batch_size, num_transformer_heads,
          seq_length, seq_length)`, empty tensor if the transformer has 0 layers.
  
  Raises:
      A `TFLayerConfigException` if no feature signatures for sequence-level features
          are provided.
  
  Attributes:
      output_units: The last dimension size of the layer's first output (`outputs`).
class_docstr_tok: ["Creates","an","embedding","from","all","features","for","a","sequence","attribute",";","facilitates","MLM",".","This","layer","combines","all","features","for","an","attribute","and","embeds","them","using","a","transformer",",","optionally","doing","masked","language","modeling",".","The","layer","is","meant","only","for","attributes","with","sequence-level","features",",","such","as","`","text","`",",","`","response","`","and","`","action_text","`",".","Internally",",","this","layer","applies","the","following","steps",":","1",".","Combine","features","using","`","RasaFeatureCombiningLayer","`",".","2",".","Apply","a","dense","layer","(","s",")","to","the","combined","features",".","3",".","Optionally",",","and","only","during","training","for","the","`","text","`","attribute",",","apply","masking","to","the","features","and","create","further","helper","variables","for","masked","language","modeling",".","4",".","Embed","the","features","using","a","transformer",",","effectively","reducing","variable-length","sequences","of","features","to","fixed-size","embeddings",".","Arguments",":","attribute",":","Name","of","attribute","(","e.g",".","`","text","`","or","`","label","`",")","whose","features","will","be","processed",".","attribute_signature",":","A","dictionary","containing","two","lists","of","feature","signatures",",","one","for","each","feature","type","(","`","sentence","`","or","`","sequence","`",")","of","the","given","attribute",".","config",":","A","model","config","used","for","correctly","parameterising","the","underlying","layers",".","Input","shape",":","Tuple","of","three","input","tensors",":","sequence_features",":","List","of","3-D","dense","or","sparse","tensors",",","each","with","shape","`","(","batch_size",",","max_seq_length",",","input_dim",")","`","where","`","input_dim","`","can","be","different","for","sparse","vs","dense","tensors",".","See","the","input","shape","of","`","ConcatenateSparseDenseFeatures","`","for","more","information",".","sentence_features",":","List","of","3-D","dense","or","sparse","tensors",",","each","with","shape","`","(","batch_size",",","1",",","input_dim",")","`","where","`","input_dim","`","can","be","different","for","sparse","vs","dense","tensors",",","and","can","differ","from","that","in","`","sequence_features","`",".","See","the","input","shape","of","`","ConcatenateSparseDenseFeatures","`","for","more","information",".","sequence_feature_lengths",":","Dense","tensor","of","shape","`","(","batch_size",",",")","`",".","Output","shape",":","outputs",":","`","(","batch_size",",","seq_length",",","units",")","`","where","`","units","`","matches","the","underlying","transformer","'s","output","size","(","if","present",")",",","otherwise","it","matches","the","output","size","of","the","`","Ffnn","`","block","applied","to","the","combined","features",",","or","it","'s","the","output","size","of","the","underlying","`","RasaFeatureCombiningLayer","`","if","the","`","Ffnn","`","block","has","0","layers",".","`","seq_length","`","is","the","sum","of","the","sequence","dimension","sizes","of","sequence-","and","sentence-level","features","(","for","details",",","see","the","output","shape","of","`","RasaFeatureCombiningLayer","`",")",".","If","both","feature","types","are","present",",","then","`","seq_length","`","will","be","1","+","the","length","of","the","longest","sequence","of","real","tokens","across","all","examples","in","the","given","batch",".","seq_sent_features",":","`","(","batch_size",",","seq_length",",","hidden_dim",")","`",",","where","`","hidden_dim","`","is","the","output","size","of","the","underlying","`","Ffnn","`","block",",","or","the","output","size","of","the","underlying","`","RasaFeatureCombiningLayer","`","if","the","`","Ffnn","`","block","has","0","layers",".","mask_combined_sequence_sentence",":","`","(","batch_size",",","seq_length",",","1",")","`","token_ids",":","`","(","batch_size",",","seq_length",",","id_dim",")","`",".","`","id_dim","`","is","2","when","no","dense","sequence-level","features","are","present",".","Otherwise",",","it","'s","arbitrarily","chosen","to","match","the","last","dimension","size","of","the","first","dense","sequence-level","feature","in","the","input","list","of","features",".","mlm_boolean_mask",":","`","(","batch_size",",","seq_length",",","1",")","`",",","empty","tensor","if","not","doing","MLM",".","attention_weights",":","`","(","transformer_layers",",","batch_size",",","num_transformer_heads",",","seq_length",",","seq_length",")","`",",","empty","tensor","if","the","transformer","has","0","layers",".","Raises",":","A","`","TFLayerConfigException","`","if","no","feature","signatures","for","sequence-level","features","are","provided",".","Attributes",":","output_units",":","The","last","dimension","size","of","the","layer","'s","first","output","(","`","outputs","`",")","."]
docstr: Determines the output units based on what layer components are present.
  
  The size depends on which component is the last created one in the internal
  pipeline that is `RasaFeatureCombiningLayer` -> `Ffnn` -> `Transformer`, since
  not all the components are always created.
docstr_tok: ["Determines","the","output","units","based","on","what","layer","components","are","present",".","The","size","depends","on","which","component","is","the","last","created","one","in","the","internal","pipeline","that","is","`","RasaFeatureCombiningLayer","`","-",">","`","Ffnn","`","-",">","`","Transformer","`",",","since","not","all","the","components","are","always","created","."]
code: def _calculate_output_units(
      self,
      attribute: Text,
      transformer_layers: int,
      transformer_units: int,
      config: Dict[Text, Any],
  ) -> int:
      """Determines the output units based on what layer components are present.
  
      The size depends on which component is the last created one in the internal
      pipeline that is `RasaFeatureCombiningLayer` -> `Ffnn` -> `Transformer`, since
      not all the components are always created.
      """
      # transformer is the last component
      if transformer_layers > 0:
          return transformer_units
  
      # the Ffnn block is the last component
      if len(config[HIDDEN_LAYERS_SIZES][attribute]) > 0:
          # this is the output size of the last layer of the Ffnn block
          return config[HIDDEN_LAYERS_SIZES][attribute][-1]
  
      # only the RasaFeatureCombiningLayer is present
      return self._tf_layers[self.FEATURE_COMBINING].output_units
  
imports: import tensorflow
  import numpy
  from typing import Text, List, Dict, Any, Union, Optional, Tuple, Callable
  from rasa.shared.nlu.constants import TEXT
  from rasa.utils.tensorflow.model_data import FeatureSignature
  from rasa.utils.tensorflow.constants import REGULARIZATION_CONSTANT, CONNECTION_DENSITY, NUM_TRANSFORMER_LAYERS, TRANSFORMER_SIZE, NUM_HEADS, UNIDIRECTIONAL_ENCODER, KEY_RELATIVE_ATTENTION, VALUE_RELATIVE_ATTENTION, MAX_RELATIVE_POSITION, MASKED_LM, HIDDEN_LAYERS_SIZES, DROP_RATE, SPARSE_INPUT_DROPOUT, DENSE_INPUT_DROPOUT, DENSE_DIMENSION, CONCAT_DIMENSION, DROP_RATE_ATTENTION, SEQUENCE, SENTENCE
  from rasa.utils.tensorflow import layers
  from rasa.utils.tensorflow.exceptions import TFLayerConfigException
  from rasa.utils.tensorflow.transformer import TransformerEncoder
  from rasa.nlu.constants import DEFAULT_TRANSFORMER_SIZE
label_desc: Use image node_id 5 for calling the RasaSequenceLayer obj's underlying member method code with example usage: obj._calculate_output_units(attribute, transformer_layers, transformer_units, config) and returns: self, transformer_units, config