class_docstr: PPO Model
class_docstr_tok: ["PPO","Model"]
docstr: Generate actions along with related info from policy network.
  observation is the action of the last step.
  
  Parameters
  ----------
  num: int
      The number of trials to generate
  
  Returns
  -------
  mb_obs : list
      Observation of the ``num`` configurations
  mb_actions : list
      Actions of the ``num`` configurations
  mb_values : list
      Values from the value function of the ``num`` configurations
  mb_neglogpacs : list
      ``neglogp`` of the ``num`` configurations
  mb_dones : list
      To show whether the play is done, always ``True``
  last_values : tensorflow tensor
      The last values of the ``num`` configurations, got with session run
docstr_tok: ["Generate","actions","along","with","related","info","from","policy","network",".","observation","is","the","action","of","the","last","step",".","Parameters","--","--","--","--","--","num",":","int","The","number","of","trials","to","generate","Returns","--","--","--","-","mb_obs",":","list","Observation","of","the","``","num","``","configurations","mb_actions",":","list","Actions","of","the","``","num","``","configurations","mb_values",":","list","Values","from","the","value","function","of","the","``","num","``","configurations","mb_neglogpacs",":","list","``","neglogp","``","of","the","``","num","``","configurations","mb_dones",":","list","To","show","whether","the","play","is","done",",","always","``","True","``","last_values",":","tensorflow","tensor","The","last","values","of","the","``","num","``","configurations",",","got","with","session","run"]
code: def inference(self, num):
      """
      Generate actions along with related info from policy network.
      observation is the action of the last step.
  
      Parameters
      ----------
      num: int
          The number of trials to generate
  
      Returns
      -------
      mb_obs : list
          Observation of the ``num`` configurations
      mb_actions : list
          Actions of the ``num`` configurations
      mb_values : list
          Values from the value function of the ``num`` configurations
      mb_neglogpacs : list
          ``neglogp`` of the ``num`` configurations
      mb_dones : list
          To show whether the play is done, always ``True``
      last_values : tensorflow tensor
          The last values of the ``num`` configurations, got with session run
      """
      # Here, we init the lists that will contain the mb of experiences
      mb_obs, mb_actions, mb_values, mb_dones, mb_neglogpacs = (
          [],
          [],
          [],
          [],
          [],
      )
      # initial observation
      # use the (n+1)th embedding to represent the first step action
      first_step_ob = self.model_config.action_space.n
      obs = [first_step_ob for _ in range(num)]
      dones = [True for _ in range(num)]
      states = self.states
      # For n in range number of steps
      for cur_step in range(self.model_config.nsteps):
          # Given observations, get action value and neglopacs
          # We already have self.obs because Runner superclass run self.obs[:] = env.reset() on init
          actions, values, states, neglogpacs = self.model.step(
              cur_step, obs, S=states, M=dones
          )
          mb_obs.append(obs.copy())
          mb_actions.append(actions)
          mb_values.append(values)
          mb_neglogpacs.append(neglogpacs)
          mb_dones.append(dones)
  
          # Take actions in env and look the results
          # Infos contains a ton of useful informations
          obs[:] = actions
          if cur_step == self.model_config.nsteps - 1:
              dones = [True for _ in range(num)]
          else:
              dones = [False for _ in range(num)]
  
      # batch of steps to batch of rollouts
      np_obs = np.asarray(obs)
      mb_obs = np.asarray(mb_obs, dtype=np_obs.dtype)
      mb_actions = np.asarray(mb_actions)
      mb_values = np.asarray(mb_values, dtype=np.float32)
      mb_neglogpacs = np.asarray(mb_neglogpacs, dtype=np.float32)
      mb_dones = np.asarray(mb_dones, dtype=bool)
      last_values = self.model.value(np_obs, S=states, M=dones)
  
      return (
          mb_obs,
          mb_actions,
          mb_values,
          mb_neglogpacs,
          mb_dones,
          last_values,
      )
  
imports: import copy
  import logging
  import numpy
  from gym import spaces
  from schema import Schema, Optional
  import nni
  from nni import ClassArgsValidator
  from nni.tuner import Tuner
  from nni.utils import OptimizeMode, extract_scalar_reward
  from .model import Model
  from .util import set_global_seeds
  from .policy import build_lstm_policy
label_desc: Use image node_id 2 for calling the PPOModel obj's underlying member method code with example usage: obj.inference(num) and returns: mb_obs,  mb_actions,  mb_values,  mb_neglogpacs,  mb_dones,  last_values