code: def _sliced_states_iterator(
      trackers: List[TrackerWithCachedStates],
      domain: Domain,
      max_history: Optional[int],
      tokenizer: Optional[Tokenizer],
  ) -> Generator[TrackerEventStateTuple, None, None]:
      """Creates an iterator over sliced states.
  
      Iterate over all given trackers and all sliced states within each tracker,
      where the slicing is based on `max_history`.
  
      Args:
          trackers: List of trackers.
          domain: Domain (used for tracker.past_states).
          max_history: Assumed `max_history` value for slicing.
          tokenizer: A tokenizer to tokenize the user messages.
  
      Yields:
          A (tracker, event, sliced_states) triplet.
      """
      for tracker in trackers:
          states = tracker.past_states(domain)
  
          idx = 0
          for event in tracker.events:
              if isinstance(event, ActionExecuted):
                  sliced_states = (
                      MaxHistoryTrackerFeaturizer.slice_state_history(
                          states[: idx + 1], max_history
                      )
                  )
                  if tokenizer:
                      _apply_tokenizer_to_states(
                          tokenizer, sliced_states
                      )
                  # TODO: deal with oov (different tokens can lead to identical features
                  # if some of those tokens are out of vocabulary for all featurizers)
                  yield TrackerEventStateTuple(
                      tracker, event, sliced_states
                  )
                  idx += 1
  
imports: from collections import defaultdict
  import logging
  import json
  from typing import DefaultDict, Dict, Generator, List, NamedTuple, Optional, Text, Tuple
  from rasa.core.featurizers.tracker_featurizers import MaxHistoryTrackerFeaturizer
  from rasa.shared.core.constants import ACTION_LISTEN_NAME, PREVIOUS_ACTION, ACTION_UNLIKELY_INTENT_NAME, USER
  from rasa.shared.core.domain import Domain, State
  from rasa.shared.core.events import ActionExecuted, Event
  from rasa.shared.core.generator import TrackerWithCachedStates
  from rasa.nlu.tokenizers.tokenizer import Tokenizer
  from rasa.shared.nlu.constants import TEXT
  from rasa.shared.nlu.training_data.message import Message
label_desc: Use image node_id 5 for calling a global function with example usage: _sliced_states_iterator(trackers, domain, max_history, tokenizer) without return types