class_docstr: Truncates the tracker history into `max_history` long sequences.
  
  Creates training data from trackers where actions 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","actions","are","the","output","prediction","labels",".","Tracker","state","sequences","which","represent","policy","input","are","truncated","to","not","excede","`","max_history","`","states","."]
docstr: Slices states from the trackers history.
  
  Args:
      states: The states
      slice_length: The slice length
  
  Returns:
      The sliced states.
docstr_tok: ["Slices","states","from","the","trackers","history",".","Args",":","states",":","The","states","slice_length",":","The","slice","length","Returns",":","The","sliced","states","."]
code: def slice_state_history(
      states: List[State], slice_length: Optional[int]
  ) -> List[State]:
      """Slices states from the trackers history.
  
      Args:
          states: The states
          slice_length: The slice length
  
      Returns:
          The sliced states.
      """
      if not slice_length:
          return states
  
      return states[-slice_length:]
  
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 2 for calling the MaxHistoryTrackerFeaturizer obj's underlying member method code with example usage: obj.slice_state_history(states, slice_length) and returns: states, states