docstr: input:
      batch: dict(o, s, u, r, u_onehot, avail_u, padded, isover, actor_inputs, critic_inputs)
      epsilon: noise discount factor
  output:
      action_prob: probability of actions, shape (ep_num, tr_num, n_agents, n_actions)
docstr_tok: ["input",":","batch",":","dict","(","o",",","s",",","u",",","r",",","u_onehot",",","avail_u",",","padded",",","isover",",","actor_inputs",",","critic_inputs",")","epsilon",":","noise","discount","factor","output",":","action_prob",":","probability","of","actions",",","shape","(","ep_num",",","tr_num",",","n_agents",",","n_actions",")"]
code: def _get_actor_output(self, batch, epsilon):
      """input:
          batch: dict(o, s, u, r, u_onehot, avail_u, padded, isover, actor_inputs, critic_inputs)
          epsilon: noise discount factor
      output:
          action_prob: probability of actions, shape (ep_num, tr_num, n_agents, n_actions)
      """
      ep_num = batch["r"].shape[0]
      tr_num = batch["r"].shape[1]
      avail_actions = batch["avail_u"]
      actor_inputs = batch["actor_inputs"]
      action_prob = []
      for tr_id in range(tr_num):
          inputs = actor_inputs[
              :, tr_id
          ]  # shape (ep_num, n_agents, actor_input_dim)
          inputs = inputs.reshape(
              (-1, inputs.shape[-1])
          )  # shape (-1, actor_input_dim)
          policy_logits, self.train_rnn_h = self.model.policy(
              inputs, self.train_rnn_h
          )
          # policy_logits shape from (-1, n_actions) to (ep_num, n_agents, n_actions)
          policy_logits = policy_logits.view(ep_num, self.n_agents, -1)
          prob = torch.nn.functional.softmax(policy_logits, dim=-1)
          action_prob.append(prob)
  
      action_prob = torch.stack(action_prob, dim=1).to(
          self.device
      )  # shape: (ep_num, tr_num, n_agents, n_actions)
      action_num = avail_actions.sum()  # how many actions are available
      action_prob = (1 - epsilon) * action_prob + torch.ones_like(
          action_prob
      ) * epsilon / action_num
      action_prob[avail_actions == 0] = 0.0  # set avail action
  
      action_prob = action_prob / action_prob.sum(
          dim=-1, keepdim=True
      )  # in case action_prob.sum != 1
      action_prob[avail_actions == 0] = 0.0
      action_prob = action_prob.to(self.device)
      return action_prob
  
file_path: PARL/parl/algorithms/torch/coma.py
imports: import torch
  import os
  from copy import deepcopy
  import parl
  from parl.utils.utils import check_model_method
  import numpy
label_desc: Use image node_id 5 for calling the COMA obj's underlying member method code with example usage: obj._get_actor_output(batch, epsilon) and returns: action_prob