class_docstr: Non-tensorflow API for infering policy (and value function).
  
  Example:
    >>> ppo = PPOPolicyInferencer(...)
    >>> ppo.reset_frame_stack()
    >>> ob = env.reset()
    >>> while not done:
    >>>   logits, value = ppo.infer(ob)
    >>>   ob, _, done, _ = env.step(action)
class_docstr_tok: ["Non-tensorflow","API","for","infering","policy","(","and","value","function",")",".","Example",":",">",">",">","ppo","=","PPOPolicyInferencer","(","...",")",">",">",">","ppo.reset_frame_stack","(",")",">",">",">","ob","=","env.reset","(",")",">",">",">","while","not","done",":",">",">",">","logits",",","value","=","ppo.infer","(","ob",")",">",">",">","ob",",","_",",","done",",","_","=","env.step","(","action",")"]
code: def __init__(
      self, hparams, action_space, observation_space, policy_dir
  ):
      assert hparams.base_algo == "ppo"
      ppo_hparams = trainer_lib.create_hparams(hparams.base_algo_params)
  
      frame_stack_shape = (
          1,
          hparams.frame_stack_size,
      ) + observation_space.shape
      self._frame_stack = np.zeros(frame_stack_shape, dtype=np.uint8)
  
      with tf.Graph().as_default():
          self.obs_t = tf.placeholder(
              shape=self.frame_stack_shape, dtype=np.uint8
          )
          self.logits_t, self.value_function_t = get_policy(
              self.obs_t, ppo_hparams, action_space
          )
          model_saver = tf.train.Saver(
              tf.global_variables(
                  scope=ppo_hparams.policy_network + "/.*"
              )  # pylint: disable=unexpected-keyword-arg
          )
          self.sess = tf.Session()
          self.sess.run(tf.global_variables_initializer())
          trainer_lib.restore_checkpoint(
              policy_dir, model_saver, self.sess
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import os
  import re
  import gym
  import numpy
  import six
  from tensor2tensor.models.research.rl import get_policy
  from tensor2tensor.models.research.rl import make_simulated_env_fn_from_hparams
  from tensor2tensor.rl import rl_utils
  from tensor2tensor.rl.envs.simulated_batch_gym_env import FlatBatchEnv
  from tensor2tensor.utils import hparam
  from tensor2tensor.utils import trainer_lib
  from tensor2tensor.utils.misc_utils import camelcase_to_snakecase
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new PPOPolicyInferencer object from inherited base classes: object with example: obj = PPOPolicyInferencer(hparams, action_space, observation_space, policy_dir)