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 _process_nas_space(self, search_space):
      actions_spaces = []
      actions_to_config = []
      for key, val in search_space.items():
          if val["_type"] == "layer_choice":
              actions_to_config.append((key, "layer_choice"))
              actions_spaces.append(val["_value"])
              self.chosen_arch_template[key] = None
          elif val["_type"] == "input_choice":
              candidates = val["_value"]["candidates"]
              n_chosen = val["_value"]["n_chosen"]
              if n_chosen not in [0, 1, [0, 1]]:
                  raise ValueError(
                      "Optional_input_size can only be 0, 1, or [0, 1], but the pecified one is %s"
                      % (n_chosen)
                  )
              if isinstance(n_chosen, list):
                  actions_to_config.append((key, "input_choice"))
                  # FIXME: risk, candidates might also have None
                  actions_spaces.append(["None", *candidates])
                  self.chosen_arch_template[key] = None
              elif n_chosen == 1:
                  actions_to_config.append((key, "input_choice"))
                  actions_spaces.append(candidates)
                  self.chosen_arch_template[key] = None
              elif n_chosen == 0:
                  self.chosen_arch_template[key] = []
          else:
              raise ValueError(
                  "Unsupported search space type: %s" % (val["_type"])
              )
  
      # calculate observation space
      dedup = {}
      for step in actions_spaces:
          for action in step:
              dedup[action] = 1
      full_act_space = [act for act, _ in dedup.items()]
      assert len(full_act_space) == len(dedup)
      observation_space = len(full_act_space)
      nsteps = len(actions_spaces)
  
      return (
          actions_spaces,
          actions_to_config,
          full_act_space,
          observation_space,
          nsteps,
      )
  
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 PPOTuner obj's underlying member method code with example usage: obj._process_nas_space(search_space) and returns: actions_spaces,  actions_to_config,  full_act_space,  observation_space,  nsteps