class_docstr: Truncates the tracker history into `max_history` long sequences.
  
  Creates training data from trackers where intents are the output prediction
  labels. Tracker state sequences which represent policy input are truncated
  to not excede `max_history` states.
class_docstr_tok: ["Truncates","the","tracker","history","into","`","max_history","`","long","sequences",".","Creates","training","data","from","trackers","where","intents","are","the","output","prediction","labels",".","Tracker","state","sequences","which","represent","policy","input","are","truncated","to","not","excede","`","max_history","`","states","."]
docstr: Removes the last tracker state if the previous action is `action_listen`.
  
  States with the previous action equal to `action_listen` correspond to states
  with a new user intent. This information is what `UnexpecTEDIntentPolicy` is
  trying to predict so it needs to be removed before obtaining a prediction.
  
  Args:
      trackers_as_states: Trackers converted to states
  
  Returns:
      Filtered states with last `action_listen` removed.
docstr_tok: ["Removes","the","last","tracker","state","if","the","previous","action","is","`","action_listen","`",".","States","with","the","previous","action","equal","to","`","action_listen","`","correspond","to","states","with","a","new","user","intent",".","This","information","is","what","`","UnexpecTEDIntentPolicy","`","is","trying","to","predict","so","it","needs","to","be","removed","before","obtaining","a","prediction",".","Args",":","trackers_as_states",":","Trackers","converted","to","states","Returns",":","Filtered","states","with","last","`","action_listen","`","removed","."]
code: def _cleanup_last_user_state_with_action_listen(
      trackers_as_states: List[List[State]],
  ) -> List[List[State]]:
      """Removes the last tracker state if the previous action is `action_listen`.
  
      States with the previous action equal to `action_listen` correspond to states
      with a new user intent. This information is what `UnexpecTEDIntentPolicy` is
      trying to predict so it needs to be removed before obtaining a prediction.
  
      Args:
          trackers_as_states: Trackers converted to states
  
      Returns:
          Filtered states with last `action_listen` removed.
      """
      for states in trackers_as_states:
          if not states:
              continue
          last_state = states[-1]
          if rasa.shared.core.trackers.is_prev_action_listen_in_state(
              last_state
          ):
              del states[-1]
  
      return trackers_as_states
  
imports: from __future__ import annotations
  from pathlib import Path
  from collections import defaultdict
  from abc import abstractmethod
  import jsonpickle
  import logging
  from tqdm import tqdm
  from typing import Tuple, List, Optional, Dict, Text, Union, Any, Iterator, Set, DefaultDict, cast
  import numpy
  from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer
  from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
  from rasa.core.exceptions import InvalidTrackerFeaturizerUsageError
  import rasa.shared.core.trackers
  import rasa.shared.utils.io
  from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ACTION_NAME
  from rasa.shared.nlu.training_data.features import Features
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.domain import State, Domain
  from rasa.shared.core.events import Event, ActionExecuted, UserUttered
  from rasa.shared.core.constants import USER, ACTION_UNLIKELY_INTENT_NAME, PREVIOUS_ACTION
  from rasa.shared.exceptions import RasaException
  from rasa.utils.tensorflow.constants import LABEL_PAD_ID
  from rasa.utils.tensorflow.model_data import ragged_array_to_ndarray
label_desc: Use image node_id 5 for calling the IntentMaxHistoryTrackerFeaturizer obj's underlying member method code with example usage: obj._cleanup_last_user_state_with_action_listen(trackers_as_states) and returns: trackers_as_states