code: def test_encode_state__with_lookup__creates_features_for_intent_and_action_name(
      with_action_listen: bool,
  ):
      """Tests that features for intent and action name are created if needed.
      Especially tests that this is the case even though no features are present in the
      given lookup table for this intent and action_name.
      However, if no `action_listen` is in the given sub-state, then the user sub-state
      should not be featurized (hence, no features for intent) should be created.
      """
  
      f = SingleStateFeaturizer()
      f._default_feature_states[INTENT] = {"a": 0, "b": 1}
      f._default_feature_states[ACTION_NAME] = {
          "c": 0,
          "d": 1,
          ACTION_LISTEN_NAME: 2,
      }
  
      # create state
      action_name = ACTION_LISTEN_NAME if with_action_listen else "c"
      state = {
          USER: {INTENT: "e"},
          PREVIOUS_ACTION: {ACTION_NAME: action_name},
      }
  
      # create a lookup table with all relevant entries **but no Features**
      precomputations = MessageContainerForCoreFeaturization()
      precomputations.add(Message(data={INTENT: state[USER][INTENT]}))
      precomputations.add(
          Message(
              data={ACTION_NAME: state[PREVIOUS_ACTION][ACTION_NAME]}
          )
      )
  
      # encode!
      encoded = f.encode_state(state, precomputations=precomputations)
  
      if with_action_listen:
          assert set(encoded.keys()) == set([INTENT, ACTION_NAME])
          assert (
              encoded[INTENT][0].features
              != scipy.sparse.coo_matrix([[0, 0]])
          ).nnz == 0
      else:
          assert set(encoded.keys()) == set([ACTION_NAME])
  
imports: from typing import Text
  import numpy
  import re
  import scipy.sparse
  import pytest
  from rasa.nlu.tokenizers.tokenizer import Token
  from rasa.nlu.constants import TOKENS_NAMES
  from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
  from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer
  from rasa.shared.nlu.training_data.features import Features
  from rasa.shared.nlu.training_data.message import Message
  from rasa.shared.nlu.constants import ACTION_TEXT, ACTION_NAME, ENTITIES, TEXT, INTENT, FEATURE_TYPE_SEQUENCE, FEATURE_TYPE_SENTENCE, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_VALUE, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_TAGS
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.slots import TextSlot
  from rasa.shared.core.constants import ACTION_LISTEN_NAME, ACTIVE_LOOP, PREVIOUS_ACTION, SLOTS, ENTITY_LABEL_SEPARATOR, USER
  from rasa.utils.tensorflow.constants import SENTENCE, SEQUENCE
label_desc: Use image node_id 9 for calling a global function with example usage: test_encode_state__with_lookup__creates_features_for_intent_and_action_name(with_action_listen) without return types