class_docstr: PPO Model
class_docstr_tok: ["PPO","Model"]
code: def __init__(self, model_config, mask):
      self.model_config = model_config
      self.states = (
          None  # initial state of lstm in policy/value network
      )
      self.nupdates = None  # the number of func train is invoked, used to tune lr and cliprange
      self.cur_update = 1  # record the current update
      self.np_mask = (
          mask  # record the mask of each action within one trial
      )
  
      set_global_seeds(None)
      assert isinstance(self.model_config.lr, float)
      self.lr = _constfn(self.model_config.lr)
      assert isinstance(self.model_config.cliprange, float)
      self.cliprange = _constfn(self.model_config.cliprange)
  
      # build lstm policy network, value share the same network
      policy = build_lstm_policy(model_config)
  
      # Get the nb of env
      nenvs = model_config.num_envs
  
      # Calculate the batch_size
      self.nbatch = nbatch = (
          nenvs * model_config.nsteps
      )  # num of record per update
      nbatch_train = (
          nbatch // model_config.nminibatches
      )  # get batch size
      # self.nupdates is used to tune lr and cliprange
      self.nupdates = self.model_config.total_timesteps // self.nbatch
  
      # Instantiate the model object (that creates act_model and train_model)
      self.model = Model(
          policy=policy,
          nbatch_act=nenvs,
          nbatch_train=nbatch_train,
          nsteps=model_config.nsteps,
          ent_coef=model_config.ent_coef,
          vf_coef=model_config.vf_coef,
          max_grad_norm=model_config.max_grad_norm,
          np_mask=self.np_mask,
      )
  
      self.states = self.model.initial_state
  
      logger.info("=== finished PPOModel 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 PPOModel object  with example: obj = PPOModel(model_config, mask)