class_docstr: Helper for running environements
  
  Parameters
  ----------
  env: gym.Env or MultiAgentEnv
      a possibly multi agent environment
  num_repetations: int
      number of repetitions to play the environment (smoothes the output)
  max_step: int
      maximum number of steps to play the environemnet before breaking
class_docstr_tok: ["Helper","for","running","environements","Parameters","--","--","--","--","--","env",":","gym.Env","or","MultiAgentEnv","a","possibly","multi","agent","environment","num_repetations",":","int","number","of","repetitions","to","play","the","environment","(","smoothes","the","output",")","max_step",":","int","maximum","number","of","steps","to","play","the","environemnet","before","breaking"]
code: def _run_once(
      self, *single_agent: Agent, **agents: Agent
  ) -> tp.Dict[str, float]:
      san = "single_agent_name"
      if len(single_agent) == 1 and not agents:
          agents = {san: single_agent[0]}
      elif single_agent or not agents:
          raise ValueError(
              "Either provide 1 unnamed agent or several named agents"
          )
      for agent in agents.values():
          agent.reset()
      if isinstance(self.env, gym.Env):
          outcomes, done = {san: StepOutcome(self.env.reset())}, False
      else:
          outcomes, done = StepOutcome.from_multiagent_step(
              self.env.reset(), {}, {}, {}
          )
      reward_sum: tp.Dict[str, float] = defaultdict(float)
      step = 0
      while step < self.max_step and not done:
          actions: tp.Dict[str, tp.Any] = {}
          for name, outcome in outcomes.items():
              actions[name] = agents[name].act(*outcome)  # type: ignore
          if isinstance(self.env, gym.Env):
              outcomes = {
                  san: StepOutcome(*self.env.step(actions[san]))
              }
              done = outcomes[san].done
          else:
              outcomes, done = StepOutcome.from_multiagent_step(
                  *self.env.step(actions)
              )
          for name, outcome in outcomes.items():
              assert outcome.reward is not None
              reward_sum[name] += outcome.reward
          step += 1
      for name, outcome in outcomes.items():
          agents[name].act(*outcome)  # type: ignore
      return reward_sum
  
imports: import typing
  from collections import defaultdict
  import gym
label_desc: Use image node_id 3 for calling the EnvironmentRunner obj's underlying member method code with example usage: obj._run_once() and returns: reward_sum