class_docstr: Base class to transform the dialogue state into an ML format.
  
  Subclasses of SingleStateFeaturizer will decide how a bot will
  transform the dialogue state into a dictionary mapping an attribute
  to its features. Possible attributes are: `INTENT`, `TEXT`, `ACTION_NAME`,
  `ACTION_TEXT`, `ENTITIES`, `SLOTS` and `ACTIVE_LOOP`. Each attribute will be
  featurized into a list of `rasa.utils.features.Features`.
class_docstr_tok: ["Base","class","to","transform","the","dialogue","state","into","an","ML","format",".","Subclasses","of","SingleStateFeaturizer","will","decide","how","a","bot","will","transform","the","dialogue","state","into","a","dictionary","mapping","an","attribute","to","its","features",".","Possible","attributes","are",":","`","INTENT","`",",","`","TEXT","`",",","`","ACTION_NAME","`",",","`","ACTION_TEXT","`",",","`","ENTITIES","`",",","`","SLOTS","`","and","`","ACTIVE_LOOP","`",".","Each","attribute","will","be","featurized","into","a","list","of","`","rasa.utils.features.Features","`","."]
code: def _extract_state_features(
      self,
      sub_state: SubState,
      precomputations: Optional[MessageContainerForCoreFeaturization],
      sparse: bool = False,
  ) -> Dict[Text, List[Features]]:
      # Remove entities from possible attributes
      attributes = set(
          attribute
          for attribute in sub_state.keys()
          if attribute != ENTITIES
      )
  
      if precomputations is not None:
          # Collect features for all those attributes
          attributes_to_features = precomputations.collect_features(
              sub_state, attributes=attributes
          )
          # if features for INTENT or ACTION_NAME exist,
          # they are always sparse sequence features;
          # transform them to sentence sparse features
          if attributes_to_features.get(INTENT):
              attributes_to_features[
                  INTENT
              ] = self._to_sparse_sentence_features(
                  attributes_to_features[INTENT]
              )
          if attributes_to_features.get(ACTION_NAME):
              attributes_to_features[
                  ACTION_NAME
              ] = self._to_sparse_sentence_features(
                  attributes_to_features[ACTION_NAME]
              )
  
          # Combine and sort the features:
          # Per attribute, combine features of same type and level into one Feature,
          # and (if there are any such features) store the results in a list where
          # - all the sparse features are listed first and a
          # - sequence feature is always listed before the sentence feature of the
          #   same type (sparse/not sparse).
          output = {
              attribute: Features.reduce(
                  features_list=features_list, expected_origins=None
              )
              for attribute, features_list in attributes_to_features.items()
              if len(features_list)
              > 0  # otherwise, following will fail
          }
      else:
          output = {}
  
      # Check that the name attribute has features
      name_attribute = self._get_name_attribute(attributes)
      if name_attribute and name_attribute not in output:
          # nlu pipeline didn't create features for user or action
          # this might happen, for example, when we have action_name in the state
          # but it did not get featurized because only character level
          # CountVectorsFeaturizer was included in the config.
          output[name_attribute] = self._create_features(
              sub_state, name_attribute, sparse
          )
      return output
  
imports: import logging
  import numpy
  import scipy.sparse
  from typing import List, Optional, Dict, Text, Set, Any
  from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
  from rasa.nlu.extractors.extractor import EntityTagSpec
  from rasa.nlu.utils import bilou_utils
  from rasa.nlu.utils.bilou_utils import BILOU_PREFIXES
  from rasa.shared.core.domain import SubState, State, Domain
  from rasa.shared.core.constants import PREVIOUS_ACTION, ACTIVE_LOOP, USER, SLOTS
  from rasa.shared.core.trackers import is_prev_action_listen_in_state
  from rasa.shared.nlu.constants import ENTITIES, FEATURE_TYPE_SENTENCE, ACTION_TEXT, ACTION_NAME, INTENT, NO_ENTITY_TAG, ENTITY_ATTRIBUTE_TYPE, ENTITY_TAGS, TEXT
  from rasa.shared.nlu.training_data.features import Features
  from rasa.utils.tensorflow import model_data_utils
label_desc: Use image node_id 8 for calling the SingleStateFeaturizer obj's underlying member method code with example usage: obj._extract_state_features(sub_state, precomputations, sparse) and returns: output