def encode_observation(ob_space, placeholder):
if isinstance(ob_space, Discrete):<EOL><INDENT>return tf.to_float(tf.one_hot(placeholder, ob_space.n))<EOL><DEDENT>elif isinstance(ob_space, Box):<EOL><INDENT>return tf.to_float(placeholder)<EOL><DEDENT>elif isinstance(ob_space, MultiDiscrete):<EOL><INDENT>placeholder = tf.cast(placeholder, tf.int32)<EOL>one_hots = [tf.to_float(tf.one_hot(placeholder[..., i], ob_space.nvec[i])) for i in range(placeholder.shape[-<NUM_LIT:1>])]<EOL>return tf.concat(one_hots, axis=-<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>
Encode input in the way that is appropriate to the observation space

Parameters:
----------

ob_space: gym.Space             observation space

placeholder: tf.placeholder     observation input placeholder