class_docstr: PPOTuner, the implementation inherits the main logic of the implementation
  `ppo2 from openai <https://github.com/openai/baselines/tree/master/baselines/ppo2>`__ and is adapted for NAS scenario.
  It uses ``lstm`` for its policy network and value network, policy and value share the same network.
  
  Parameters
  ----------
  optimize_mode : str
      maximize or minimize
  trials_per_update : int
      Number of trials to have for each model update
  epochs_per_update : int
      Number of epochs to run for each model update
  minibatch_size : int
      Minibatch size (number of trials) for the update
  ent_coef : float
      Policy entropy coefficient in the optimization objective
  lr : float
      Learning rate of the model (lstm network), constant
  vf_coef : float
      Value function loss coefficient in the optimization objective
  max_grad_norm : float
      Gradient norm clipping coefficient
  gamma : float
      Discounting factor
  lam : float
      Advantage estimation discounting factor (lambda in the paper)
  cliprange : float
      Cliprange in the PPO algorithm, constant
class_docstr_tok: ["PPOTuner",",","the","implementation","inherits","the","main","logic","of","the","implementation","`","ppo2","from","openai","<","https",":","\/\/github.com\/openai\/baselines\/tree\/master\/baselines\/ppo2",">","`","__","and","is","adapted","for","NAS","scenario",".","It","uses","``","lstm","``","for","its","policy","network","and","value","network",",","policy","and","value","share","the","same","network",".","Parameters","--","--","--","--","--","optimize_mode",":","str","maximize","or","minimize","trials_per_update",":","int","Number","of","trials","to","have","for","each","model","update","epochs_per_update",":","int","Number","of","epochs","to","run","for","each","model","update","minibatch_size",":","int","Minibatch","size","(","number","of","trials",")","for","the","update","ent_coef",":","float","Policy","entropy","coefficient","in","the","optimization","objective","lr",":","float","Learning","rate","of","the","model","(","lstm","network",")",",","constant","vf_coef",":","float","Value","function","loss","coefficient","in","the","optimization","objective","max_grad_norm",":","float","Gradient","norm","clipping","coefficient","gamma",":","float","Discounting","factor","lam",":","float","Advantage","estimation","discounting","factor","(","lambda","in","the","paper",")","cliprange",":","float","Cliprange","in","the","PPO","algorithm",",","constant"]
code: def __init__(
      self,
      optimize_mode,
      trials_per_update=20,
      epochs_per_update=4,
      minibatch_size=4,
      ent_coef=0.0,
      lr=3e-4,
      vf_coef=0.5,
      max_grad_norm=0.5,
      gamma=0.99,
      lam=0.95,
      cliprange=0.2,
  ):
      self.optimize_mode = OptimizeMode(optimize_mode)
      self.model_config = ModelConfig()
      self.model = None
      self.search_space = None
      self.running_trials = (
          {}
      )  # key: parameter_id, value: actions/states/etc.
      self.inf_batch_size = trials_per_update  # number of trials to generate in one inference
      self.first_inf = True  # indicate whether it is the first time to inference new trials
      self.trials_result = [
          None for _ in range(self.inf_batch_size)
      ]  # results of finished trials
  
      self.credit = 0  # record the unsatisfied trial requests
      self.param_ids = []
      self.finished_trials = 0
      self.chosen_arch_template = {}
  
      self.actions_spaces = None
      self.actions_to_config = None
      self.full_act_space = None
      self.trials_info = None
  
      self.all_trials = (
          {}
      )  # used to dedup the same trial, key: config, value: final result
  
      self.model_config.num_envs = self.inf_batch_size
      self.model_config.noptepochs = epochs_per_update
      self.model_config.nminibatches = minibatch_size
  
      self.send_trial_callback = None
      logger.info("Finished PPOTuner initialization")
  
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 1 to create a new PPOTuner object from inherited base classes: Tuner with example: obj = PPOTuner(optimize_mode, trials_per_update, epochs_per_update, minibatch_size, ent_coef, lr, vf_coef, max_grad_norm, gamma, lam, cliprange)