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: Truncates the tracker to begin at the next `ActionExecuted` event.
  
  Args:
      tracker: The tracker to truncate.
      again: When true, truncate tracker at the second action.
          Otherwise truncate to the first action.
  
  Returns:
      The truncated tracker if there were actions present.
      If none are found, returns `None`.
docstr_tok: ["Truncates","the","tracker","to","begin","at","the","next","`","ActionExecuted","`","event",".","Args",":","tracker",":","The","tracker","to","truncate",".","again",":","When","true",",","truncate","tracker","at","the","second","action",".","Otherwise","truncate","to","the","first","action",".","Returns",":","The","truncated","tracker","if","there","were","actions","present",".","If","none","are","found",",","returns","`","None","`","."]
code: def _strip_leading_events_until_action_executed(
      tracker: DialogueStateTracker, again: bool = False
  ) -> Optional[DialogueStateTracker]:
      """Truncates the tracker to begin at the next `ActionExecuted` event.
  
      Args:
          tracker: The tracker to truncate.
          again: When true, truncate tracker at the second action.
              Otherwise truncate to the first action.
  
      Returns:
          The truncated tracker if there were actions present.
          If none are found, returns `None`.
      """
      idx_of_first_action = None
      idx_of_second_action = None
  
      applied_events = tracker.applied_events()
  
      # we need to find second executed action
      for e_i, event in enumerate(applied_events):
          if isinstance(event, ActionExecuted):
              if idx_of_first_action is None:
                  idx_of_first_action = e_i
              else:
                  idx_of_second_action = e_i
                  break
  
      # use first action, if we went first time and second action, if we went again
      idx_to_use = (
          idx_of_second_action if again else idx_of_first_action
      )
      if idx_to_use is None:
          return None
  
      # make second ActionExecuted the first one
      events = applied_events[idx_to_use:]
      if not events:
          return None
  
      truncated_tracker = tracker.init_copy()
      for e in events:
          truncated_tracker.update(e)
  
      return truncated_tracker
  
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 1 for calling the AugmentedMemoizationPolicy obj's underlying member method code with example usage: obj._strip_leading_events_until_action_executed(tracker, again) and returns: truncated_tracker, None, None