def __init__(self, env, handle, name, eval_obs=None,
                 batch_size=64, reward_decay=0.99, learning_rate=1e-3,
                 train_freq=1, value_coef=0.1, ent_coef=0.1,
                 custom_view_space=None, custom_feature_space=None,
                 *args, **kwargs):
        """init a model

        Parameters
        ----------
        env: Environment
            environment
        handle: Handle (ctypes.c_int32)
            handle of this group, can be got by env.get_handles
        name: str
            name of this model
        learning_rate: float
        batch_size: int
        reward_decay: float
            reward_decay in TD
        eval_obs: numpy array
            evaluation set of observation
        train_freq: int
            mean training times of a sample
        ent_coef: float
            weight of entropy loss in total loss
        value_coef: float
            weight of value loss in total loss
        custom_feature_space: tuple
            customized feature space
        custom_view_space: tuple
            customized feature space
        """
        MXBaseModel.__init__(self, env, handle, name, "mxa2c")
        # ======================== set config  ========================
        self.env = env
        self.handle = handle
        self.view_space = custom_view_space or env.get_view_space(handle)
        self.feature_space = custom_feature_space or env.get_feature_space(handle)
        self.num_actions  = env.get_action_space(handle)[0]
        self.reward_decay = reward_decay

        self.batch_size   = batch_size
        self.learning_rate= learning_rate
        self.train_freq   = train_freq   # train time of every sample (s,a,r,s')
        self.eval_obs     = eval_obs

        self.value_coef = value_coef
        self.ent_coef   = ent_coef

        self.train_ct = 0

        # ======================= build network =======================
        self.ctx = self._get_ctx()

        self.input_view = mx.sym.var("input_view")
        self.input_feature = mx.sym.var("input_feature")

        policy, value = self._create_network(self.input_view, self.input_feature)

        log_policy = mx.sym.log(policy)
        out_policy = mx.sym.BlockGrad(policy)

        neg_entropy = ent_coef * mx.sym.sum(policy * log_policy, axis=1)
        neg_entropy = mx.sym.MakeLoss(data=neg_entropy)

        self.sym = mx.sym.Group([log_policy, value, neg_entropy, out_policy])
        self.model = mx.mod.Module(self.sym, data_names=['input_view', 'input_feature'],
                                   label_names=None, context=self.ctx)

        # bind (set initial batch size)
        self.bind_size = batch_size
        self.model.bind(data_shapes=[('input_view', (batch_size,) + self.view_space),
                                     ('input_feature', (batch_size,) + self.feature_space)],
                        label_shapes=None)

        # init params
        self.model.init_params(initializer=mx.init.Xavier())
        self.model.init_optimizer(optimizer='adam', optimizer_params={
            'learning_rate': learning_rate,
            'clip_gradient': 10,
        })

        # init training buffers
        self.view_buf = np.empty((1,) + self.view_space)
        self.feature_buf = np.empty((1,) + self.feature_space)
        self.action_buf = np.empty(1, dtype=np.int32)
        self.advantage_buf, self.value_buf = np.empty(1), np.empty(1)
        self.terminal_buf = np.empty(1, dtype=np.bool)

        # print("parameters", self.model.get_params())
        # mx.viz.plot_network(self.output).view()
init a model

        Parameters
        ----------
        env: Environment
            environment
        handle: Handle (ctypes.c_int32)
            handle of this group, can be got by env.get_handles
        name: str
            name of this model
        learning_rate: float
        batch_size: int
        reward_decay: float
            reward_decay in TD
        eval_obs: numpy array
            evaluation set of observation
        train_freq: int
            mean training times of a sample
        ent_coef: float
            weight of entropy loss in total loss
        value_coef: float
            weight of value loss in total loss
        custom_feature_space: tuple
            customized feature space
        custom_view_space: tuple
            customized feature space
        
python/magent/builtin/mx_model/a2c.py