class_docstr: The policy that remembers examples from training stories for `max_history` turns.
  
  If it is needed to recall turns from training dialogues
  where some slots might not be set during prediction time,
  add relevant stories without such slots to training data.
  E.g. reminder stories.
  
  Since `slots` that are set some time in the past are
  preserved in all future feature vectors until they are set
  to None, this policy has a capability to recall the turns
  up to `max_history` from training stories during prediction
  even if additional slots were filled in the past
  for current dialogue.
class_docstr_tok: ["The","policy","that","remembers","examples","from","training","stories","for","`","max_history","`","turns",".","If","it","is","needed","to","recall","turns","from","training","dialogues","where","some","slots","might","not","be","set","during","prediction","time",",","add","relevant","stories","without","such","slots","to","training","data",".","E.g",".","reminder","stories",".","Since","`","slots","`","that","are","set","some","time","in","the","past","are","preserved","in","all","future","feature","vectors","until","they","are","set","to","None",",","this","policy","has","a","capability","to","recall","the","turns","up","to","`","max_history","`","from","training","stories","during","prediction","even","if","additional","slots","were","filled","in","the","past","for","current","dialogue","."]
docstr: Attempts to match memorized states to progressively shorter trackers.
  
  This method iteratively removes the oldest events up to the next action
  executed and checks if the truncated event sequence matches some memorized
  states, until a match has been found or until the even sequence has been
  exhausted.
  
  Args:
      old_states: List of states.
      tracker: The tracker.
      domain: The Domain.
      rule_only_data: Slots and loops which are specific to rules and hence
          should be ignored by this policy.
  
  Returns:
      The name of the action.
docstr_tok: ["Attempts","to","match","memorized","states","to","progressively","shorter","trackers",".","This","method","iteratively","removes","the","oldest","events","up","to","the","next","action","executed","and","checks","if","the","truncated","event","sequence","matches","some","memorized","states",",","until","a","match","has","been","found","or","until","the","even","sequence","has","been","exhausted",".","Args",":","old_states",":","List","of","states",".","tracker",":","The","tracker",".","domain",":","The","Domain",".","rule_only_data",":","Slots","and","loops","which","are","specific","to","rules","and","hence","should","be","ignored","by","this","policy",".","Returns",":","The","name","of","the","action","."]
code: def _recall_using_truncation(
      self,
      old_states: List[State],
      tracker: DialogueStateTracker,
      domain: Domain,
      rule_only_data: Optional[Dict[Text, Any]],
  ) -> Optional[Text]:
      """Attempts to match memorized states to progressively shorter trackers.
  
      This method iteratively removes the oldest events up to the next action
      executed and checks if the truncated event sequence matches some memorized
      states, until a match has been found or until the even sequence has been
      exhausted.
  
      Args:
          old_states: List of states.
          tracker: The tracker.
          domain: The Domain.
          rule_only_data: Slots and loops which are specific to rules and hence
              should be ignored by this policy.
  
      Returns:
          The name of the action.
      """
      logger.debug("Launch DeLorean...")
  
      # Truncate the tracker based on `max_history`
      truncated_tracker: Optional[
          DialogueStateTracker
      ] = _trim_tracker_by_max_history(
          tracker, self.config[POLICY_MAX_HISTORY]
      )
      truncated_tracker = (
          self._strip_leading_events_until_action_executed(
              truncated_tracker
          )
      )
      while truncated_tracker is not None:
          states = self._prediction_states(
              truncated_tracker, domain, rule_only_data=rule_only_data
          )
  
          if old_states != states:
              # check if we like new futures
              memorised = self._recall_states(states)
              if memorised is not None:
                  structlogger.debug(
                      "memoization.states_recall",
                      states=copy.deepcopy(states),
                  )
                  return memorised
              old_states = states
  
          # go back again
          truncated_tracker = (
              self._strip_leading_events_until_action_executed(
                  truncated_tracker, again=True
              )
          )
  
      # No match found
      structlogger.debug(
          "memoization.states_recall",
          old_states=copy.deepcopy(old_states),
      )
      return None
  
imports: from __future__ import annotations
  import copy
  import zlib
  import base64
  import json
  import logging
  import structlog
  from tqdm import tqdm
  from typing import Optional, Any, Dict, List, Text
  from pathlib import Path
  import rasa.utils.io
  import rasa.shared.utils.io
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.core.domain import State, Domain
  from rasa.shared.core.events import ActionExecuted
  from rasa.core.featurizers.tracker_featurizers import TrackerFeaturizer
  from rasa.core.featurizers.tracker_featurizers import MaxHistoryTrackerFeaturizer
  from rasa.core.featurizers.tracker_featurizers import FEATURIZER_FILE
  from rasa.shared.exceptions import FileIOException
  from rasa.core.policies.policy import PolicyPrediction, Policy, SupportedData
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.generator import TrackerWithCachedStates
  from rasa.shared.utils.io import is_logging_disabled
  from rasa.core.constants import MEMOIZATION_POLICY_PRIORITY, DEFAULT_MAX_HISTORY, POLICY_MAX_HISTORY, POLICY_PRIORITY
  from rasa.shared.core.constants import ACTION_LISTEN_NAME
label_desc: Use image node_id 2 for calling the AugmentedMemoizationPolicy obj's underlying member method code with example usage: obj._recall_using_truncation(old_states, tracker, domain, rule_only_data) and returns: None, memorised