code: def main():
      config = deepcopy(QMixConfig)
      env = StarCraft2Env(
          map_name=config["scenario"], difficulty=config["difficulty"]
      )
      env = SC2EnvWrapper(env)
      config["episode_limit"] = env.episode_limit
      config["obs_shape"] = env.obs_shape
      config["state_shape"] = env.state_shape
      config["n_agents"] = env.n_agents
      config["n_actions"] = env.n_actions
  
      rpm = EpisodeReplayBuffer(config["replay_buffer_size"])
      agent_model = RNNModel(
          config["obs_shape"],
          config["n_actions"],
          config["rnn_hidden_dim"],
      )
      qmixer_model = QMixerModel(
          config["n_agents"],
          config["state_shape"],
          config["mixing_embed_dim"],
          config["hypernet_layers"],
          config["hypernet_embed_dim"],
      )
  
      algorithm = QMIX(
          agent_model,
          qmixer_model,
          config["double_q"],
          config["gamma"],
          config["lr"],
          config["clip_grad_norm"],
      )
  
      qmix_agent = QMixAgent(
          algorithm,
          config["exploration_start"],
          config["min_exploration"],
          config["exploration_decay"],
          config["update_target_interval"],
      )
  
      while rpm.count < config["memory_warmup_size"]:
          (
              train_reward,
              train_step,
              train_is_win,
              train_loss,
              train_td_error,
          ) = run_train_episode(env, qmix_agent, rpm, config)
  
      total_steps = 0
      last_test_step = -1e10
      while total_steps < config["training_steps"]:
          (
              train_reward,
              train_step,
              train_is_win,
              train_loss,
              train_td_error,
          ) = run_train_episode(env, qmix_agent, rpm, config)
          total_steps += train_step
  
          if total_steps - last_test_step >= config["test_steps"]:
              last_test_step = total_steps
              eval_is_win_buffer = []
              eval_reward_buffer = []
              eval_steps_buffer = []
              for _ in range(3):
                  (
                      eval_reward,
                      eval_step,
                      eval_is_win,
                  ) = run_evaluate_episode(env, qmix_agent)
                  eval_reward_buffer.append(eval_reward)
                  eval_steps_buffer.append(eval_step)
                  eval_is_win_buffer.append(eval_is_win)
  
              summary.add_scalar("train_loss", train_loss, total_steps)
              summary.add_scalar(
                  "eval_reward",
                  np.mean(eval_reward_buffer),
                  total_steps,
              )
              summary.add_scalar(
                  "eval_steps", np.mean(eval_steps_buffer), total_steps
              )
              summary.add_scalar(
                  "eval_win_rate",
                  np.mean(eval_is_win_buffer),
                  total_steps,
              )
              summary.add_scalar(
                  "exploration", qmix_agent.exploration, total_steps
              )
              summary.add_scalar(
                  "replay_buffer_size", rpm.count, total_steps
              )
              summary.add_scalar(
                  "target_update_count",
                  qmix_agent.target_update_count,
                  total_steps,
              )
              summary.add_scalar(
                  "train_td_error:", train_td_error, total_steps
              )
  
file_path: PARL/benchmark/torch/qmix/train.py
imports: from smac.env import StarCraft2Env
  from env_wrapper import SC2EnvWrapper
  from replay_buffer import EpisodeExperience, EpisodeReplayBuffer
  from qmixer_model import QMixerModel
  from rnn_model import RNNModel
  from parl.algorithms import QMIX
  from qmix_agent import QMixAgent
  from parl.utils import logger, summary
  import numpy
  from copy import deepcopy
  from qmix_config import QMixConfig
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types