class_docstr: A statistics logging wrapper for :class:`~maze.core.env.base_env.BaseEnv`.
  
  :param env: The environment to wrap.
class_docstr_tok: ["A","statistics","logging","wrapper","for",":","class",":","`","~maze.core.env.base_env.BaseEnv","`",".",":","param","env",":","The","environment","to","wrap","."]
docstr: Checks if stats are ready to record based on env time (for structured envs, we wait till the end
  of the whole structured step) and if so, does the recording.
code: def _record_stats_if_ready(self) -> None:
      """Checks if stats are ready to record based on env time (for structured envs, we wait till the end
      of the whole structured step) and if so, does the recording.
      """
      if self.last_env_time is None:
          self.last_env_time = self.env.initial_env_time
  
      # Recording of event logs and stats happens:
      #  - for TimeEnvs:   Only if the env time changed, so that we record once per time step
      #  - for other envs: Every step
      if (
          isinstance(self.env, TimeEnvMixin)
          and self.env.get_env_time() == self.last_env_time
      ):
          return
  
      step_event_log = StepEventLog(
          env_time=self.last_env_time, events=self.reward_events
      )
      self.reward_events = EventCollection()
  
      if isinstance(self.env, EventEnvMixin):
          step_event_log.extend(self.env.get_step_events())
  
      # add all recorded events to the step aggregator
      for event_record in step_event_log.events:
          self.step_stats.add_event(event_record)
  
      # trigger logging statistics calculation
      self.step_stats.reduce()
  
      # lazy init new episode event log if needed
      if not self.episode_event_log:
          episode_id = (
              self.env.get_episode_id()
              if isinstance(self.env, RecordableEnvMixin)
              else str(uuid.uuid4())
          )
          self.episode_event_log = EpisodeEventLog(episode_id)
  
      # log raw events and init new step log
      self.episode_event_log.step_event_logs.append(step_event_log)
  
      # update the time of last stats recording
      self.last_env_time = (
          self.env.get_env_time()
          if isinstance(self.env, TimeEnvMixin)
          else self.last_env_time + 1
      )
  
imports: import uuid
  from typing import Callable, Optional, Iterable
  from typing import TypeVar, Union, Any, Tuple, Dict
  from maze.core.annotations import override
  from maze.core.env.base_env import BaseEnv
  from maze.core.env.base_env_events import BaseEnvEvents
  from maze.core.env.environment_context import EnvironmentContext
  from maze.core.env.event_env_mixin import EventEnvMixin
  from maze.core.env.maze_action import MazeActionType
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.maze_state import MazeStateType
  from maze.core.env.recordable_env_mixin import RecordableEnvMixin
  from maze.core.env.simulated_env_mixin import SimulatedEnvMixin
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.env.time_env_mixin import TimeEnvMixin
  from maze.core.events.event_collection import EventCollection
  from maze.core.events.event_record import EventRecord
  from maze.core.log_events.episode_event_log import EpisodeEventLog
  from maze.core.log_events.log_events_writer_registry import LogEventsWriterRegistry
  from maze.core.log_events.step_event_log import StepEventLog
  from maze.core.log_stats.log_stats import LogStatsAggregator, LogStatsLevel, get_stats_logger, LogStatsValue
  from maze.core.log_stats.log_stats_env import LogStatsEnv
  from maze.core.rendering.events_stats_renderer import EventStatsRenderer
  from maze.core.wrappers.wrapper import Wrapper
label_desc: Use image node_id 4 for calling the LogStatsWrapper obj's underlying member method code with example usage: obj._record_stats_if_ready() without return types