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: Declare instance variables with default values.
  
  Args:
      config: Configuration for the component.
      model_storage: Storage which graph components can use to persist and load
          themselves.
      resource: Resource locator for this component which can be used to persist
          and load itself from the `model_storage`.
      execution_context: Information about the current graph run.
      index_label_id_mapping: Mapping between label and index used for encoding.
      entity_tag_specs: Format specification all entity tags.
      model: Model architecture.
      all_retrieval_intents: All retrieval intents defined in the data.
      responses: All responses defined in the data.
      finetune_mode: If `True` loads the model with pre-trained weights,
          otherwise initializes it with random weights.
      sparse_feature_sizes: Sizes of the sparse features the model was trained on.
code: def __init__(
      self,
      config: Dict[Text, Any],
      model_storage: ModelStorage,
      resource: Resource,
      execution_context: ExecutionContext,
      index_label_id_mapping: Optional[Dict[int, Text]] = None,
      entity_tag_specs: Optional[List[EntityTagSpec]] = None,
      model: Optional[RasaModel] = None,
      all_retrieval_intents: Optional[List[Text]] = None,
      responses: Optional[Dict[Text, List[Dict[Text, Any]]]] = None,
      sparse_feature_sizes: Optional[
          Dict[Text, Dict[Text, List[int]]]
      ] = None,
  ) -> None:
      """Declare instance variables with default values.
  
      Args:
          config: Configuration for the component.
          model_storage: Storage which graph components can use to persist and load
              themselves.
          resource: Resource locator for this component which can be used to persist
              and load itself from the `model_storage`.
          execution_context: Information about the current graph run.
          index_label_id_mapping: Mapping between label and index used for encoding.
          entity_tag_specs: Format specification all entity tags.
          model: Model architecture.
          all_retrieval_intents: All retrieval intents defined in the data.
          responses: All responses defined in the data.
          finetune_mode: If `True` loads the model with pre-trained weights,
              otherwise initializes it with random weights.
          sparse_feature_sizes: Sizes of the sparse features the model was trained on.
      """
      component_config = config
  
      # the following properties cannot be adapted for the ResponseSelector
      component_config[INTENT_CLASSIFICATION] = True
      component_config[ENTITY_RECOGNITION] = False
      component_config[BILOU_FLAG] = None
  
      # Initialize defaults
      self.responses = responses or {}
      self.all_retrieval_intents = all_retrieval_intents or []
      self.retrieval_intent = None
      self.use_text_as_label = False
  
      super().__init__(
          component_config,
          model_storage,
          resource,
          execution_context,
          index_label_id_mapping,
          entity_tag_specs,
          model,
          sparse_feature_sizes=sparse_feature_sizes,
      )
  
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 3 to create a new ResponseSelector object from inherited base classes: DIETClassifier with example: obj = ResponseSelector(config, model_storage, resource, execution_context, index_label_id_mapping, entity_tag_specs, model, all_retrieval_intents, responses, sparse_feature_sizes)