code: def test_encode_state__without_lookup(action_name: Text):
      """Tests that `encode_state` creates features for every attribute.
      In particular, that this is done even when there is no lookup table.
      If there is no action_listen in the  state, then no features should be created for
      the user sub-state.
      """
      f = SingleStateFeaturizer()
      f._default_feature_states[INTENT] = {"a": 0, "b": 1}
      f._default_feature_states[ACTION_NAME] = {
          "c": 0,
          "d": 1,
          "NOT_action_listen": 2,
          ACTION_LISTEN_NAME: 3,
      }
      f._default_feature_states[SLOTS] = {"e_0": 0, "f_0": 1, "g_0": 2}
      f._default_feature_states[ACTIVE_LOOP] = {
          "h": 0,
          "i": 1,
          "j": 2,
          "k": 3,
      }
  
      state = {
          USER: {INTENT: "a", TEXT: "blah blah blah"},
          PREVIOUS_ACTION: {ACTION_TEXT: "boom"},
          ACTIVE_LOOP: {"name": "i"},
          SLOTS: {"g": (1.0,)},
      }
      if action_name is not None:
          state[PREVIOUS_ACTION][ACTION_NAME] = action_name
  
      encoded = f.encode_state(state, precomputations=None)
  
      # this differs depending on whether action name is ACTION_LISTEN_NAME or "d"
      expected_attributes = [ACTIVE_LOOP, SLOTS]
      if action_name == ACTION_LISTEN_NAME:
          expected_attributes += [INTENT]
      if action_name is not None:
          expected_attributes += [ACTION_NAME]
      assert set(encoded.keys()) == set(expected_attributes)
  
      # the encoding of action_name of course depends on the sub-state
      if action_name is not None:
          if action_name == "NOT_action_listen":
              action_name_encoding = [0, 0, 1, 0]
          else:
              action_name_encoding = [0, 0, 0, 1]
          assert sparse_equals_dense(
              encoded[ACTION_NAME][0].features,
              np.array([action_name_encoding]),
          )
  
      # the intent / user substate is only featurized if action_listen is
      # with_action_listen
      if action_name == ACTION_LISTEN_NAME:
          assert sparse_equals_dense(
              encoded[INTENT][0].features, np.array([[1, 0]])
          )
  
      # this is always the same
      assert sparse_equals_dense(
          encoded[ACTIVE_LOOP][0].features, np.array([[0, 1, 0, 0]])
      )
      assert sparse_equals_dense(
          encoded[SLOTS][0].features, np.array([[0, 0, 1]])
      )
  
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 7 for calling a global function with example usage: test_encode_state__without_lookup(action_name) without return types