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","`","."]
docstr: Encode the given state.
  
  Args:
      state: The state to encode
      precomputations: Contains precomputed features and attributes.
  
  Returns:
      A dictionary of state_type to list of features.
docstr_tok: ["Encode","the","given","state",".","Args",":","state",":","The","state","to","encode","precomputations",":","Contains","precomputed","features","and","attributes",".","Returns",":","A","dictionary","of","state_type","to","list","of","features","."]
code: def encode_state(
      self,
      state: State,
      precomputations: Optional[MessageContainerForCoreFeaturization],
  ) -> Dict[Text, List[Features]]:
      """Encode the given state.
  
      Args:
          state: The state to encode
          precomputations: Contains precomputed features and attributes.
  
      Returns:
          A dictionary of state_type to list of features.
      """
      state_features = {}
      for state_type, sub_state in state.items():
          if state_type == PREVIOUS_ACTION:
              state_features.update(
                  self._extract_state_features(
                      sub_state,
                      precomputations=precomputations,
                      sparse=True,
                  )
              )
          # featurize user only if it is "real" user input,
          # i.e. input from a turn after action_listen
          if state_type == USER and is_prev_action_listen_in_state(
              state
          ):
              state_features.update(
                  self._extract_state_features(
                      sub_state,
                      precomputations=precomputations,
                      sparse=True,
                  )
              )
              if sub_state.get(ENTITIES):
                  state_features[ENTITIES] = self._create_features(
                      sub_state, ENTITIES, sparse=True
                  )
  
          if state_type in {SLOTS, ACTIVE_LOOP}:
              state_features[state_type] = self._create_features(
                  sub_state, state_type, sparse=True
              )
  
      return state_features
  
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 9 for calling the SingleStateFeaturizer obj's underlying member method code with example usage: obj.encode_state(state, precomputations) and returns: state_features