code: def to_rnn_dict_space_environment(
      env: str, rnn_steps: int
  ) -> GymMazeEnv:
      """Instantiates a structured gym environment with the option to enable rnn support.
  
      :param env: The name of the gym environment to instantiate.
      :param rnn_steps: The number of previous time steps to consider for selecting the next action.
      :return: The structured gym environment.
      """
  
      # instantiate structured environment
      env = GymMazeEnv(env=env)
  
      # add observation stacking for rnn processing
      if rnn_steps > 1:
          stack_config = [
              {
                  "observation": "observation",
                  "keep_original": False,
                  "tag": None,
                  "delta": False,
                  "stack_steps": rnn_steps,
              }
          ]
          env = ObservationStackWrapper.wrap(
              env, stack_config=stack_config
          )
  
      return env
  
file_path: maze/tutorials/examples/a2c_gym_cartpole_default_nets.py
imports: from maze.core.agent.torch_actor_critic import TorchActorCritic
  from maze.core.agent.torch_policy import TorchPolicy
  from maze.core.rollout.rollout_generator import RolloutGenerator
  from maze.core.wrappers.maze_gym_env_wrapper import GymMazeEnv
  from maze.core.wrappers.observation_stack_wrapper import ObservationStackWrapper
  from maze.perception.builders import ConcatModelBuilder
  from maze.perception.models.template_model_composer import TemplateModelComposer
  from maze.train.parallelization.vector_env.sequential_vector_env import SequentialVectorEnv
  from maze.train.trainers.a2c.a2c_algorithm_config import A2CAlgorithmConfig
  from maze.train.trainers.a2c.a2c_trainer import A2C
  from maze.train.trainers.common.evaluators.rollout_evaluator import RolloutEvaluator
  from maze.utils.log_stats_utils import setup_logging
label_desc: Use image node_id 1 for calling a global function with example usage: to_rnn_dict_space_environment(env, rnn_steps) and returns: env