code: def run_episode(env, agents):
      obs_n = env.reset()
      done = False
      total_reward = 0
      agents_reward = [0 for _ in range(env.n)]
      steps = 0
      while not done and steps < MAX_STEP_PER_EPISODE:
          steps += 1
          action_n = [
              agent.sample(obs) for agent, obs in zip(agents, obs_n)
          ]
          next_obs_n, reward_n, done_n, _ = env.step(action_n)
          done = all(done_n)
  
          # store experience
          for i, agent in enumerate(agents):
              agent.add_experience(
                  obs_n[i],
                  action_n[i],
                  reward_n[i],
                  next_obs_n[i],
                  done_n[i],
              )
  
          # compute reward of every agent
          obs_n = next_obs_n
          for i, reward in enumerate(reward_n):
              total_reward += reward
              agents_reward[i] += reward
  
          # show model effect without training
          if args.restore and args.show:
              continue
  
          # learn policy
          for i, agent in enumerate(agents):
              critic_loss = agent.learn(agents)
  
      return total_reward, agents_reward, steps
  
file_path: PARL/benchmark/torch/maddpg/train.py
imports: import os
  import time
  import argparse
  import numpy
  from simple_model import MAModel
  from simple_agent import MAAgent
  from parl.algorithms import MADDPG
  from parl.env.multiagent_env import MAenv
  from parl.utils import logger, summary
  from gym import spaces
label_desc: Use image node_id 2 for calling a global function with example usage: run_episode(env, agents) and returns: total_reward,  agents_reward,  steps