class_docstr: Response selector using supervised embeddings.
  
  The response selector embeds user inputs
  and candidate response into the same space.
  Supervised embeddings are trained by maximizing similarity between them.
  It also provides rankings of the response that did not "win".
  
  The supervised response selector needs to be preceded by
  a featurizer in the pipeline.
  This featurizer creates the features used for the embeddings.
  It is recommended to use ``CountVectorsFeaturizer`` that
  can be optionally preceded by ``SpacyNLP`` and ``SpacyTokenizer``.
  
  Based on the starspace idea from: https://arxiv.org/abs/1709.03856.
  However, in this implementation the `mu` parameter is treated differently
  and additional hidden layers are added together with dropout.
class_docstr_tok: ["Response","selector","using","supervised","embeddings",".","The","response","selector","embeds","user","inputs","and","candidate","response","into","the","same","space",".","Supervised","embeddings","are","trained","by","maximizing","similarity","between","them",".","It","also","provides","rankings","of","the","response","that","did","not","``","win","''",".","The","supervised","response","selector","needs","to","be","preceded","by","a","featurizer","in","the","pipeline",".","This","featurizer","creates","the","features","used","for","the","embeddings",".","It","is","recommended","to","use","``","CountVectorsFeaturizer","``","that","can","be","optionally","preceded","by","``","SpacyNLP","``","and","``","SpacyTokenizer","``",".","Based","on","the","starspace","idea","from",":","https",":","\/\/arxiv.org\/abs\/1709.03856",".","However",",","in","this","implementation","the","`","mu","`","parameter","is","treated","differently","and","additional","hidden","layers","are","added","together","with","dropout","."]
docstr: The component's default config (see parent class for full docstring).
code: def get_default_config() -> Dict[Text, Any]:
      """The component's default config (see parent class for full docstring)."""
      return {
          **DIETClassifier.get_default_config(),
          # ## Architecture of the used neural network
          # Hidden layer sizes for layers before the embedding layers for user message
          # and labels.
          # The number of hidden layers is equal to the length of the corresponding
          # list.
          HIDDEN_LAYERS_SIZES: {TEXT: [256, 128], LABEL: [256, 128]},
          # Whether to share the hidden layer weights between input words
          # and responses
          SHARE_HIDDEN_LAYERS: False,
          # Number of units in transformer
          TRANSFORMER_SIZE: None,
          # Number of transformer layers
          NUM_TRANSFORMER_LAYERS: 0,
          # Number of attention heads in transformer
          NUM_HEADS: 4,
          # If 'True' use key relative embeddings in attention
          KEY_RELATIVE_ATTENTION: False,
          # If 'True' use key relative embeddings in attention
          VALUE_RELATIVE_ATTENTION: False,
          # Max position for relative embeddings. Only in effect if key-
          # or value relative attention are turned on
          MAX_RELATIVE_POSITION: 5,
          # Use a unidirectional or bidirectional encoder.
          UNIDIRECTIONAL_ENCODER: False,
          # ## Training parameters
          # Initial and final batch sizes:
          # Batch size will be linearly increased for each epoch.
          BATCH_SIZES: [64, 256],
          # Strategy used when creating batches.
          # Can be either 'sequence' or 'balanced'.
          BATCH_STRATEGY: BALANCED,
          # Number of epochs to train
          EPOCHS: 300,
          # Set random seed to any 'int' to get reproducible results
          RANDOM_SEED: None,
          # Initial learning rate for the optimizer
          LEARNING_RATE: 0.001,
          # ## Parameters for embeddings
          # Dimension size of embedding vectors
          EMBEDDING_DIMENSION: 20,
          # Default dense dimension to use if no dense features are present.
          DENSE_DIMENSION: {TEXT: 512, LABEL: 512},
          # Default dimension to use for concatenating sequence and sentence features.
          CONCAT_DIMENSION: {TEXT: 512, LABEL: 512},
          # The number of incorrect labels. The algorithm will minimize
          # their similarity to the user input during training.
          NUM_NEG: 20,
          # Type of similarity measure to use, either 'auto' or 'cosine' or 'inner'.
          SIMILARITY_TYPE: AUTO,
          # The type of the loss function, either 'cross_entropy' or 'margin'.
          LOSS_TYPE: CROSS_ENTROPY,
          # Number of top actions for which confidences should be predicted.
          # Set to 0 if confidences for all intents should be reported.
          RANKING_LENGTH: 10,
          # Determines whether the confidences of the chosen top actions should be
          # renormalized so that they sum up to 1. By default, we do not renormalize
          # and return the confidences for the top actions as is.
          # Note that renormalization only makes sense if confidences are generated
          # via `softmax`.
          RENORMALIZE_CONFIDENCES: False,
          # Indicates how similar the algorithm should try to make embedding vectors
          # for correct labels.
          # Should be 0.0 < ... < 1.0 for 'cosine' similarity type.
          MAX_POS_SIM: 0.8,
          # Maximum negative similarity for incorrect labels.
          # Should be -1.0 < ... < 1.0 for 'cosine' similarity type.
          MAX_NEG_SIM: -0.4,
          # If 'True' the algorithm only minimizes maximum similarity over
          # incorrect intent labels, used only if 'loss_type' is set to 'margin'.
          USE_MAX_NEG_SIM: True,
          # Scale loss inverse proportionally to confidence of correct prediction
          SCALE_LOSS: True,
          # ## Regularization parameters
          # The scale of regularization
          REGULARIZATION_CONSTANT: 0.002,
          # Fraction of trainable weights in internal layers.
          CONNECTION_DENSITY: 1.0,
          # The scale of how important is to minimize the maximum similarity
          # between embeddings of different labels.
          NEGATIVE_MARGIN_SCALE: 0.8,
          # Dropout rate for encoder
          DROP_RATE: 0.2,
          # Dropout rate for attention
          DROP_RATE_ATTENTION: 0,
          # If 'True' apply dropout to sparse input tensors
          SPARSE_INPUT_DROPOUT: False,
          # If 'True' apply dropout to dense input tensors
          DENSE_INPUT_DROPOUT: False,
          # ## Evaluation parameters
          # How often calculate validation accuracy.
          # Small values may hurt performance, e.g. model accuracy.
          EVAL_NUM_EPOCHS: 20,
          # How many examples to use for hold out validation set
          # Large values may hurt performance, e.g. model accuracy.
          EVAL_NUM_EXAMPLES: 0,
          # ## Selector config
          # If 'True' random tokens of the input message will be masked and the model
          # should predict those tokens.
          MASKED_LM: False,
          # Name of the intent for which this response selector is to be trained
          RETRIEVAL_INTENT: None,
          # Boolean flag to check if actual text of the response
          # should be used as ground truth label for training the model.
          USE_TEXT_AS_LABEL: False,
          # If you want to use tensorboard to visualize training
          # and validation metrics,
          # set this option to a valid output directory.
          TENSORBOARD_LOG_DIR: None,
          # Define when training metrics for tensorboard should be logged.
          # Either after every epoch or for every training step.
          # Valid values: 'epoch' and 'batch'
          TENSORBOARD_LOG_LEVEL: "epoch",
          # Specify what features to use as sequence and sentence features
          # By default all features in the pipeline are used.
          FEATURIZERS: [],
          # Perform model checkpointing
          CHECKPOINT_MODEL: False,
          # if 'True' applies sigmoid on all similarity terms and adds it
          # to the loss function to ensure that similarity values are
          # approximately bounded. Used inside cross-entropy loss only.
          CONSTRAIN_SIMILARITIES: False,
          # Model confidence to be returned during inference. Currently, the only
          # possible value is `softmax`.
          MODEL_CONFIDENCE: SOFTMAX,
      }
  
