class_docstr: The LevelManager is in charge of managing a level in the hierarchy of control. Each level can have one or more
  CompositeAgents and an environment to control. Its API is double-folded:
      1. Expose services of a LevelManager such as training the level, or stepping it (while behaving according to a
         LevelBehaviorScheme, e.g. as SelfPlay between two identical agents). These methods are implemented in the
         LevelManagerLogic class.
      2. Disguise as appearing as an environment to the upper level control so it will believe it is interacting with
         an environment. This includes stepping through what appears to be a regular environment, setting its phase
         or resetting it. These methods are implemented directly in LevelManager as it inherits from
         EnvironmentInterface.
docstr: Run a single step of following the behavioral scheme set for this environment.
  :param action: the action to apply to the agents held in this level, before beginning following
                 the scheme.
  :return: None
docstr_tok: ["Run","a","single","step","of","following","the","behavioral","scheme","set","for","this","environment",".",":","param","action",":","the","action","to","apply","to","the","agents","held","in","this","level",",","before","beginning","following","the","scheme",".",":","return",":","None"]
code: def step(
      self, action: Union[None, Dict[str, ActionType]]
  ) -> EnvResponse:
      """
      Run a single step of following the behavioral scheme set for this environment.
      :param action: the action to apply to the agents held in this level, before beginning following
                     the scheme.
      :return: None
      """
      # set the incoming directive for the sub-agent (goal / skill selection / etc.)
      if action is not None:
          for agent_name, agent in self.agents.items():
              agent.set_incoming_directive(action)
  
      if self.reset_required:
          self.reset_internal_state()
  
      # get last response or initial response from the environment
      env_response = copy.copy(self.environment.last_env_response)
  
      # step for several time steps
      accumulated_reward = 0
      acting_agent = self.acting_agent()
  
      for i in range(self.steps_limit.num_steps):
          # let the agent observe the result and decide if it wants to terminate the episode
          done = acting_agent.observe(env_response)
  
          if done:
              break
          else:
              # get action
              action_info = acting_agent.act()
  
              # imitation agents will return no action since they don't play during training
              if action_info:
                  # step environment
                  env_response = self.environment.step(
                      action_info.action
                  )
  
                  # accumulate rewards such that the master policy will see the total reward during the step phase
                  accumulated_reward += env_response.reward
  
      # update the env response that will be exposed to the parent agent
      env_response_for_upper_level = copy.copy(env_response)
      env_response_for_upper_level.reward = accumulated_reward
      self.last_env_response = env_response_for_upper_level
  
      # if the environment terminated the episode -> let the agent observe the last response
      # in HRL,excluding top level one, we will always enter the below if clause
      # (because should_reset_agent_state_after_time_limit_passes is set to True)
      if (
          env_response.game_over
          or self.should_reset_agent_state_after_time_limit_passes
      ):
          # this is the agent's only opportunity to observe this transition - he will not get another one
          acting_agent.observe(
              env_response
          )  # TODO: acting agent? maybe all of the agents in the layer?
          self.handle_episode_ended()
          self.reset_required = True
  
      return env_response_for_upper_level
  
imports: import copy
  from typing import Union, Dict
  from rl_coach.agents.composite_agent import CompositeAgent
  from rl_coach.agents.agent_interface import AgentInterface
  from rl_coach.core_types import EnvResponse, ActionInfo, RunPhase, ActionType, EnvironmentSteps, Transition
  from rl_coach.environments.environment import Environment
  from rl_coach.environments.environment_interface import EnvironmentInterface
  from rl_coach.saver import SaverCollection
  from rl_coach.spaces import ActionSpace, SpacesDefinition
label_desc: Use image node_id 14 for calling the LevelManager obj's underlying member method code with example usage: obj.step(action) and returns: env_response_for_upper_level