code: def test_counts_episodes_that_skip_and_error_in_reset():
      """Test that episodes where step-skipping during reset is performed and then
      an error is raised (still as part of reset) are still counted as valid episodes.
      """
      env = build_dummy_maze_env()
      env = _StepSkippingAndErrorInResetWrapper.wrap(env)
      env = LogStatsWrapper.wrap(env)
  
      # Reset the env: This should raise an exception
      with pytest.raises(RuntimeError):
          env.reset()
  
      # Events should be collected for 1 steps in total (the one step skipped in the reset)
      assert len(env.episode_event_log.step_event_logs) == 1
  
      env.write_epoch_stats()
  
      # The original_reward stats should be recorded for the one skipped step
      assert (
          env.get_stats_value(
              RewardEvents.reward_original,
              LogStatsLevel.EPOCH,
              name="total_step_count",
          )
          == 1
      )
  
      # Both episode_count and total_episode_count stats for the reward_original event reflect this
      assert (
          env.get_stats_value(
              RewardEvents.reward_original,
              LogStatsLevel.EPOCH,
              name="episode_count",
          )
          == 1
      )
      assert (
          env.get_stats_value(
              RewardEvents.reward_original,
              LogStatsLevel.EPOCH,
              name="total_episode_count",
          )
          == 1
      )
  
      # No ordinary "reward" event is counted, as no step was done from the outside
      with pytest.raises(KeyError):
          env.get_stats_value(
              BaseEnvEvents.reward,
              LogStatsLevel.EPOCH,
              name="total_step_count",
          )
  
imports: import pytest
  from maze.core.env.base_env_events import BaseEnvEvents
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.observation_conversion import ObservationType
  from maze.core.log_events.monitoring_events import RewardEvents
  from maze.core.log_stats.log_stats import LogStatsLevel
  from maze.core.wrappers.log_stats_wrapper import LogStatsWrapper
  from maze.core.wrappers.wrapper import Wrapper
  from maze.test.shared_test_utils.dummy_wrappers.step_skip_in_reset_wrapper import StepSkipInResetWrapper
  from maze.test.shared_test_utils.dummy_wrappers.step_skip_in_step_wrapper import StepSkipInStepWrapper
  from maze.test.shared_test_utils.helper_functions import build_dummy_maze_env, build_dummy_structured_env
label_desc: Use image node_id 7 for calling a global function with example usage: test_counts_episodes_that_skip_and_error_in_reset() without return types