class_docstr: General abstract class for rollout runners.
  
  Offers general structure, plus a couple of helper methods for env instantiation and performing the rollout.
  
  :param n_episodes: Count of episodes to run. If explicit seeds are given the actual number of episodes is given by
                     min(n_episodes, n_seeds).
  :param max_episode_steps: Count of steps to run in each episode (if environment returns done, the episode
                            will be finished earlier though).
  :param deterministic: Deterministic or stochastic action sampling.
  :param record_trajectory: Whether to record trajectory data.
  :param record_event_logs: Whether to record event logs.
class_docstr_tok: ["General","abstract","class","for","rollout","runners",".","Offers","general","structure",",","plus","a","couple","of","helper","methods","for","env","instantiation","and","performing","the","rollout",".",":","param","n_episodes",":","Count","of","episodes","to","run",".","If","explicit","seeds","are","given","the","actual","number","of","episodes","is","given","by","min","(","n_episodes",",","n_seeds",")",".",":","param","max_episode_steps",":","Count","of","steps","to","run","in","each","episode","(","if","environment","returns","done",",","the","episode","will","be","finished","earlier","though",")",".",":","param","deterministic",":","Deterministic","or","stochastic","action","sampling",".",":","param","record_trajectory",":","Whether","to","record","trajectory","data",".",":","param","record_event_logs",":","Whether","to","record","event","logs","."]
docstr: Build the environment (including wrappers) and agent according to given configuration.
  
  :param env_config: Environment config.
  :param wrappers_config: Wrapper config.
  :param max_episode_steps: Max number of steps per episode to limit the env for.
  :param agent_config: Policies config.
  :param input_dir: Directory to load the model from.
  
  :return: Tuple of (instantiated environment, instantiated agent).
docstr_tok: ["Build","the","environment","(","including","wrappers",")","and","agent","according","to","given","configuration",".",":","param","env_config",":","Environment","config",".",":","param","wrappers_config",":","Wrapper","config",".",":","param","max_episode_steps",":","Max","number","of","steps","per","episode","to","limit","the","env","for",".",":","param","agent_config",":","Policies","config",".",":","param","input_dir",":","Directory","to","load","the","model","from",".",":","return",":","Tuple","of","(","instantiated","environment",",","instantiated","agent",")","."]
code: def init_env_and_agent(
      env_config: DictConfig,
      wrappers_config: CollectionOfConfigType,
      max_episode_steps: int,
      agent_config: DictConfig,
      input_dir: str,
  ) -> (MazeEnv, Policy):
      """Build the environment (including wrappers) and agent according to given configuration.
  
      :param env_config: Environment config.
      :param wrappers_config: Wrapper config.
      :param max_episode_steps: Max number of steps per episode to limit the env for.
      :param agent_config: Policies config.
      :param input_dir: Directory to load the model from.
  
      :return: Tuple of (instantiated environment, instantiated agent).
      """
  
      with SwitchWorkingDirectoryToInput(input_dir):
          agent = Factory(base_type=Policy).instantiate(agent_config)
  
          env = EnvFactory(env_config, wrappers_config)()
          if not isinstance(env, TimeLimitWrapper):
              env = TimeLimitWrapper.wrap(env)
          env.set_max_episode_steps(max_episode_steps)
  
      return env, agent
  
imports: import time
  from abc import ABC, abstractmethod
  from typing import Callable, Optional, List, Any
  import numpy
  from omegaconf import DictConfig
  from maze.core.agent.policy import Policy
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.observation_conversion import ObservationType
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.utils.config_utils import EnvFactory, SwitchWorkingDirectoryToInput
  from maze.core.utils.factory import Factory, ConfigType, CollectionOfConfigType
  from maze.core.utils.seeding import MazeSeeding
  from maze.core.wrappers.time_limit_wrapper import TimeLimitWrapper
  from maze.core.wrappers.trajectory_recording_wrapper import TrajectoryRecordingWrapper
  from maze.runner import Runner
  from maze.utils.bcolors import BColors
label_desc: Use image node_id 5 for calling the RolloutRunner obj's underlying member method code with example usage: obj.init_env_and_agent(env_config, wrappers_config, max_episode_steps, agent_config, input_dir) and returns: env,  agent