code: def test_data_load_with_stateful_wrapper():
      dataset = InMemoryDataset(
          n_workers=1,
          conversion_env_factory=lambda: _MockObservationStackWrapper.wrap(
              _env_factory()
          ),
          input_data=None,
          trajectory_processor=IdentityTrajectoryProcessor(),
          deserialize_in_main_thread=False,
      )
      trajectories = dataset._trajectory_processor.process(
          _mock_state_trajectory_record(4), dataset._conversion_env
      )
      assert len(trajectories)
      step_records = trajectories[0]
  
      expected_observations = [
          {0: {"observation": [None, 0]}},
          {0: {"observation": [0, 2]}},
          {0: {"observation": [2, 4]}},
      ]
      assert [
          rec.observations_dict for rec in step_records
      ] == expected_observations
  
imports: import pickle
  from typing import Any, Dict, Union, Tuple, List, Optional
  import gym
  import numpy
  from maze.core.env.maze_action import MazeActionType
  from maze.core.env.maze_state import MazeStateType
  from maze.core.env.structured_env import ActorID
  from maze.core.env.structured_env_spaces_mixin import StructuredEnvSpacesMixin
  from maze.core.log_events.step_event_log import StepEventLog
  from maze.core.trajectory_recording.datasets.trajectory_processor import IdentityTrajectoryProcessor
  from maze.core.trajectory_recording.records.spaces_record import SpacesRecord
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
  from maze.core.trajectory_recording.records.state_record import StateRecord
  from maze.core.trajectory_recording.records.trajectory_record import StateTrajectoryRecord, SpacesTrajectoryRecord
  from maze.core.wrappers.maze_gym_env_wrapper import make_gym_maze_env
  from maze.core.wrappers.wrapper import ObservationWrapper
  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.space_interfaces.action_conversion.double import DoubleActionConversion
  from maze.test.shared_test_utils.dummy_env.space_interfaces.observation_conversion.double import DoubleObservationConversion
  from maze.test.shared_test_utils.run_maze_utils import run_maze_job
  from maze.core.trajectory_recording.datasets.in_memory_dataset import InMemoryDataset
label_desc: Use image node_id 6 for calling a global function with example usage: test_data_load_with_stateful_wrapper() without return types