imports: from __future__ import annotations
  import copy
  import logging
  from rasa.nlu.featurizers.featurizer import Featurizer
  import numpy
  import tensorflow
  from typing import Any, Dict, Optional, Text, Tuple, Union, List, Type
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.constants import DIAGNOSTIC_DATA
  from rasa.shared.nlu.training_data import util
  import rasa.shared.utils.io
  from rasa.shared.exceptions import InvalidConfigException
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.nlu.classifiers.diet_classifier import DIET, LABEL_KEY, LABEL_SUB_KEY, SENTENCE, SEQUENCE, DIETClassifier
  from rasa.nlu.extractors.extractor import EntityTagSpec
  from rasa.utils.tensorflow import rasa_layers
  from rasa.utils.tensorflow.constants import LABEL, HIDDEN_LAYERS_SIZES, SHARE_HIDDEN_LAYERS, TRANSFORMER_SIZE, NUM_TRANSFORMER_LAYERS, NUM_HEADS, BATCH_SIZES, BATCH_STRATEGY, EPOCHS, RANDOM_SEED, LEARNING_RATE, RANKING_LENGTH, RENORMALIZE_CONFIDENCES, LOSS_TYPE, SIMILARITY_TYPE, NUM_NEG, SPARSE_INPUT_DROPOUT, DENSE_INPUT_DROPOUT, MASKED_LM, ENTITY_RECOGNITION, INTENT_CLASSIFICATION, EVAL_NUM_EXAMPLES, EVAL_NUM_EPOCHS, UNIDIRECTIONAL_ENCODER, DROP_RATE, DROP_RATE_ATTENTION, CONNECTION_DENSITY, NEGATIVE_MARGIN_SCALE, REGULARIZATION_CONSTANT, SCALE_LOSS, USE_MAX_NEG_SIM, MAX_NEG_SIM, MAX_POS_SIM, EMBEDDING_DIMENSION, BILOU_FLAG, KEY_RELATIVE_ATTENTION, VALUE_RELATIVE_ATTENTION, MAX_RELATIVE_POSITION, RETRIEVAL_INTENT, USE_TEXT_AS_LABEL, CROSS_ENTROPY, AUTO, BALANCED, TENSORBOARD_LOG_DIR, TENSORBOARD_LOG_LEVEL, CONCAT_DIMENSION, FEATURIZERS, CHECKPOINT_MODEL, DENSE_DIMENSION, CONSTRAIN_SIMILARITIES, MODEL_CONFIDENCE, SOFTMAX
  from rasa.nlu.constants import RESPONSE_SELECTOR_PROPERTY_NAME, RESPONSE_SELECTOR_RETRIEVAL_INTENTS, RESPONSE_SELECTOR_RESPONSES_KEY, RESPONSE_SELECTOR_PREDICTION_KEY, RESPONSE_SELECTOR_RANKING_KEY, RESPONSE_SELECTOR_UTTER_ACTION_KEY, RESPONSE_SELECTOR_DEFAULT_INTENT, DEFAULT_TRANSFORMER_SIZE
  from rasa.shared.nlu.constants import TEXT, INTENT, RESPONSE, INTENT_RESPONSE_KEY, INTENT_NAME_KEY, PREDICTED_CONFIDENCE_KEY
  from rasa.utils.tensorflow.model_data import RasaModelData
  from rasa.utils.tensorflow.models import RasaModel
label_desc: Use image node_id 2 for calling the ResponseSelector obj's underlying member method code with example usage: obj.get_default_config() and returns: dict