class_docstr: Test suite for AugmentedMemoizationPolicy.
class_docstr_tok: ["Test","suite","for","AugmentedMemoizationPolicy","."]
docstr: Tests that the last user utterance is preserved in action states
  even when the utterance occurs prior to `max_history` actions in the
  past.
docstr_tok: ["Tests","that","the","last","user","utterance","is","preserved","in","action","states","even","when","the","utterance","occurs","prior","to","`","max_history","`","actions","in","the","past","."]
code: def test_augmented_prediction_across_max_history_actions(
      self,
      max_history: Optional[int],
      model_storage: ModelStorage,
      resource: Resource,
      execution_context: ExecutionContext,
  ):
      """Tests that the last user utterance is preserved in action states
      even when the utterance occurs prior to `max_history` actions in the
      past.
      """
      policy = self.create_policy(
          featurizer=MaxHistoryTrackerFeaturizer(
              max_history=max_history
          ),
          model_storage=model_storage,
          resource=resource,
          execution_context=execution_context,
          config={POLICY_MAX_HISTORY: max_history},
      )
  
      GREET_INTENT_NAME = "greet"
      UTTER_GREET_ACTION = "utter_greet"
      UTTER_ACTION_1 = "utter_1"
      UTTER_ACTION_2 = "utter_2"
      UTTER_ACTION_3 = "utter_3"
      UTTER_ACTION_4 = "utter_4"
      UTTER_ACTION_5 = "utter_5"
      UTTER_BYE_ACTION = "utter_goodbye"
      domain = Domain.from_yaml(
          f"""
                  intents:
                  - {GREET_INTENT_NAME}
                  actions:
                  - {UTTER_GREET_ACTION}
                  - {UTTER_ACTION_1}
                  - {UTTER_ACTION_2}
                  - {UTTER_ACTION_3}
                  - {UTTER_ACTION_4}
                  - {UTTER_ACTION_5}
                  - {UTTER_BYE_ACTION}
                  """
      )
      training_story = TrackerWithCachedStates.from_events(
          "training story",
          [
              ActionExecuted(ACTION_LISTEN_NAME),
              UserUttered(intent={"name": GREET_INTENT_NAME}),
              ActionExecuted(UTTER_ACTION_1),
              ActionExecuted(UTTER_ACTION_2),
              ActionExecuted(UTTER_ACTION_3),
              ActionExecuted(UTTER_ACTION_4),
              ActionExecuted(UTTER_ACTION_5),
              ActionExecuted(UTTER_BYE_ACTION),
              ActionExecuted(ACTION_LISTEN_NAME),
          ],
          domain=domain,
          slots=domain.slots,
      )
      test_story = TrackerWithCachedStates.from_events(
          "test story",
          [
              ActionExecuted(ACTION_LISTEN_NAME),
              UserUttered(intent={"name": GREET_INTENT_NAME}),
              ActionExecuted(UTTER_ACTION_1),
              ActionExecuted(UTTER_ACTION_2),
              ActionExecuted(UTTER_ACTION_3),
              ActionExecuted(UTTER_ACTION_4),
              ActionExecuted(UTTER_ACTION_5),
              # ActionExecuted(UTTER_BYE_ACTION),
          ],
          domain=domain,
          slots=domain.slots,
      )
      policy.train([training_story], domain)
      prediction = policy.predict_action_probabilities(
          test_story, domain
      )
      assert (
          domain.action_names_or_texts[
              prediction.probabilities.index(
                  max(prediction.probabilities)
              )
          ]
          == UTTER_BYE_ACTION
      )
  
imports: import uuid
  from pathlib import Path
  from typing import Type, List, Text, Optional, Dict, Any
  import dataclasses
  import numpy
  import pytest
  from _pytest.tmpdir import TempPathFactory
  from rasa.engine.graph import ExecutionContext, GraphSchema
  from rasa.engine.storage.local_model_storage import LocalModelStorage
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.constants import DEFAULT_SENDER_ID
  from rasa.shared.core.constants import ACTION_LISTEN_NAME, ACTION_UNLIKELY_INTENT_NAME
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.events import ActionExecuted, Event, UserUttered, EntitiesAdded, SlotSet
  from rasa.core import training
  from rasa.core.constants import POLICY_MAX_HISTORY
  from rasa.core.featurizers.tracker_featurizers import TrackerFeaturizer, MaxHistoryTrackerFeaturizer, IntentMaxHistoryTrackerFeaturizer
  from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer, IntentTokenizerSingleStateFeaturizer
  from rasa.core.policies.policy import SupportedData, InvalidPolicyConfig, Policy
  from rasa.core.policies.rule_policy import RulePolicy
  from rasa.core.policies.ted_policy import TEDPolicy
  from rasa.core.policies.memoization import AugmentedMemoizationPolicy, MemoizationPolicy
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.generator import TrackerWithCachedStates
  from tests.dialogues import TEST_DEFAULT_DIALOGUE
  from tests.core.utilities import get_tracker, tracker_from_dialogue
label_desc: Use image node_id 3 for calling the TestAugmentedMemoizationPolicy obj's underlying member method code with example usage: obj.test_augmented_prediction_across_max_history_actions(max_history, model_storage, resource, execution_context) without return types