code: def test_records_once_per_maze_step_in_multistep_envs():
      """In multi-step envs, trajectory should be recorded once per Maze env step (not in each sub-step)."""
  
      observation_conversion = ObservationConversion()
      maze_env = DummyEnvironment(
          core_env=DummyCoreEnvironment(observation_conversion.space()),
          action_conversion=[DictActionConversion()],
          observation_conversion=[observation_conversion],
      )
      env = DummyStructuredEnvironment(maze_env)
  
      class TestWriter(TrajectoryWriter):
          """Mock writer checking the recorded data"""
  
          def __init__(self):
              self.episode_count = 0
              self.step_count = 0
  
          def write(self, episode_record: StateTrajectoryRecord):
              """Count steps and episodes"""
              self.episode_count += 1
              self.step_count += len(episode_record.step_records)
  
      writer = TestWriter()
      TrajectoryWriterRegistry.writers = (
          []
      )  # Ensure there is no other writer
      TrajectoryWriterRegistry.register_writer(writer)
  
      env = TrajectoryRecordingWrapper.wrap(env)
      for _ in range(5):
          env.reset()
          for i in range(10):
              env.step(env.action_space.sample())
  
      # final env reset required
      env.reset()
      env.close()
  
      # The step count should correspond to core env steps (disregarding sub-steps),
      # I.e., 5 flat steps per 10 structured + 1 final state for each episode
      assert writer.step_count == 5 * (5 + 1)
      assert writer.episode_count == 5
  
imports: from abc import ABC
  from copy import deepcopy
  from typing import Any, Dict, List, Type
  import numpy
  from maze.core.env.base_env_events import BaseEnvEvents
  from maze.core.events.pubsub import Pubsub
  from maze.core.rendering.renderer import Renderer
  from maze.core.trajectory_recording.records.trajectory_record import StateTrajectoryRecord
  from maze.core.trajectory_recording.writers.trajectory_writer import TrajectoryWriter
  from maze.core.trajectory_recording.writers.trajectory_writer_registry import TrajectoryWriterRegistry
  from maze.core.wrappers.trajectory_recording_wrapper import TrajectoryRecordingWrapper
  from maze.test.shared_test_utils.dummy_wrappers.step_skip_in_step_wrapper import StepSkipInStepWrapper
  from maze.test.shared_test_utils.dummy_wrappers.step_skip_in_reset_wrapper import StepSkipInResetWrapper
  from maze.test.shared_test_utils.dummy_env.agents.dummy_policy import DummyGreedyPolicy
  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_renderer import DummyRenderer
  from maze.test.shared_test_utils.dummy_env.dummy_struct_env import DummyStructuredEnvironment
  from maze.test.shared_test_utils.dummy_env.reward.base import RewardAggregator
  from maze.test.shared_test_utils.dummy_env.space_interfaces.action_conversion.dict import DictActionConversion
  from maze.test.shared_test_utils.dummy_env.space_interfaces.observation_conversion.dict import ObservationConversion
  from maze.test.shared_test_utils.helper_functions import build_dummy_maze_env
label_desc: Use image node_id 2 for calling a global function with example usage: test_records_once_per_maze_step_in_multistep_envs() without return types