code: def test_stack_reset_on_trajectory_load():
      env = build_dummy_maze_environment()
  
      # wrapper config
      stack_config = [
          {
              "observation": "observation_0",
              "keep_original": False,
              "tag": "stacked",
              "delta": False,
              "stack_steps": 2,
          }
      ]
      env = ObservationStackWrapper.wrap(env, stack_config=stack_config)
  
      # == Check that stepping affects the stack as expected ==
  
      # Stack should be empty at the beginning
      assert len(env._observation_stack["observation_0"]) == 0
  
      # Env reset puts the first observation on stack
      env.reset()
      assert len(env._observation_stack["observation_0"]) == 1
  
      # Env step puts second observation on stack
      env.step(env.action_space.sample())
      assert len(env._observation_stack["observation_0"]) == 2
  
      # == Check loading trajectory data ==
  
      maze_state = env.get_maze_state()
      maze_action = env.action_conversion.space_to_maze(
          env.action_space.sample(), maze_state
      )
  
      # Loading the first step in the episode should reduce the stack back to 1 (like after a reset)
      env.get_observation_and_action_dicts(
          deepcopy(maze_state),
          deepcopy(maze_action),
          first_step_in_episode=True,
      )
      assert len(env._observation_stack["observation_0"]) == 1
  
      # Loading the next step should put second observation on stack
      env.get_observation_and_action_dicts(
          deepcopy(maze_state),
          deepcopy(maze_action),
          first_step_in_episode=False,
      )
      assert len(env._observation_stack["observation_0"]) == 2
  
      # Loading first step of another episode should reduce the stack back to 1
      env.get_observation_and_action_dicts(
          deepcopy(maze_state),
          deepcopy(maze_action),
          first_step_in_episode=True,
      )
      assert len(env._observation_stack["observation_0"]) == 1
  
file_path: maze/maze/test/core/wrappers/test_observation_stack_wrapper.py
imports: from copy import deepcopy
  import maze.test.core.wrappers
  from maze.core.wrappers.observation_stack_wrapper import ObservationStackWrapper
  from maze.test.shared_test_utils.config_testing_utils import load_env_config
  from maze.test.shared_test_utils.dummy_env.dummy_core_env import DummyCoreEnvironment
  from maze.test.shared_test_utils.dummy_env.dummy_maze_env import DummyEnvironment
  from maze.test.shared_test_utils.dummy_env.dummy_struct_env import DummyStructuredEnvironment
  from maze.test.shared_test_utils.dummy_env.space_interfaces.action_conversion.dict_discrete import DictDiscreteActionConversion
  from maze.test.shared_test_utils.dummy_env.space_interfaces.observation_conversion.dict import ObservationConversion
label_desc: Use image node_id 7 for calling a global function with example usage: test_stack_reset_on_trajectory_load() without return types