code: def test_by_sparse_reward(agents, config):
      env = StarCraft2Env(
          map_name=config["map"],
          difficulty=config["difficulty"],
          seed=config["env_seed"],
          replay_dir=config["replay_dir"],
          reward_sparse=True,  # Receive 1/-1 reward for winning/loosing an episode
          reward_scale=False,
      )
      win_number = 0
      for ep_id in range(config["test_episode_n"]):
          _, ep_reward = run_episode(env, agents, config, test=True)
          result = "win" if ep_reward > 0 else "defeat"
          print("Episode {}: {}".format(ep_id, result))
          if ep_reward > 0:
              win_number += 1
      env.close()
      win_rate = win_number / config["test_episode_n"]
      print("The win rate of coma is  {}".format(win_rate))
      return win_rate
  
file_path: PARL/benchmark/torch/coma/train.py
imports: from smac.env import StarCraft2Env
  import numpy
  import os
  from sc2_model import ComaModel
  from sc2_agent import Agents
  from parl.algorithms import COMA
  from parl.utils import summary
label_desc: Use image node_id 4 for calling a global function with example usage: test_by_sparse_reward(agents, config) and returns: win_rate