code: def run_train_episode(env, agent, rpm, config):
      episode_limit = config["episode_limit"]
      agent.reset_agent()
      episode_reward = 0.0
      episode_step = 0
      terminated = False
      state, obs = env.reset()
  
      episode_experience = EpisodeExperience(episode_limit)
  
      while not terminated:
          available_actions = env.get_available_actions()
          actions = agent.sample(obs, available_actions)
          next_state, next_obs, reward, terminated = env.step(actions)
          episode_reward += reward
          episode_step += 1
          episode_experience.add(
              state,
              actions,
              [reward],
              [terminated],
              obs,
              available_actions,
              [0],
          )
          state = next_state
          obs = next_obs
  
      # fill the episode
      state_zero = np.zeros_like(state, dtype=state.dtype)
      actions_zero = np.zeros_like(actions, dtype=actions.dtype)
      obs_zero = np.zeros_like(obs, dtype=obs.dtype)
      available_actions_zero = np.zeros_like(
          available_actions, dtype=available_actions.dtype
      )
      reward_zero = 0
      terminated_zero = True
      for _ in range(episode_step, episode_limit):
          episode_experience.add(
              state_zero,
              actions_zero,
              [reward_zero],
              [terminated_zero],
              obs_zero,
              available_actions_zero,
              [1],
          )
      rpm.add(episode_experience)
      is_win = env.win_counted
  
      mean_loss = []
      mean_td_error = []
      if rpm.count > config["memory_warmup_size"]:
          for _ in range(2):
              (
                  s_batch,
                  a_batch,
                  r_batch,
                  t_batch,
                  obs_batch,
                  available_actions_batch,
                  filled_batch,
              ) = rpm.sample_batch(config["batch_size"])
              loss, td_error = agent.learn(
                  s_batch,
                  a_batch,
                  r_batch,
                  t_batch,
                  obs_batch,
                  available_actions_batch,
                  filled_batch,
              )
              mean_loss.append(loss)
              mean_td_error.append(td_error)
  
      mean_loss = np.mean(mean_loss) if mean_loss else None
      mean_td_error = np.mean(mean_td_error) if mean_td_error else None
      return (
          episode_reward,
          episode_step,
          is_win,
          mean_loss,
          mean_td_error,
      )
  
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 1 for calling a global function with example usage: run_train_episode(env, agent, rpm, config) and returns: episode_reward,  episode_step,  is_win,  mean_loss,  mean_td_error